rainbowCube = bs.createRainbowCube() gpuRainbowCube = es.GPUShape().initBuffers() colorShaderProgram.setupVAO(gpuRainbowCube) gpuRainbowCube.fillBuffers(rainbowCube.vertices, rainbowCube.indices, GL_STATIC_DRAW) shapeQuad = bs.createTextureQuad(1, 1) gpuQuad = es.GPUShape().initBuffers() textureShaderProgram.setupVAO(gpuQuad) gpuQuad.fillBuffers(shapeQuad.vertices, shapeQuad.indices, GL_STATIC_DRAW) gpuQuad.texture = textureColorbuffer # <--- Here is where the magic happens! # Setting up the scene view = tr.lookAt(np.array([1.0, 1.0, 1.0]), np.array([0.0, 0.0, 0.0]), np.array([0.0, 0.0, 1.0])) projection = tr.ortho(-1, 1, -1, 1, 0.1, 100) while not glfw.window_should_close(window): # Using GLFW to check for input events glfw.poll_events() # Using the time as the theta parameter theta = glfw.get_time() # Rendering to a texture ####################### glBindFramebuffer(GL_FRAMEBUFFER, framebuffer) #glBindFramebuffer(GL_FRAMEBUFFER, 0) glEnable(GL_DEPTH_TEST) glClearColor(0.15, 0.15, 0.15, 1.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
camX = 10 * np.sin(camera_theta) camY = 10 * np.cos(camera_theta) viewPos = np.array([camX, camY, 10]) view = tr.lookAt(viewPos, np.array([0, 0, 0]), np.array([0, 0, 1])) glUniformMatrix4fv( glGetUniformLocation(pipeline.shaderProgram, "view"), 1, GL_TRUE, view) # Setting up the projection transform if controller.projection == PROJECTION_ORTHOGRAPHIC: projection = tr.ortho(-8, 8, -8, 8, 0.1, 100) elif controller.projection == PROJECTION_FRUSTUM: projection = tr.frustum(-5, 5, -5, 5, 9, 100) elif controller.projection == PROJECTION_PERSPECTIVE: projection = tr.perspective(60, float(width) / float(height), 0.1, 100) else: raise Exception() glUniformMatrix4fv( glGetUniformLocation(pipeline.shaderProgram, "projection"), 1, GL_TRUE, projection)