def fbresize(): x = None while True: if x is None: x, y = glfw.get_framebuffer_size(w) else: _, x, y = yield from listen.on_framebuffer_size(w) # adjust viewport glViewport(0, 0, x, y) # adjust projection projection.set_uniform(shaderProgram, "projection") projection.clear() projection.ortho(0, x, 0, y, 0, 100)
def viewport_loop(): while True: # set the viewport glViewport(0,0,globs.cam["w"], globs.cam["h"]) # build orthographic projection proj = np.eye(4) s = globs.cam["pixels_per_unit"]*globs.cam["pixel_scale"] proj = scale(s,s,-1) @ proj proj = scale(2/globs.cam["w"],2/globs.cam["h"],1) @ proj proj = translate(-1,-1,0) @ proj globs.cam["projection"] = proj globs.cam["projection-inv"] = np.linalg.inv(proj) # wait until framebuffer gets resized yield from listen.on_framebuffer_size(globs.window) globs.cam["w"], globs.cam["h"] = glfw.get_framebuffer_size(globs.window)
def viewport_loop(): while True: # set the viewport glViewport(0, 0, globs.cam["w"], globs.cam["h"]) # origin = bottom left corner # x,y = position in window in pixels proj = np.eye(4) proj = scale(2 / globs.cam["w"], 2 / globs.cam["h"], 1) @ proj proj = translate(-1, -1, 0) @ proj globs.cam["projection"] = proj globs.cam["projection-inv"] = np.linalg.inv(proj) # wait until framebuffer gets resized yield from listen.on_framebuffer_size(globs.window) globs.cam["w"], globs.cam["h"] = glfw.get_framebuffer_size( globs.window)