# Clearing the screen in both, color and depth glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) projection = tr.perspective(30, float(width)/float(height),0.1, 100) view = tr.lookAt( np.array([5,5,2]), np.array([0,0,0]), np.array([0,0,1]) ) theta = glfw.get_time() axis = np.array([1,-1,1]) axis = axis / np.linalg.norm(axis) model = tr.rotationA(theta, axis) # Drawing axes and cube in a 3D world glUseProgram(mvpPipeline.shaderProgram) glUniformMatrix4fv(glGetUniformLocation(mvpPipeline.shaderProgram, "projection"), 1, GL_TRUE, projection) glUniformMatrix4fv(glGetUniformLocation(mvpPipeline.shaderProgram, "view"), 1, GL_TRUE, view) glUniformMatrix4fv(glGetUniformLocation(mvpPipeline.shaderProgram, "model"), 1, GL_TRUE, tr.identity()) mvpPipeline.drawCall(gpuAxis, GL_LINES) glUniformMatrix4fv(glGetUniformLocation(mvpPipeline.shaderProgram, "model"), 1, GL_TRUE, model) mvpPipeline.drawCall(gpuRainbowCube) theta = glfw.get_time() tx = 0.7 * np.sin(0.5 * theta) ty = 0.2 * np.sin(5 * theta)
camY = 3 * np.cos(camera_theta) viewPos = np.array([camX,camY,2]) view = tr.lookAt( viewPos, np.array([0,0,0]), np.array([0,0,1]) ) rotation_theta = glfw.get_time() axis = np.array([1,-1,1]) #axis = np.array([0,0,1]) axis = axis / np.linalg.norm(axis) model = tr.rotationA(rotation_theta, axis) model = tr.identity() # Clearing the screen in both, color and depth glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # 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) # The axis is drawn without lighting effects if controller.showAxis: glUseProgram(mvpPipeline.shaderProgram) glUniformMatrix4fv(glGetUniformLocation(mvpPipeline.shaderProgram, "projection"), 1, GL_TRUE, projection)