示例#1
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
示例#2
0
    s1 = (0.5, 0, 0)
    s2 = (-0.5, 0, 0)
    s3 = (-0.5, 0.55, 0)
    s4 = (0.5, 0.55, 0)
    gpuTexturePlane = es.to_gpu_shape(
        bs.create4_vertex_texture('example_data/boo.png', s1, s2, s3, s4),
        GL_REPEAT, GL_LINEAR)
    obj_planeB = AdvancedGPUShape(gpuTexturePlane, shader=textureShaderProgram)
    obj_planeB.rotation_z(np.pi)
    obj_planeB.scale(1, 2, 1)

    # Create camera target
    obj_camTarget = AdvancedGPUShape(es.to_gpu_shape(
        bs.create_color_cube(1, 0, 0.5)),
                                     shader=colorShaderProgram)
    obj_camTarget.uniform_scale(0.05)

    # Main loop
    while not glfw.window_should_close(window):

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

        # Filling or not the shapes depending on the controller state
        if controller.fillPolygon:
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        else:
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

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