Esempio n. 1
0
    # Creating shapes on GPU memory
    gpuBoo = es.to_gpu_shape(
        shapes.create_texture_quad('example_data/boo.png'), GL_REPEAT,
        GL_NEAREST)
    gpuQuestionBox = es.to_gpu_shape(
        shapes.create_texture_quad('example_data/question_box.png', 10, 1),
        GL_REPEAT, GL_NEAREST)

    # Create objets
    obj_boo = AdvancedGPUShape(gpuBoo, shader=pipeline)
    obj_question = AdvancedGPUShape(gpuQuestionBox, shader=pipeline)

    # Apply object transform
    obj_question.scale(sx=-2, sy=0.2)
    obj_question.translate(ty=-0.8)

    # Mainloop
    while not glfw.window_should_close(window):

        # Using GLFW to check for input events
        glfw.poll_events()

        # OpenGL polygon mode
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT)

        theta = glfw.get_time()
        tx = 0.7 * np.sin(0.5 * theta)
Esempio n. 2
0
    redQuad = shapes.create_color_quad(1, 0, 0)
    yellowQuad = shapes.create_color_quad(1, 1, 0)
    greenQuad = shapes.create_color_quad(0, 1, 0)

    # Create objects
    obj_quad_blue = AdvancedGPUShape(es.to_gpu_shape(blueQuad),
                                     shader=basicShader)
    obj_quad_red = AdvancedGPUShape(es.to_gpu_shape(redQuad),
                                    shader=basicShader)
    obj_quad_yellow = AdvancedGPUShape(es.to_gpu_shape(yellowQuad),
                                       shader=basicShader)
    obj_quad_green = AdvancedGPUShape(es.to_gpu_shape(greenQuad),
                                      shader=basicShader)

    # Apply permanent transforms
    obj_quad_red.translate(tx=0.5)
    obj_quad_red.uniform_scale(0.5)

    # Polyfon fill mode
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

    # Get time
    t0 = glfw.get_time()

    # Mainloop
    while not glfw.window_should_close(window):

        # Getting the time difference from the previous iteration
        t1 = glfw.get_time()
        dt = t1 - t0
        t0 = t1