Example #1
0
def process(dt):

    # Poll for and process events
    glfw.glfwPollEvents()

    for window in __windows__:
        window.activate()

        window.imguiRenderer.process_inputs()

        # Dispatch the main draw event
        window.dispatch_event('on_draw', dt)

        # Dispatch the idle event
        window.dispatch_event('on_idle', dt)

        imgui_draw_data = imgui.get_draw_data()
        if imgui_draw_data is not None:
            window.imguiRenderer.render(imgui_draw_data)

        # Swap buffers
        window.swap()

    for window in __windows_to_remove__:
        window.destroy()
        __windows_to_remove__.remove(window)

    return len(__windows__)
Example #2
0
def render(window):
    global program, vao, indices, cube_positions

    GLFW.glfwPollEvents()

    GL.glViewport(0, 0, window.width, window.height)

    cameraPos = GLM.vec3(0.0, 0.0, 3.0)
    cameraTarget = GLM.vec3(0.0, 0.0, 0.0)
    cameraDirection = GLM.normalize(cameraPos - cameraTarget)
    up = GLM.vec3(0.0, 1.0, 0.0)
    cameraRight = GLM.normalize(GLM.cross(up, cameraDirection))
    cameraUp = GLM.cross(cameraDirection, cameraRight)

    view = GLM.lookAt(GLM.vec3(0.0, 0.0, 3.0), GLM.vec3(0.0, 0.0, 0.0),
                      GLM.vec3(0.0, 1.0, 0.0))

    GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    program.useProgram()

    view = GLM.mat4(1.0)
    view = GLM.translate(view, GLM.vec3(0.0, 0.0, -3.0))

    projection = GLM.perspective(GLM.radians(45.0),
                                 window.width / window.height, 0.1, 100.0)

    program.setMat4("projection", projection)

    for w in range(10):
        radius = 10.0
        camX = MATH.sin(GLFW.glfwGetTime()) * radius
        camZ = MATH.cos(GLFW.glfwGetTime()) * radius
        view = GLM.lookAt(GLM.vec3(camX, 0.0, camZ), GLM.vec3(0.0, 0.0, 0.0),
                          GLM.vec3(0.0, 1.0, 0.0))

        model = GLM.mat4(1.0)
        model = GLM.translate(model, cube_positions[w])
        model = GLM.rotate(model, GLM.radians(20.0 * w),
                           GLM.vec3(1.0, 0.3, 0.5))
        program.setMat4("model", model)
        program.setMat4("view", view)
        vao.useVAO(program)
        GL.glDrawArrays(GL.GL_TRIANGLES, 0, 36)

    vao.unBind()

    GLFW.glfwSwapBuffers(window.getWindow())
Example #3
0
def process(dt):

    # Poll for and process events
    glfw.glfwPollEvents()

    for window in __windows__:
        # Make window active
        window.activate()

        # Dispatch the main draw event
        window.dispatch_event('on_draw', dt)

        # Dispatch the idle event
        window.dispatch_event('on_idle', dt)

        # Swap buffers
        window.swap()

    for window in __windows_to_remove__:
        window.destroy()
        __windows_to_remove__.remove(window)

    return len(__windows__)