void Display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); static CStopWatch timer; GLfloat yRot = timer.GetElapsedSeconds()*20.0f; GLfloat vWhite[] = {1.0f,1.0f,1.0f,1.0f}; GLfloat vLightPos[] = {0.0f,2.0f,2.0f}; GLfloat vAmbient[] = {0.3f,0.3f,1.0f,1.0f}; modelViewMatrix.PushMatrix(); //move to camera view M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(yRot,1.0,1.0,1.0); glBindTexture(GL_TEXTURE_2D,fbxTexture); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, transformPipeLine.GetModelViewMatrix(), transformPipeLine.GetProjectionMatrix(), vLightPos, vWhite, 0); //*/shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeLine.GetModelViewProjectionMatrix(),vWhite); modelViewMatrix.Scale(0.05,0.05,0.05); rTest.DrawReader(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable( GL_DEPTH_TEST ) ; glUseProgram(shader); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); float angle = timer.GetElapsedSeconds(); M3DVector3f eye = {cos(angle)*4.0f,sin(angle)*4.0,sin(angle)*4.0f}; M3DVector3f at = {0,0,0}; M3DVector3f up = {0.0f,0.0f,1.0f}; GLFrame cameraFrame; LookAt(cameraFrame, eye, at, up); cameraFrame.GetCameraMatrix(cameraMatrix); m3dMatrixMultiply44(matrix, viewFrustum.GetProjectionMatrix(), cameraMatrix); M3DMatrix44f tMatrix; m3dTranslationMatrix44(tMatrix, 0, 0, 0); m3dMatrixMultiply44(matrix, tMatrix, matrix); if((sin(angle) < 0 && sin(angle-0.003) > 0) || (sin(angle) > 0 && sin(angle-0.003) < 0)) { debugMatrix44(matrix); } glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrix); // drawGrid(0.1); drawPyramid(); glutSwapBuffers(); glutPostRedisplay(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); modelViewMatrix.MultMatrix(mRotation); glUseProgram(myShader); //mWcgCube.Draw(locMVP, modelViewMatrix, transformPipeline); mWcgCube.DrawRotate(0, 30, locMVP, modelViewMatrix, transformPipeline); //glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); //cubeBatch.Draw(); //sphereBatch.Draw(); //triangleBatch.Draw(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); updateCamera(); GLGeometryTransform geometryPipeline; GLMatrixStack modelViewStack; GLMatrixStack projectionStack; geometryPipeline.SetMatrixStacks(modelViewStack, projectionStack); projectionStack.LoadMatrix(frustum.GetProjectionMatrix()); M3DMatrix44f cameraMatrix; frame.GetCameraMatrix(cameraMatrix); modelViewStack.PushMatrix(cameraMatrix); glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, geometryPipeline.GetProjectionMatrix()); glUniformMatrix4fv(modelViewMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix()); glUniformMatrix4fv(normalMatrixLocation, 1, GL_FALSE, geometryPipeline.GetNormalMatrix()); modelViewStack.PushMatrix(); modelViewStack.Translate(0.0, 1.0, 0.0); glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, geometryPipeline.GetProjectionMatrix()); glUniformMatrix4fv(modelViewMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix()); glUniformMatrix4fv(normalMatrixLocation, 1, GL_FALSE, geometryPipeline.GetNormalMatrix()); glDrawElements(GL_TRIANGLES, 3 * n_faces, GL_UNSIGNED_INT, 0); modelViewStack.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void RenderScene() { static GLfloat vSunColor[] = { 1.0f, 0.0f, 0.0f, 1.0f }; static GLfloat vEarthColor[] = { 0.0f, 0.0f, 1.0f, 1.0f }; static GLfloat vMoonColor[] = { 1.0f, 1.0f, 0.0f, 1.0f }; static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f}; static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.PushMatrix(mCamera); M3DVector4f vLightPos = { 0.0f, 10.0f, 5.0f, 1.0f }; M3DVector4f vLightEyePos; m3dTransformVector4(vLightEyePos, vLightPos, mCamera); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor); floorBatch.Draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); modelViewMatrix.Translate(0.0f, 0.0f, -3.5f); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vSunColor); sunSphereBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.8f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vEarthColor); earthSphereBatch.Draw(); modelViewMatrix.Rotate(yRot * -4.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.4f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vMoonColor); moonSphereBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void GetViewProjectionMatrix(float *viewProjectionMatrix) { M3DMatrix44f viewMatrix; cameraFrame.GetCameraMatrix(viewMatrix); m3dMatrixMultiply44(viewProjectionMatrix, viewFrustum.GetProjectionMatrix(), viewMatrix); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { static GLfloat vLightPos [] = { 1.0f, 1.0f, 0.0f }; static GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f }; // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); M3DMatrix44f mObjectFrame; objectFrame.GetMatrix(mObjectFrame); modelViewMatrix.MultMatrix(mObjectFrame); glBindTexture(GL_TEXTURE_2D, textureID); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vLightPos, vWhite, 0); pyramidBatch.Draw(); modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); M3DMatrix44f mObjectFrame; objectFrame.GetMatrix(mObjectFrame); modelViewMatrix.MultMatrix(mObjectFrame); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack); switch(nStep) { case 0: glPointSize(4.0f); pointBatch.Draw(); glPointSize(1.0f); break; case 1: glLineWidth(2.0f); lineBatch.Draw(); glLineWidth(1.0f); break; case 2: glLineWidth(2.0f); lineStripBatch.Draw(); glLineWidth(1.0f); break; case 3: glLineWidth(2.0f); lineLoopBatch.Draw(); glLineWidth(1.0f); break; case 4: DrawWireFramedBatch(&triangleBatch); break; case 5: DrawWireFramedBatch(&triangleStripBatch); break; case 6: DrawWireFramedBatch(&triangleFanBatch); break; } modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); }
// Called to draw scene void RenderScene(void) { // Clear the window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); M3DMatrix44f mCamera; M3DMatrix44f mCameraRotOnly; M3DMatrix44f mInverseCamera; viewFrame.GetCameraMatrix(mCamera, false); viewFrame.GetCameraMatrix(mCameraRotOnly, true); m3dInvertMatrix44(mInverseCamera, mCameraRotOnly); modelViewMatrix.PushMatrix(); // Draw the sphere modelViewMatrix.MultMatrix(mCamera); glUseProgram(reflectionShader); glUniformMatrix4fv(locMVPReflect, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMVReflect, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(locNormalReflect, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); glUniformMatrix4fv(locInvertedCamera, 1, GL_FALSE, mInverseCamera); glUniform1i(locCubeMap, 0); glUniform1i(locTarnishMap, 1); glEnable(GL_CULL_FACE); sphereBatch.Draw(); glDisable(GL_CULL_FACE); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.MultMatrix(mCameraRotOnly); glUseProgram(skyBoxShader); glUniformMatrix4fv(locMVPSkyBox, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); cubeBatch.Draw(); modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); }
void DrawScene() { modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); // Transform the light position into eye coordinates M3DVector4f vLightPos = { LIGHT_POSITION[0], LIGHT_POSITION[1], LIGHT_POSITION[2], LIGHT_POSITION[3] }; M3DVector4f vLightEyePos; m3dTransformVector4(vLightEyePos, vLightPos, mCamera); /* ------------ */ /* FERRIS WHEEL */ modelViewMatrix.PushMatrix(); /* Position the ferris wheel appropriately. */ modelViewMatrix.Translate(FERRIS_WHEEL_POSITION[0], FERRIS_WHEEL_POSITION[1], FERRIS_WHEEL_POSITION[2]); /* Apply the Translation to this entire block of objects */ modelViewMatrix.PushMatrix(); //theWheel.Draw(modelViewMatrix, shaderManager, transformPipeline, vLightEyePos, capTexture, wheelTexture, wallTexture, carTexture, currentTextureIndex); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); /* -------------- */ /* ROLLER COASTER */ modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0, 0.0, -10.0); //track.Draw(modelViewMatrix, shaderManager, transformPipeline, vLightEyePos); modelViewMatrix.PopMatrix(); /* -------- */ /* CAROUSEL */ modelViewMatrix.PushMatrix(); //modelViewMatrix.Translate(3.0f, 0.0f, -3.0f); modelViewMatrix.Translate(0.0f, 0.0f, -3.0f); //carousel.Draw(modelViewMatrix, shaderManager, transformPipeline, vLightEyePos); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.0f, -2.0f); //unicorn.Draw(modelViewMatrix, shaderManager, transformPipeline, vLightEyePos); //ostrich.Draw(modelViewMatrix, shaderManager, transformPipeline, vLightEyePos); turtle.Draw(modelViewMatrix, shaderManager, transformPipeline, vLightEyePos); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); }
void render_scene(void) { float angle = timer.GetElapsedSeconds() * 3.14f / 10.0f; location[0] = -8.0f * cos(angle / 2.0f); location[1] = -8.0f * sin(angle / 2.0f); location[2] = 5.0f; light_0.position[0] = 10.0f * cos(-angle); light_0.position[1] = 10.0f * sin(-angle); light_0.position[2] = 3.0f; look_at(camera_frame, location, target, up_dir); camera_frame.GetCameraMatrix(camera_matrix); p_stack.LoadMatrix(view_frustum.GetProjectionMatrix()); mv_stack.LoadMatrix(camera_matrix); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //-- glUseProgram(shader_color); mv_stack.PushMatrix(); mv_stack.Translate(light_0.position[0], light_0.position[1], light_0.position[2]); mv_stack.Scale(0.25f, 0.25f, 0.25f); glUniformMatrix4fv(mvp_matrix_location_shader_color, 1, GL_FALSE, geometry_pipeline.GetModelViewProjectionMatrix()); draw_light(); mv_stack.PopMatrix(); //-- glUseProgram(shader_light); glUniformMatrix3fv(normal_matrix_location, 1, GL_FALSE, geometry_pipeline.GetNormalMatrix()); glUniformMatrix4fv(v_matrix_location, 1, GL_FALSE, camera_matrix); glUniform3fv(intensity_ambient_component_location, 1, intensity_ambient_component); glUniform3fv(light_0_position_location, 1, light_0.position); glUniform3fv(light_0_intensity_diffuse_location, 1, light_0.intensity_diffuse); glUniform3fv(light_0_intensity_specular_location, 1, light_0.intensity_specular); glUniform3fv(light_0_attenuation_location, 1, light_0.attenuation); glUniform1f(material_0_ka_location, material_0.ka); glUniform1f(material_0_kd_location, material_0.kd); glUniform1f(material_0_ks_location, material_0.ks); glUniform1f(material_0_alpha_location, material_0.alpha); //-- for(int i = -10; i <= 10; i += 3) for(int j = -10; j <= 10; j += 3) { mv_stack.PushMatrix(); mv_stack.Translate(i, j, 0.0f); glUniformMatrix4fv(mvp_matrix_location, 1, GL_FALSE, geometry_pipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(mv_matrix_location, 1, GL_FALSE, geometry_pipeline.GetModelViewMatrix()); glDrawElements(GL_TRIANGLES, faces.size(), GL_UNSIGNED_INT, 0); mv_stack.PopMatrix(); } //-- glUseProgram(0); glutSwapBuffers(); glutPostRedisplay(); }
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); // Draw the world upside down modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); // Flips the Y Axis modelViewMatrix.Translate(0.0f, 0.8f, 0.0f); // Scootch the world down a bit... glFrontFace(GL_CW); DrawSongAndDance(yRot); glFrontFace(GL_CCW); modelViewMatrix.PopMatrix(); // Draw the solid ground glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, uiTextures[0]); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); static GLfloat vFloorColor[] = { 1.0f, 1.0f, 1.0f, 0.75f}; shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor, 0); floorBatch.Draw(); glDisable(GL_BLEND); DrawSongAndDance(yRot); modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Do it again glutPostRedisplay(); }
void RenderScene(void) { M3DMatrix44f CameraMatrix; M3DMatrix44f ViewProjectionMatrix; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); cameraFrame.GetCameraMatrix(CameraMatrix); frame.GetMatrix(ProjectionMatrix); m3dMatrixMultiply44(ViewProjectionMatrix,ProjectionMatrix,CameraMatrix); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,ViewProjectionMatrix); glBegin(GL_QUADS); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.5, 0.5, 0.5); glVertex3f(-1.0f, 1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 0.0f); glEnd(); glBegin(GL_TRIANGLES); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0, 1.0, 0.0); glVertex3f(0.0, 0.0, 2.0); glVertex3f(-1.0, 1.0, 0.0); glVertex3f(-1.0, -1.0, 0.0); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 2.0); glVertex3f(-1.0, -1.0, 0.0); glVertex3f(1.0, -1.0, 0.0); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.0, 1.0, 0.0); glVertex3f(0.0, 0.0, 2.0); glVertex3f(1.0, -1.0, 0.0); glVertex3f(1.0, 1.0, 0.0); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 2.0); glVertex3f(1.0, 1.0, 0.0); glVertex3f(-1.0, 1.0, 0.0); glEnd(); glutSwapBuffers(); //cameraFrame.RotateLocalZ(0.01); //Obrót kamery glutPostRedisplay(); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); // Reflection step... draw cube upside down, the floor // blended on top of it if(nStep == 5) { glDisable(GL_CULL_FACE); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); modelViewMatrix.Translate(0.0f, 2.0f, 0.0f); modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f); RenderBlock(); modelViewMatrix.PopMatrix(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderFloor(); glDisable(GL_BLEND); } modelViewMatrix.PushMatrix(); // Draw normally modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f); RenderBlock(); modelViewMatrix.PopMatrix(); // If not the reflection pass, draw floor last if(nStep != 5) RenderFloor(); modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); }
void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); CStopWatch timer; float angle = timer.GetElapsedSeconds()*3.14f; M3DVector3f mAt={0,0,0}; M3DVector3f mUp={0,0,1}; M3DVector3f mEye; mEye[0]=6.8f*cos(angle); mEye[1]=6.0f*sin(angle); mEye[2]=5.0f; LookAt(mFrame,mEye,mAt,mUp); mFrame.GetCameraMatrix(mCameraMatrix); matrixStack.LoadMatrix(mFrustrum.GetProjectionMatrix()); matrixStack.MultMatrix(mCameraMatrix); glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, matrixStack.GetMatrix()); drawGrid(); matrixStack.Translate(1.0f,7.0f,0.0f); matrixStack.Rotate(30.0f,0.0,0.0,1.0); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix()); drawPyramid(); matrixStack.PopMatrix(); matrixStack.Translate(-7.0f,0.0f,0.0f); matrixStack.Scale(2.0f, 2.0f, 2.0f); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix()); drawPyramid(); matrixStack.PopMatrix(); // Perform the buffer swap to display back buffer glutSwapBuffers(); glutPostRedisplay(); }
void Display() { // Clear the color and depth buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Save the current modelview matrix (the identity matrix) modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); if (reflecting) { // Draw the "reflection" of the scene upside down modelViewMatrix.PushMatrix(); // Flip the y-axis last. modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); // The scene is essentially in a pit, bo elevate it an equal distance from the // x-z plane to ensure that its reflection will appear to be below the ground. modelViewMatrix.Translate(0.0f, -2.0f * FLOOR_HEIGHT, 0.0f); // Reverse the orientation of all polygonsm in the scene so the orientation of // their reflections will produce the same lighting as the above-ground scene. glFrontFace(GL_CW); DrawScene(); glFrontFace(GL_CCW); modelViewMatrix.PopMatrix(); } DrawGround(); DrawScene(); modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Tell GLUT to do it again glutPostRedisplay(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glFrontFace(GL_CW); glUseProgram(shader); M3DVector3f at={0.0f, 0.0f, 0.0f}; M3DVector3f up={0.0f, 0.0f, 1.0f}; M3DVector3f eye; float angle = timer.GetElapsedSeconds()*3.14159f/8; eye[0]= 6.8f * cos(angle); eye[1]= 6.0f * sin(angle); eye[2]= 25.0f; LookAt(cameraFrame,eye,at,up); projection.LoadMatrix(viewFrustum.GetProjectionMatrix()); modelView.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); szachownica(); modelView.Translate(0.0f, 0.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujPiramidke(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(5.0f, 0.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujPiramidke(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-5.0f, 0.0f, 0.0f); modelView.Scale(2.0f, 2.0f, 2.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujPiramidke(); modelView.PopMatrix(); modelView.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void renderScene(void) { float angle = timer.GetElapsedSeconds() * 3.14f; location[0] = 6.0f * cos(angle); location[1] = 6.0f * sin(angle); location[2] = 5.0f; lookAt(cameraFrame, location, target, upDir); cameraFrame.GetCameraMatrix(cameraMatrix); m3dMatrixMultiply44(MVPMatrix, viewFrustum.GetProjectionMatrix(), cameraMatrix); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, MVPMatrix); glBegin(GL_QUADS); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0f, 0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 0.0f); glEnd(); glBegin(GL_TRIANGLES); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0f, 1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); //-- glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0f, 1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); //-- glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.0f, 1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); glVertex3f(-1.0f, 1.0f, 0.0f); //-- glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.0f, 0.0f, 1.0f); glVertex3f(1.0f, -1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); glVertex3f(-1.0f, -1.0f, 0.0f); glEnd(); glutSwapBuffers(); glutPostRedisplay(); }
void PassGouraudDataToShader() { glUniformMatrix4fv(mvpMatrixLocation, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(mvMatrixLocation, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); M3DMatrix44f viewMatrix; cameraFrame.GetCameraMatrix(viewMatrix); M3DVector3f lightPositionInEyeSpace; m3dTransformVector3(lightPositionInEyeSpace, lightPosition, viewMatrix); glUniform3fv(shaderLightPositionLocation, 1, lightPositionInEyeSpace); glUniform3fv(shaderLightColorLocation, 1, lightColor); glUniform1f(shaderLightAngleLocation, lightAngle); glUniform1f(shaderLightAttenuation0Location, lightAttenuation0); glUniform1f(shaderLightAttenuation1Location, lightAttenuation1); glUniform1f(shaderLightAttenuation2Location, lightAttenuation2); glUniform3fv(materialAmbientColorLocation, 1, materialAmbientColor); glUniform3fv(materialDiffuseColorLocation, 1, materialDiffuseColor); glUniform3fv(materialSpecularColorLocation, 1, materialSpecularColor); glUniform1f(materialSpecularExponentLocation, materialSpecularExponent); }
/** * @brief Called to draw scene */ void RenderScene() { // Color values static GLfloat vSunColor[] = { 1.0f, 0.0f, 0.0f, 1.0f }; static GLfloat vEarthColor[] = { 0.0f, 0.0f, 1.0f, 1.0f }; static GLfloat vMoonColor[] = { 1.0f, 1.0f, 0.0f, 1.0f }; static GLfloat vFloorColor[] = { 0.0f, 0.64f, 0.0f, 1.0f}; // Time Based animation static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; // Clear the color and depth buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Save the current modelview matrix (the identity matrix) modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.PushMatrix(mCamera); // Transform the light position into eye coordinates M3DVector4f vLightPos = { 0.0f, 10.0f, 5.0f, 1.0f }; M3DVector4f vLightEyePos; m3dTransformVector4(vLightEyePos, vLightPos, mCamera); // Draw the floor shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor); floorBatch.Draw(); // Draw the spinning Sun modelViewMatrix.Translate(0.0f, 0.0f, -3.5f); // Save the Translation modelViewMatrix.PushMatrix(); // Apply a rotation and draw the Sun modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vLightEyePos, vSunColor); sunSphereBatch.Draw(); modelViewMatrix.PopMatrix(); // "Erase" the Rotation from before // Apply another rotation, followed by a translation, then draw the Earth modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.8f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vLightEyePos, vEarthColor); earthSphereBatch.Draw(); // Apply another rotation, followed by a translation, then draw the Moon modelViewMatrix.Rotate(yRot * -4.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.4f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vLightEyePos, vMoonColor); moonSphereBatch.Draw(); // Restore the previous modleview matrix (the identity matrix) modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Tell GLUT to do it again glutPostRedisplay(); }
void RenderScene(void) { static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); modelViewMatrix.PushMatrix(); { //反向 modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); //因为是反向,所以正数是向下 modelViewMatrix.Translate(0.0f, 0.8f, 0.0f); // Scootch the world down a bit... //三维中其中一维反向之后,缠绕方向也会呈相反,所以重新定义缠绕正方向为顺时针方向; glFrontFace(GL_CW); DrawSongAndDance(yRot); glFrontFace(GL_CCW); } modelViewMatrix.PopMatrix(); // Draw the solid ground glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, uiTextures[0]); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); static GLfloat vFloorColor[] = { 1.0f, 1.0f, 1.0f, 0.75f }; shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeLine.GetModelViewProjectionMatrix(), vFloorColor, 0); floorBatch.Draw(); glDisable(GL_BLEND); DrawSongAndDance(yRot); modelViewMatrix.PopMatrix(); // Render the overlay // Creating this matrix really doesn't need to be done every frame. I'll leave it here // so all the pertenant code is together M3DMatrix44f mScreenSpace; m3dMakeOrthographicMatrix(mScreenSpace, 0.0f, 800.0f, 0.0f, 600.0f, -1.0f, 1.0f); // Turn blending on, and depth testing off glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glUseProgram(sphereWolrdShader); glUniform1i(locTexture, 0); glUniformMatrix4fv(locMVP, 1, GL_FALSE, mScreenSpace); glBindTexture(GL_TEXTURE_RECTANGLE, uiTextures[3]); logoBatch.Draw(); // Restore no blending and depth test glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); // Do the buffer Swap glutSwapBuffers(); // Do it again glutPostRedisplay(); }
void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //glFrontFace(GL_CW); glUseProgram(shader); float angle=timer.GetElapsedSeconds()*M_PI/5; M3DVector3f at={1,0,0}; M3DVector3f up={0,0,1}; M3DVector3f eye; eye[0]=6.0f*cos(angle); eye[1]=6.0f*sin(angle); eye[2]=kz; LookAt(cameraFrame,eye,at,up); geometryPipeline.SetMatrixStacks(modelView,projection); //swiatlo M3DVector3f ambientLight = {1.0f, 1.0f, 1.0f}; M3DVector3f position = {2.0f, 2.0f, 5.0f}; M3DVector3f color = {1.0f, 1.0f, 1.0f}; float l_angle = 90.0f; float attenuation0 = 0.5f; float attenuation1 = 0.02f; float attenuation2 = 0.05f; M3DVector3f ambientColor = {0.1f, 0.1, 0.1}; M3DVector3f diffuseColor = {0.184f, 0.598f, 0.75f}; M3DVector3f specularColor = {1.0f, 1.0f, 1.0f}; float specularExponent = 9; float ico_vertices[3 * 12] = { 0., 0., -0.9510565162951536, 0., 0., 0.9510565162951536, -0.85065080835204, 0., -0.42532540417601994, 0.85065080835204, 0., 0.42532540417601994, 0.6881909602355868, -0.5, -0.42532540417601994, 0.6881909602355868, 0.5, -0.42532540417601994, -0.6881909602355868, -0.5, 0.42532540417601994, -0.6881909602355868, 0.5, 0.42532540417601994, -0.2628655560595668, -0.8090169943749475, -0.42532540417601994, -0.2628655560595668, 0.8090169943749475, -0.42532540417601994, 0.2628655560595668, -0.8090169943749475, 0.42532540417601994, 0.2628655560595668, 0.8090169943749475, 0.42532540417601994}; int ico_faces[3*20] = { 1 , 11 , 7 , 1 , 7 , 6 , 1 , 6 , 10 , 1 , 10 , 3 , 1 , 3 , 11 , 4 , 8 , 0 , 5 , 4 , 0 , 9 , 5 , 0 , 2 , 9 , 0 , 8 , 2 , 0 , 11 , 9 , 7 , 7 , 2 , 6 , 6 , 8 , 10 , 10 , 4 , 3 , 3 , 5 , 11 , 4 , 10 , 8 , 5 , 3 , 4 , 9 , 11 , 5 , 2 , 7 , 9 , 8 , 6 , 2 }; projection.LoadMatrix(viewFrustum.GetProjectionMatrix()); cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); glPolygonOffset(1.0f, 1.0f); drawGrid(); glEnable(GL_POLYGON_OFFSET_FILL); drawGrid(); glDisable(GL_POLYGON_OFFSET_FILL); modelView.Translate(-2.0f,-2.0f,2.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); drawTriangles(20, ico_vertices, ico_faces); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(2.0,2.0,2.0); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); drawSmoothTriangles(20, ico_vertices, ico_faces); modelView.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
/////////////////////////////////////////////////////////////////////////////// // Render a frame. The owning framework is responsible for buffer swaps, // flushes, etc. void RenderScene(void) { static CStopWatch animationTimer; static float totalTime = 6; // To go back and forth static float halfTotalTime = totalTime/2; float seconds = animationTimer.GetElapsedSeconds() * speedFactor; float xPos = 0; // Calculate the next postion of the moving object // First perform a mod-like operation on the time as a float while(seconds > totalTime) seconds -= totalTime; // Move object position, if it's gone half way across // start bringing it back if(seconds < halfTotalTime) xPos = seconds -halfTotalTime*0.5f; else xPos = totalTime - seconds -halfTotalTime*0.5f; // First draw world to screen modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); // Marble glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vWhite, 0); floorBatch.Draw(); DrawWorld(0.0f, xPos); modelViewMatrix.PopMatrix(); if(bUsePBOPath) { #ifndef OPENGL_ES // First bind the PBO as the pack buffer, then read the pixels directly to the PBO glBindBuffer(GL_PIXEL_PACK_BUFFER, pixBuffObjs[0]); glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, NULL); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); // Next bind the PBO as the unpack buffer, then push the pixels straight into the texture glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixBuffObjs[0]); // Setup texture unit for new blur, this gets imcremented every frame glActiveTexture(GL_TEXTURE0+GetBlurTarget0() ); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); #endif } else { // Grab the screen pixels and copy into local memory glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, pixelData); // Push pixels from client memory into texture // Setup texture unit for new blur, this gets imcremented every frame glActiveTexture(GL_TEXTURE0+GetBlurTarget0() ); #ifndef OPENGL_ES glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pixelData); #else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pixelData); #endif } // Draw full screen quad with blur shader and all blur textures projectionMatrix.PushMatrix(); projectionMatrix.LoadIdentity(); projectionMatrix.LoadMatrix(orthoMatrix); modelViewMatrix.PushMatrix(); modelViewMatrix.LoadIdentity(); glDisable(GL_DEPTH_TEST); SetupBlurProg(); screenQuad.Draw(); glEnable(GL_DEPTH_TEST); modelViewMatrix.PopMatrix(); projectionMatrix.PopMatrix(); // Move to the next blur texture for the next frame AdvanceBlurTaget(); // Do the buffer Swap glutSwapBuffers(); // Do it again glutPostRedisplay(); UpdateFrameCount(); }
void RenderScene(void) { load_vertices("geode_vertices.dat", vertices); load_faces("geode_faces.dat", faces); glGenBuffers(1, &vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), &vertices[0], GL_STATIC_DRAW); glVertexAttribPointer(GLT_ATTRIBUTE_VERTEX, 4 ,GL_FLOAT,GL_FALSE, sizeof(float) * 7, (const GLvoid *)0); glVertexAttribPointer(GLT_ATTRIBUTE_NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 7, (const GLvoid *)(4*sizeof(float)) ); glEnableVertexAttribArray(GLT_ATTRIBUTE_VERTEX); glEnableVertexAttribArray(GLT_ATTRIBUTE_NORMAL); //--- glGenBuffers(1, &faces_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, faces_buffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, faces.size() * sizeof(GLuint), &faces[0], GL_STATIC_DRAW); //--- // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Obracanie widoku float angle =timer.GetElapsedSeconds()*PI/4; posVector[0] = -8.0f * cos(angle / 2.0f); posVector[1] = -8.0f * sin(angle / 2.0f); posVector[2] = 5.0f; swiatlo0.position[0] = 8.0f * cos(-angle); swiatlo0.position[1] = 15.0f * sin(-angle); swiatlo0.position[2] = 5.0f; LookAt(viewFrame, posVector, atVector, upVector); geometryPipeline.SetMatrixStacks(modelView,projection); projection.LoadMatrix(viewFrustum.GetProjectionMatrix()); modelView.PushMatrix(); M3DMatrix44f mCamera; viewFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); //glUseProgram(shader); modelView.Translate(swiatlo0.position[0], swiatlo0.position[1], swiatlo0.position[2]); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); modelView.PopMatrix(); //mno¿enie macierzy //modelView.MultMatrix(mCamera); // modelView.PushMatrix(); //m3dMatrixMultiply44(mModelViewProjection, viewFrustum.GetProjectionMatrix(), mCamera); // wrzucanie do shadera glUniformMatrix3fv(NMatrixLocation, 1, GL_FALSE, geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(VMmatrixLocation, 1, GL_FALSE, mCamera); glUniform3fv(iambient_component_location, 1, iambient_component); glUniform3fv(swiatlo0_location, 1, swiatlo0.position); glUniform3fv(swiatlo0_idiffuse_location, 1, swiatlo0.idiffuse); glUniform3fv(swiatlo0_ispecular_location, 1, swiatlo0.ispecular); glUniform3fv(swiatlo0_attenuation_location, 1, swiatlo0.attenuation); glUniform1f(material0_ka_location, material0.ka); glUniform1f(material0_kd_location, material0.kd); glUniform1f(material0_ks_location, material0.ks); glUniform1f(material0_alpha_location, material0.alpha); //-- glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix()); //DrawPramid(0.5,0.0,1.0); drawTriangles(20,ico_vertices,ico_faces); // rysowanie siatki -------------------------------------------------------------------------- glEnable(GL_CULL_FACE); glPolygonOffset(1.0f, 1.0f); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0, 1.0, 1.0); glEnable(GL_POLYGON_OFFSET_FILL); glBegin(GL_QUADS); glVertex3f(10, -10.0f, 0.0f); glVertex3f(-10, -10.0f, 0.0f); glVertex3f(-10, 10.0f, 0.0f); glVertex3f(10, 10.0f, 0.0f); glEnd(); glDisable(GL_POLYGON_OFFSET_FILL); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 1.0, 1.0, 1.0); for(int i=-10;i<=10;i++){ glBegin(GL_LINES); glVertex3f((float)i, -10.0f, 0.0f); glVertex3f((float)i, 10.0f, 0.0f); glEnd(); } for(int i=-10;i<=10;i++){ glBegin(GL_LINES); glVertex3f(-10.0f, (float)i, 0.0f); glVertex3f(10.0f, (float)i, 0.0f); glEnd(); } glDisable(GL_CULL_FACE); //sphereBatch.Draw(); glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix()); modelView.PopMatrix(); // rysowanie siatki - koniec ------------------------------------------------------------------- //matrixStack.Translate(10.0f,1.0f,0.0f); // macierz translacji i macierz rotacji //M3DMatrix44f mT,mR; // m3dTranslationMatrix44(mT,0.0f,3.0f,0.0f); //m3dRotationMatrix44(mR, angle, 0.0f, 0.0f, 1.0f); //mno¿enie macierzy translacji i macierzy rotacji //m3dMatrixMultiply44(mM,mT,mR); //mno¿enie macierzy przekszta³ceñ i macierzy projekcji modelwidok // m3dMatrixMultiply44(mModelViewProjection,mModelViewProjection, mM); //wysy³anie macierzy projekcji modelwidok do shadera //glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, mModelViewProjection); //TriangleFace(position,color,atVector); //DrawPramid(0.5,0.0,1.0); //drawTriangles(20, ico_vertices, ico_faces); //matrixStack.PopMatrix(); //matrixStack.Rotate(45.0,0,0,1); //matrixStack.Translate(0.0,0.0,1.0); //glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); //DrawPramid(0.5,0.0,1.0); glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix()); modelView.PopMatrix(); glUseProgram(Pshader);//wywo³anie shadera // Perform the buffer swap to display back buffer glutSwapBuffers(); glutPostRedisplay(); }
void renderScene() { //Colours: static GLfloat vDarkRed[] = {0.0f, 0.396f, 0.702f, 1.0f}; static GLfloat vDarkGrey[] = {0.2f, 0.2f, 0.2f, 1.0f}; static CStopWatch inputTimer; //Clear buffers glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); //Beginning push: modelViewStack.PushMatrix(); //Camera matrix: M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewStack.PushMatrix(mCamera); modelViewStack.Rotate(-15.0f, 1.0f, 0.0f, 0.0f); if (screenshot) { cameraFrame.SetForwardVector(0, 0, -1); cameraFrame.SetUpVector(0, 1, 0); cameraFrame.GetCameraMatrix(mCamera); modelViewStack.PushMatrix(mCamera); } //Light source: static M3DVector4f vAmbient = {0.1f, 0.1f, 0.1f, 1.0f}; static M3DVector4f vLightPos = {4.0f, -6.5f, 10.0f, 1.0f}; static M3DVector4f vLightEyePos; m3dTransformVector4(vLightEyePos, vLightPos, mCamera); //Draw floor and grid: glEnable(GL_MULTISAMPLE); cRoom.draw(shaderManager, tPipeline, modelViewStack); // Highlight grid hlGrid.draw(shaderManager, tPipeline, modelViewStack); //Draw desks: stuDesks.drawAll(shaderManager, tPipeline, vLightEyePos, modelViewStack, vAmbient); //Draw polygon version of desks glDisable(GL_MULTISAMPLE); //Disable multisampling (to use AA) glEnable(GL_BLEND); //Enable blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPolygonOffset(-1.0f, -1.0f); glEnable(GL_POLYGON_OFFSET_LINE); //Render wireframe in front of polygon glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //Wireframe mode glEnable(GL_LINE_SMOOTH); //Enable AA stuDesks.drawAll(shaderManager, tPipeline, vLightEyePos, modelViewStack, vAmbient, vDarkGrey); //Draw wireframe version of desks //Reset stuff as they were before: glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_OFFSET_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_BLEND); //End cam push: modelViewStack.PopMatrix(); //End pop: modelViewStack.PopMatrix(); if (!screenshot) { newDeskButton.draw(W_WIDTH, W_HEIGHT); removeDeskButton.draw(W_WIDTH, W_HEIGHT); exportButton.draw(W_WIDTH, W_HEIGHT); } glutSwapBuffers(); if (screenshot) { char name[38]; sprintf(name, "Exports/screenshot%d.tga", expCounter); gltWriteTGA(name); counterSaver(); modelViewStack.PopMatrix(); screenshot = false; } glutPostRedisplay(); handleInput(inputTimer); }
void RenderScene(void) { // clear the window with current clearing lightColor glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); // use camera transform M3DMatrix44f cameraMatrix; cameraFrame.GetCameraMatrix(cameraMatrix); modelViewMatrix.PushMatrix(cameraMatrix); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.0f, -10.0f); materialDiffuseColor[0] = materialDiffuseColor[1] = materialDiffuseColor[2] = 0.9f; PassGouraudDataToShader(); glutSolidCube(20); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 2, 0); modelViewMatrix.Rotate(timer.GetElapsedSeconds()*5, 0.0f, 0.0f, 1.0f); materialDiffuseColor[0] = 0.0f; materialDiffuseColor[1] = 0.0f; materialDiffuseColor[2] = 0.9f; PassGouraudDataToShader(); RenderTwentatenta(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, -2, 0); modelViewMatrix.Rotate(timer.GetElapsedSeconds()*10, 0.0f, 0.0f, 1.0f); materialDiffuseColor[0] = 0.0f; materialDiffuseColor[1] = 0.9f; materialDiffuseColor[2] = 0.0f; PassGouraudDataToShader(); RenderSmoothTwentatenta(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); //modelViewMatrix.Translate(0, 0, 0); modelViewMatrix.Rotate(timer.GetElapsedSeconds()*10, 0.0f, 0.0f, 1.0f); materialDiffuseColor[0] = 0.9f; materialDiffuseColor[1] = 0.0f; materialDiffuseColor[2] = 0.0f; PassGouraudDataToShader(); glutSolidSphere(1, 20, 20); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(5.0f, 0.0f, 3.0f); materialDiffuseColor[0] = materialDiffuseColor[1] = materialDiffuseColor[2] = 10.0f; PassGouraudDataToShader(); glutSolidCube(0.1); modelViewMatrix.PopMatrix(); // bring camera matrix back to top of the stack modelViewMatrix.PopMatrix(); // perform the buffer swap to display back buffer glutSwapBuffers(); glutPostRedisplay(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUniform3fv(shaderMaterialAmbientLocation, 1, ambientColor); glUniform3fv(shaderMaterialDiffuseLocation, 1, diffuseColor); glUniform3fv(shaderMaterialSpecularLocation, 1, specularColor); glUniform1f(shaderMaterialSpecularExponentLocation, specularExponent); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); GLMatrixStack modelView; GLMatrixStack projection; GLGeometryTransform geometryPipeline; geometryPipeline.SetMatrixStacks(modelView,projection); projection.LoadMatrix(frustum.GetProjectionMatrix()); modelView.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujSiatke(); modelView.PushMatrix(); modelView.Translate(0.0f,0.0f,-1.f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(MNMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujTrojkat(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(0.0f,4.0f,0.f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(MNMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujTrojkat(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(3.0f,-3.0f,0.f); modelView.Scale(2.0f,2.0f,2.f); modelView.Rotate(45,0,0,1); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(MNMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); rysujTrojkat(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(3.0f,3.0f,0.f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(MNMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); drawTriangles(20, ico_vertices,ico_faces); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(0.0f,0.0f,7.f); modelView.Rotate(90+rotAngle,1,1,1); modelView.Scale(2.0f,2.5f,2.5f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(MNMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); drawTriangles(20, ico_vertices,ico_faces); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-4.0f,0.0f,4.f); modelView.Scale(2.0f,2.0f,2.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(MNMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glDrawElements(GL_TRIANGLES,3*n_faces,GL_UNSIGNED_INT,0); modelView.PopMatrix(); // Perform the buffer swap to display back buffer glutSwapBuffers(); rotAngle+=5.f; if(!stopRotate){ M3DVector3f at={0,0,0}; M3DVector3f up={0,0,1}; M3DVector3f eye; float angle = timer.GetElapsedSeconds()*3.14159f /3.f; eye[0]=16.f*cos(angle); eye[1]=40.0f*sin(angle); eye[2]=20.0f; LookAt(cameraFrame,eye,at,up); } glutPostRedisplay(); }
// Called to draw scene void RenderScene(void) { // Color values static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f}; static GLfloat vTorusColor[] = { 1.0f, 0.0f, 0.0f, 1.0f }; static GLfloat vSphereColor[] = { 0.0f, 0.0f, 1.0f, 1.0f }; // Time Based animation static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; // Clear the color and depth buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Save the current modelview matrix (the identity matrix) modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.PushMatrix(mCamera); // Draw the ground shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor); floorBatch.Draw(); for(int i = 0; i < NUM_SPHERES; i++) { modelViewMatrix.PushMatrix(); modelViewMatrix.MultMatrix(spheres[i]); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vSphereColor); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); } // Draw the spinning Torus modelViewMatrix.Translate(0.0f, 0.0f, -2.5f); // Save the Translation modelViewMatrix.PushMatrix(); // Apply a rotation and draw the torus modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vTorusColor); torusBatch.Draw(); modelViewMatrix.PopMatrix(); // "Erase" the Rotation from before // Apply another rotation, followed by a translation, then draw the sphere modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.8f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vSphereColor); sphereBatch.Draw(); // Restore the previous modleview matrix (the identity matrix) modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Tell GLUT to do it again glutPostRedisplay(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); static CStopWatch Timer; float angle = Timer.GetElapsedSeconds() * 3/7; GLfloat position[] = { 1.0f, 1.0f, .5f }; GLfloat color[] = { 1.0f, 1.0f, 1.0f }; GLfloat angle2 = 90.0f; GLfloat attenuation0 = 0.1f; GLfloat attenuation1 = 0.1f; GLfloat attenuation2 = 0.1f; GLfloat ambientColor[] = { 0.1f, 0.5f, 0.1f }; GLfloat diffuseColor[] = { 1.0f, 1.0f, 0.0f }; GLfloat specularColor[] = { 0.0f, 0.0f, 1.0f }; GLfloat specularExponent = 100.0f; GLMatrixStack modelView; GLMatrixStack projection; M3DVector3f at={0,0,0}; M3DVector3f up={0,0,1}; M3DVector3f eye; eye[0] = 2 * cos(angle); eye[1] = 2 * sin(angle); eye[2] = 10; LookAt(cameraFrame,eye,at,up); GLGeometryTransform geometryPipeline; geometryPipeline.SetMatrixStacks(modelView,projection); projection.LoadMatrix(frustum.GetProjectionMatrix()); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); for(int i=-10; i<=10; ++i) { glBegin(GL_LINES); glVertex3f(-10, i, 0); glVertex3f(10, i, 0); glEnd(); glBegin(GL_LINES); glVertex3f(i, -10, 0); glVertex3f(i, 10, 0); glEnd(); } modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(0,0.0,0.0); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, angle2); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); GLuint vertex_buffer; glGenBuffers(1,&vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); glBufferData(GL_ARRAY_BUFFER,n_vertices*sizeof(float)*7,&vertices[0],GL_STATIC_DRAW); if(glGetError()!=GL_NO_ERROR) { fprintf(stderr,"error copying vertices\n"); } glVertexAttribPointer(GLT_ATTRIBUTE_VERTEX,4,GL_FLOAT,GL_FALSE,sizeof(float)*7,(const GLvoid *)0); glVertexAttribPointer(GLT_ATTRIBUTE_NORMAL,3,GL_FLOAT,GL_FALSE,sizeof(float)*7,(const GLvoid *)(4*sizeof(float)) ); glEnableVertexAttribArray(GLT_ATTRIBUTE_VERTEX); glEnableVertexAttribArray(GLT_ATTRIBUTE_NORMAL); GLuint faces_buffer; glGenBuffers(1,&faces_buffer); if(glGetError()!=GL_NO_ERROR) { fprintf(stderr,"faces_buffer invalid\n"); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,faces_buffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER,n_faces*sizeof(GLuint)*3,&faces[0],GL_STATIC_DRAW); if(glGetError()!=GL_NO_ERROR) { fprintf(stderr,"error copying faces\n"); } glDrawElements(GL_TRIANGLES,3*n_faces,GL_UNSIGNED_INT,0); modelView.PopMatrix(); // Perform the buffer swap to display back buffer glUseProgram(0); glutSwapBuffers(); glutPostRedisplay(); }
/////////////////////////////////////////////////////////////////////////////// // Render a frame. The owning framework is responsible for buffer swaps, // flushes, etc. void RenderScene(void) { // first render the scene in HDR to fbo glBindFramebuffer(GL_DRAW_FRAMEBUFFER, hdrFBO[0]); glDrawBuffers(1, &fboBuffs[0]); glClearColor(vSkyBlue[0], vSkyBlue[1], vSkyBlue[2], vSkyBlue[3]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw to two textures, the first contains scene data // the second contains only the bright areas modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); // Marble // Draw the floor SetupTexReplaceProg(vLightPos, vWhite); floorBatch.Draw(); // Draw the window modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, -0.4f, -4.0f); modelViewMatrix.Rotate(10.0, 0.0, 1.0, 0.0); glBindTexture(GL_TEXTURE_2D, windowTexture); // Window Tex // First draw the window contents from texture SetupTexReplaceProg(vLightPos, vWhiteX2); windowBatch.Draw(); // Now draw the border and the grid SetupFlatColorProg(vLightPos, vLtGrey); windowGridBatch.Draw(); windowBorderBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); projectionMatrix.PushMatrix(); projectionMatrix.LoadMatrix(orthoMatrix); modelViewMatrix.PushMatrix(); modelViewMatrix.LoadIdentity(); // Combine original scene with blurred bright textures // to create the bloom effect glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glDrawBuffers(1,windowBuff); glViewport(0, 0, screenWidth, screenHeight); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetupHDRProg(); screenQuad.Draw(); modelViewMatrix.PopMatrix(); projectionMatrix.PopMatrix(); // Put the texture units back the way they were glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); // Do the buffer Swap glutSwapBuffers(); // Do it again glutPostRedisplay(); }