コード例 #1
0
ファイル: frontend.py プロジェクト: atthecodeface/webgl
 def run(self) -> None:
     self.animating = False
     self.time_last = glfw.get_time()
     self.keys_down = set()
     self.key_mods = 0
     self.buttons_down = 0
     self.mouse_pos_drag_start = (0.,0.)
     self.mouse_pos = (0.,0.)
     while not self.animating and not glfw.window_should_close(self.main_window):
         time_now = glfw.get_time()
         timeout = self.time_last + self.frame_delay - time_now
         if timeout > 0:
             glfw.wait_events_timeout(timeout)
             pass
         else:
             glfw.poll_events()
             pass
         time_now = glfw.get_time()
         if time_now > self.time_last + self.frame_delay:
             self.time_last = time_now
             glfw.make_context_current(self.main_window)
             self.idle()
             pass
         pass
     glfw.terminate()
     pass
コード例 #2
0
def main():
    glfw.init()

    glfw.window_hint(glfw.RESIZABLE, False)
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)

    w, h = 800, 640

    globs.window = glfw.create_window(w, h, 'PlatformPrototype', None, None)
    x = glfw.make_context_current(globs.window)

    # initialize libraries
    init_quadarray()
    init_textbox(w=2000, h=2000)  # dimension of glyph atlas

    globs.spf = 0.015  # 60ish fps

    # this stuff gets rendered by the render_loop
    globs.quadarrays = []
    globs.textboxes = []

    # launch loops (order matters here)
    listen.launch(game_loop())
    render_init(w, h)
    load_assets()
    edit_init()
    play_init()

    # the main loop.
    while not glfw.window_should_close(globs.window):
        glfw.wait_events_timeout(globs.spf / 10)
        listen.trigger_timers()

    glfw.terminate()
コード例 #3
0
def main():
    glfw.init()

    glfw.window_hint(glfw.RESIZABLE, False)
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)

    w, h = 800, 800

    globs.window = glfw.create_window(w, h, 'Tesseland', None, None)
    glfw.make_context_current(globs.window)

    init_polygon_shader()

    levels_init()

    globs.spf = 0.015  # 60ish fps
    listen.launch(game_loop())

    render_init(w, h)
    play_init()
    hud_init()

    # the main loop.
    while not glfw.window_should_close(globs.window):
        glfw.wait_events_timeout(globs.spf / 10)
        listen.trigger_timers()

    glfw.terminate()
コード例 #4
0
def better_event_loop(max_fps=100):
    """ A simple event loop that schedules draws. """
    td = 1 / max_fps
    while update_glfw_canvasses():
        # Determine next time to draw
        now = perf_counter()
        tnext = math.ceil(now / td) * td
        # Process events until it's time to draw
        while now < tnext:
            glfw.wait_events_timeout(tnext - now)
            now = perf_counter()
コード例 #5
0
ファイル: world.py プロジェクト: shirobu2400/mmdpy
    def run(self) -> bool:
        """run is main method.

        Returns:
            bool: return True if thw window is closed, false otherwise.
        """
        if glfw.window_should_close(self.window):
            return True

        # Set matrix mode
        gl.glClear(
            cast(int, gl.GL_COLOR_BUFFER_BIT)
            | cast(int, gl.GL_DEPTH_BUFFER_BIT))
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()

        # set perspective
        glu.gluPerspective(
            45.0,
            float(self.window_width) / float(self.window_height), 0.10, 160.0)

        # set camera
        glu.gluLookAt(0.0, 10.0, -30.0, 0.0, 10.0, 0.0, 0.0, 1.0, 0.0)

        # Render here, e.g. using pyOpenGL
        for model in self.models:
            model.draw()

        # enforce OpenGL command
        gl.glFlush()

        # Swap front and back buffers
        glfw.swap_buffers(self.window)

        # Poll for and process events
        glfw.poll_events()

        # wait
        glfw.wait_events_timeout(
            max(0.00, 1. / 60 - self.fps_calc.elapsed_time()))

        return False
コード例 #6
0
ファイル: game.py プロジェクト: Rinwasyu/maikura-modoki
def main():
    global window

    if not glfw.init():
        return

    glfw.window_hint(glfw.DOUBLEBUFFER, glfw.TRUE)
    window = glfw.create_window(window_width, window_height, "maikura-modoki",
                                None, None)

    if not window:
        glfw.terminate()
        return

    glfw.set_window_size_callback(window, window_size_callback)
    glfw.set_window_refresh_callback(window, window_refresh_callback)
    glfw.set_key_callback(window, key_callback)
    glfw.set_cursor_pos_callback(window, cursor_pos_callback)
    glfw.set_mouse_button_callback(window, mouse_button_callback)
    glfw.make_context_current(window)

    glClearColor(0.5, 0.8, 1.0, 1.0)
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_CULL_FACE)
    glCullFace(GL_BACK)
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)
    glEnable(GL_LIGHT1)

    init()

    set_view(window_width, window_height)
    display()

    while not glfw.window_should_close(window):
        glfw.wait_events_timeout(1e-3)
        update()

    glfw.terminate()
コード例 #7
0
	def mainloop(self):

		FPS = float(60)
		render_interval = 1/FPS

		while not glfw.window_should_close(self.window):
			
			#glfw.poll_events()
			glfw.wait_events_timeout(render_interval)

			#self.prerenderUI_2D()
			
			if visualMode.STEREO == self.eVisualMode:
				self.renderSceneFromEye(self.fbo_left, eyePosition.LEFT)
				self.renderSceneFromEye(self.fbo_right, eyePosition.RIGHT)

				self.ctx.screen.use()
				self.ctx.clear(0.16, 0.16, 0.16, 1.0)
				self.ctx.enable(moderngl.DEPTH_TEST)

				#self.vao.render()

				self.mvp.write((self.proj * self.lookat).astype('f4').tobytes())
				
				self.texture_left.use()
				self.vao_left_quad.render(moderngl.TRIANGLE_STRIP)
				
				self.texture_right.use()
				self.vao_right_quad.render(moderngl.TRIANGLE_STRIP)

			else:
				self.renderSceneFromEye(self.ctx.screen, eyePosition.NONE)

			#self.renderUI_2D()
			
			glfw.swap_buffers(self.window)
コード例 #8
0
 def wait_events_timeout(self):
     glfw.make_context_current(self.window)
     glfw.wait_events_timeout(1e-3)
コード例 #9
0
 def wait_events(self, timeout=None):
     if timeout is None:
         glfw.wait_events()
     else:
         glfw.wait_events_timeout(timeout)
コード例 #10
0
def main():
    glfw.init()

    # Common window hints and their defaults

    glfw.window_hint(glfw.FOCUS_ON_SHOW, True)

    # for windowed windows
    glfw.window_hint(glfw.RESIZABLE, True)
    glfw.window_hint(glfw.VISIBLE, True)
    glfw.window_hint(glfw.DECORATED, True)
    glfw.window_hint(glfw.FOCUSED, True)
    glfw.window_hint(glfw.FLOATING, False)
    glfw.window_hint(glfw.MAXIMIZED, False)

    # for full screen windows
    # To make full screen, pass a monitor as the 5th argument to glfw.create_window,
    # or use glfw.set_window_monitor(w,mon).
    # Auto_iconify means to minimize when focus lost.
    glfw.window_hint(glfw.AUTO_ICONIFY, True)
    glfw.window_hint(glfw.CENTER_CURSOR, True)

    # opengl options
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)

    glfw.window_hint(glfw.DEPTH_BITS, 24)
    glfw.window_hint(glfw.STENCIL_BITS, 8)

    # transparency
    glfw.window_hint(glfw.TRANSPARENT_FRAMEBUFFER, False)
    # later call glfw.set_window_opacity(w, 0.5)
    # and use glfw.get_window_opacity(w)

    # for X11
    glfw.window_hint_string(glfw.X11_CLASS_NAME, "")
    glfw.window_hint_string(glfw.X11_INSTANCE_NAME, "")

    #####################

    global w
    w = glfw.create_window(800, 600, 'Window Title', None, None)
    glfw.make_context_current(w)

    # glfw.set_window_title(w, "Window Title")

    # controlling window size
    # get/set interchangable
    # glfw.set_window_pos(w, x, y)
    # glfw.set_window_size(w, width, height)
    # glfw.set_window_size_limits(w, minW, minH, maxW, maxH)
    # glfw.set_window_aspect_ratio(w, 16, 9)
    # get only
    # glfw.get_window_frame_size(w)   # with borders and all, get only
    # glfw.get_framebuffer_size(w)    # get only

    # window status
    # glfw.iconify_window(w) / glfw.restore_window(w)
    # glfw.get_window_attrib(w, glfw.ICONIFIED)
    # glfw.maximize_window(w) / glfw.restore_window(w)
    # glfw.get_window_attrib(w, glfw.MAXIMIZED)
    # glfw.hide_window / glfw.show_window
    # glfw.get_window_attrib(w, glfw.VISIBLE)
    # glfw.focus_window(w) or glfw.request_window_attention(w)
    # glfw.get_window_attrib(w, glfw.FOCUSED)
    # glfw.set_window_should_close(w, False)

    # clipboard
    # glfw.get_clipboard_string(w)
    # glfw.set_clipboard_string(w, "hello")

    def clock():
        while True:
            dt = yield from listen.wait(0.2)

    listen.launch(clock())

    ####################
    shaderProgram = make_shader_program()
    glUseProgram(shaderProgram)

    vao = glGenVertexArrays(1)
    glBindVertexArray(vao)

    tri_vbo = glGenBuffers(1)
    glBindBuffer(GL_ARRAY_BUFFER, tri_vbo)
    v1, v2, v3 = Vec(0, 0, 0), Vec(1, 1, 0), Vec(1, 0, 0)
    vertices = Vec(v1, v2, v3)
    glBufferData(GL_ARRAY_BUFFER, vertices.size, vertices.buffer,
                 GL_STATIC_DRAW)
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, ctypes.c_void_p(0))
    glEnableVertexAttribArray(0)

    ###################

    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)

    listen.launch(fbresize())

    import time, math
    t0 = time.time()

    while not glfw.window_should_close(w):
        glClearColor(0.0, 0.0, 0.0, 1.0)
        glClear(GL_COLOR_BUFFER_BIT)

        projection.set_uniform(shaderProgram, "modelview")

        projection.push()
        theta = 10 * (time.time() - t0)
        projection.translate(100, 100, 0.0)
        projection.translate(10 * math.sin(theta), 10 * math.cos(theta), 0.0)

        projection.scale(100, 100, 1)
        glDrawArrays(GL_TRIANGLES, 0, 3)
        projection.pop()

        glfw.swap_buffers(w)

        # glfw.poll_events()  # non-blocking
        # glfw.wait_events()  # blocks until an event is received
        # glfw.wait_events_timeout(0.4) # blocks until event or timeout
        # To unblock the main thread from wait_events(), use glfw.post_empty_event()

        glfw.wait_events_timeout(0.01)  # 100 fps
        listen.trigger_timers()

    glfw.terminate()
コード例 #11
0
def main():
    glfw.init()

    # for windowed windows
    glfw.window_hint(glfw.RESIZABLE, True)

    # opengl options
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)

    global w
    w = glfw.create_window(800, 600, 'Window Title', None, None)
    glfw.make_context_current(w)

    ####################
    shaderProgram = make_shader_program()
    glUseProgram(shaderProgram)

    vao = glGenVertexArrays(1)
    glBindVertexArray(vao)

    tri_vbo = glGenBuffers(1)
    glBindBuffer(GL_ARRAY_BUFFER, tri_vbo)
    vertices = Vec(0, 0), Vec(0, 1), Vec(1, 1), Vec(1, 0)
    vertices = Vec(*vertices)
    glBufferData(GL_ARRAY_BUFFER, vertices.size, vertices.buffer,
                 GL_STATIC_DRAW)
    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, ctypes.c_void_p(0))
    glEnableVertexAttribArray(0)

    colorUniform = glGetUniformLocation(shaderProgram, "color")
    glUniform4f(colorUniform, 1, 1, 1, 1)
    ###################

    node = PaddingNode(
        vertical="*",
        children=[
            RowsNode(children=[
                RowsNode(children=[
                    HintedNode(width=100, height=300, key="node1"),
                    HintedNode(width=200, height=100, key="node2"),
                    HintedNode(width=150, height=200, key="node3"),
                ])
            ])
        ])

    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)

            # adjust node
            node_window_fit(node, w)

    listen.launch(fbresize())

    def rectnode(node, color):
        while True:
            yield from node.on_draw()
            colorUniform = glGetUniformLocation(shaderProgram, "color")
            glUniform4f(colorUniform, color.x, color.y, color.z, color.w)

            projection.set_uniform(shaderProgram, 'modelview')

            projection.push()
            projection.translate(node.x, node.y, 0.0)
            projection.scale(node.width, node.height, 1)
            glDrawArrays(GL_TRIANGLE_FAN, 0, 4)
            projection.pop()

    listen.launch(rectnode(node["node1"], Vec(1, 0, 0, 1)))
    listen.launch(rectnode(node["node2"], Vec(0, 1, 0, 1)))
    listen.launch(rectnode(node["node3"], Vec(0, 0, 1, 1)))
    listen.launch(rectnode(node, Vec(0.2, 0.4, 0.3, 1)))

    while not glfw.window_should_close(w):
        glClearColor(0.0, 0.0, 0.0, 1.0)
        glClear(GL_COLOR_BUFFER_BIT)

        node.draw()

        glfw.swap_buffers(w)

        glfw.wait_events_timeout(0.01)  # 100 fps
        listen.trigger_timers()

    glfw.terminate()
コード例 #12
0
ファイル: sample_glfw.py プロジェクト: shirobu2400/mmdpy
def main():

    width = 640
    height = 480

    # Set argment parsers
    parser = argparse.ArgumentParser(description="MMD model viewer sample.")
    parser.add_argument("-p", type=str, help="MMD model file name.")
    parser.add_argument("-v", type=str, help="MMD motion file name.")
    parser.add_argument("--bone", type=bool, default=False, help="Print bone informations.")
    args = parser.parse_args()

    # Initialize GLFW
    if not glfw.init():
        return

    # Create window
    gl_window = glfw.create_window(width, height, 'mmdpy sample', None, None)
    if not gl_window:
        glfw.terminate()
        print('Failed to create window')
        return

    # Create context
    # glfw.set_window_size_callback(window, window_size)
    # glfw.set_window_refresh_callback(window, window_refresh)
    glfw.make_context_current(gl_window)

    # OpenGL Version
    print('Vendor :', gl.glGetString(gl.GL_VENDOR))
    print('GPU :', gl.glGetString(gl.GL_RENDERER))
    print('OpenGL version :', gl.glGetString(gl.GL_VERSION))

    # load argment
    model_name = args.p
    motion_name = args.v
    bone_information = args.bone
    print(model_name)
    print(motion_name)

    # Create mmdpy
    model = mmdpy.model()

    # load model
    if model_name is not None and not model.load(model_name):
        raise IOError("Model is not found")
    if bone_information:
        model.bonetree()

    # Load motion
    if motion_name != "" and not model.motion("vmd").load(motion_name):
        raise IOError("Motion is not found")

    gl.glClearColor(0.0, 0.0, 1.0, 1.0)
    gl.glEnable(gl.GL_DEPTH_TEST)  # enable shading

    # modeling transform
    gl.glMatrixMode(gl.GL_MODELVIEW)

    # light color
    light_ambient = [0.25, 0.25, 0.25]
    light_diffuse = [1.0, 1.0, 1.0]
    light_specular = [1.0, 1.0, 1.0]

    # light position
    light_position = [0, 0, 2, 1]

    # light setting
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, light_ambient)
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, light_diffuse)
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, light_specular)
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, light_position)
    gl.glEnable(gl.GL_LIGHT0)
    gl.glEnable(gl.GL_LIGHTING)

    while not glfw.window_should_close(gl_window):

        # Projection matrix
        width, height = glfw.get_framebuffer_size(gl_window)
        if width == 0 or height == 0:
            continue

        gl.glViewport(0, 0, width, height)
        gl.glLoadIdentity()
        glu.gluPerspective(45.0, float(width) / float(height), 0.10, 160.0)

        # Set matrix mode
        gl.glClear(cast(int, gl.GL_COLOR_BUFFER_BIT) | cast(int, gl.GL_DEPTH_BUFFER_BIT))
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()

        # set perspective
        glu.gluPerspective(45.0, float(width) / float(height), 0.10, 160.0)

        # set camera
        glu.gluLookAt(0.0, 10.0, -30.0, 0.0, 10.0, 0.0, 0.0, 1.0, 0.0)

        # step motion
        model.motion("vmd").step()

        # Render here, e.g. using pyOpenGL
        model.draw()

        # enforce OpenGL command
        gl.glFlush()

        # Swap front and back buffers
        glfw.swap_buffers(gl_window)

        # Poll for and process events
        glfw.poll_events()

        # wait
        glfw.wait_events_timeout(1. / 60)

    # Destory window
    glfw.destroy_window(gl_window)

    # finish GLFW
    glfw.terminate()
コード例 #13
0
def main():
    glfw.init()

    glfw.window_hint(glfw.RESIZABLE, False)
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)

    window = glfw.create_window(800, 600, 'Window Title', None, None)
    glfw.make_context_current(window)

    # A standard rectangle
    rect_vbo = glGenBuffers(1)
    glBindBuffer(GL_ARRAY_BUFFER, rect_vbo)
    vertices = Vec(1, 1), Vec(1, 0), Vec(0, 0), Vec(0, 1)
    vertices = Vec(*vertices)
    glBufferData(GL_ARRAY_BUFFER, vertices.size, vertices.buffer,
                 GL_STATIC_DRAW)
    glBindBuffer(GL_ARRAY_BUFFER, 0)

    frames, sheet = load_spritesheet("terrain.json")
    for frame in frames:
        # make a vao for this frame
        frame["vao"] = glGenVertexArrays(1)
        glBindVertexArray(frame["vao"])

        # bind the rect vbo to this vao as attribute 0
        glBindBuffer(GL_ARRAY_BUFFER, rect_vbo)
        glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, ctypes.c_void_p(0))
        glEnableVertexAttribArray(0)
        glBindBuffer(GL_ARRAY_BUFFER, 0)

        # make a vbo for the texcoords
        tex_coord_vbo = glGenBuffers(1)
        glBindBuffer(GL_ARRAY_BUFFER, tex_coord_vbo)

        # coords = Vec(1.0,1.0),Vec(1.0,0.0),Vec(0.0,0.0),Vec(0.0,1.0)
        coords = [frame["texcoords"][k] for k in ["tr", "br", "bl", "tl"]]
        coords = Vec(*coords)
        glBufferData(GL_ARRAY_BUFFER, coords.size, coords.buffer,
                     GL_STATIC_DRAW)

        # ... and bind it as attribute 1
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, ctypes.c_void_p(0))
        glEnableVertexAttribArray(1)
        glBindBuffer(GL_ARRAY_BUFFER, 0)

        glBindVertexArray(0)  # unbind vao

    shaderProgram = make_shader_program()
    glUseProgram(shaderProgram)

    glViewport(0, 0, 800, 600)
    projection.set_uniform(shaderProgram, 'projection')
    projection.ortho(0, 800, 0, 600, 0, 1)

    anims = {}
    for key in sheet:
        anim = Animator()
        anim.enqueue(sheet[key], loop=True)
        anims[key] = anim

    projection.scale(3, 3, 0)

    while not glfw.window_should_close(window):
        glClearColor(0.0, 0.0, 0.0, 1.0)
        glClear(GL_COLOR_BUFFER_BIT)

        x = 0
        for key in anims.keys():
            a = anims[key]

            glBindVertexArray(a["vao"])
            glBindTexture(GL_TEXTURE_2D, a["texture"])

            projection.push()
            projection.translate(x, 0, 0)

            projection.scale(a["w"], a["h"], 0)

            glDrawArrays(GL_TRIANGLE_FAN, 0, 4)

            projection.pop()
            x += a["w"]

        glfw.swap_buffers(window)
        glfw.wait_events_timeout(0.01)  # 100 fps
        listen.trigger_timers()

    glfw.terminate()
コード例 #14
0
rotation = False

if not glfw.init():
    raise RuntimeError('Could not initialize GLFW3')

if not DOUBLE_BUFFERING:
    glfw.window_hint(glfw.DOUBLEBUFFER, glfw.FALSE)

window = glfw.create_window(W_INIT, H_INIT, 'dodecahedron_06', None, None)
if not window:
    glfw.terminate()
    raise RuntimeError('Could not create an window')

glfw.set_key_callback(window, keyboard)
glfw.set_mouse_button_callback(window, mouse_button)
glfw.set_window_size_callback(window, resize)
glfw.set_window_refresh_callback(window, window_refresh)
glfw.make_context_current(window)

init()

while not glfw.window_should_close(window):
    if rotation:
        display()
        glfw.poll_events()
#        glfw.wait_events_timeout(1e-2)
    else:
        glfw.wait_events_timeout(1e-3)

glfw.terminate()
コード例 #15
0
def main():
    glfw.init()

    glfw.window_hint(glfw.RESIZABLE, False)
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 6)

    w, h = 800, 640
    globs.h = h
    globs.w = w

    globs.window = glfw.create_window(w, h, 'Polygon', None, None)
    x = glfw.make_context_current(globs.window)

    init_polygon_shader()

    # flood-fill colors
    globs.colors = [
        Vec(1.0, 0.0, 1.0, 1.0),
        Vec(1.0, 1.0, 1.0, 1.0),
        Vec(0.5, 0.5, 1.0, 1.0),
        Vec(0.0, 1.0, 1.0, 1.0)
    ]
    globs.colorIndex = 0
    # data to scale and shape the triangle array
    globs.tri = {}
    globs.tri["i_max"] = 7  # number of columns
    globs.tri["j_max"] = 5  # number of rows
    globs.tri[
        "offsetX"] = 50  # x, y (pixel) position of lower left corner of the array
    globs.tri["offsetY"] = 50
    globs.tri["scaleX"] = 50  # 1/2 the width of a triangle
    globs.tri["scaleY"] = 50  # 1/2 the height of a triangle
    # score
    globs.numberClicksThisLevel = 0

    # this stuff gets rendered by the render_loop
    globs.polygons = []
    #generate arrays
    for i in range(0, globs.tri["i_max"]):
        for j in range(0, globs.tri["j_max"]):
            isStaggered = (j % 2 == 1)
            if not isStaggered:
                p1, p2, p3 = grid_index_to_position(i, j, True)  # upward point
                globs.polygons.append(
                    Polygon(globs.colors[0 if isStaggered else 2],
                            [p1, p2, p3]))
                p1, p2, p3 = grid_index_to_position(i, j,
                                                    False)  # downward point
                globs.polygons.append(
                    Polygon(globs.colors[1 if isStaggered else 3],
                            [p1, p2, p3]))
            else:
                p1, p2, p3 = grid_index_to_position(i, j,
                                                    False)  # downward point
                globs.polygons.append(
                    Polygon(globs.colors[1 if isStaggered else 3],
                            [p1, p2, p3]))
                p1, p2, p3 = grid_index_to_position(i, j, True)  # upward point
                globs.polygons.append(
                    Polygon(globs.colors[0 if isStaggered else 2],
                            [p1, p2, p3]))

    # launch loops (order matters here)
    globs.spf = 0.015  # 60ish fps
    listen.launch(game_loop())

    render_init(w, h)
    edit_init()

    # the main loop.
    while not glfw.window_should_close(globs.window):
        glfw.wait_events_timeout(globs.spf / 10)
        listen.trigger_timers()

    glfw.terminate()