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(); }
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); modelViewMatrix.Rotate(-90.0f, 1.0f, 0.0f, 0.0f); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 0.0f, 1.0f); GLfloat vEyeLight[] = { -100.0f, 100.0f, 150.0f }; GLfloat vAmbientColor[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat vDiffuseColor[] = { 1.0f, 1.0f, 1.0f, 1.0f}; glUseProgram(normalMapShader); glUniform4fv(locAmbient, 1, vAmbientColor); glUniform4fv(locDiffuse, 1, vDiffuseColor); glUniform3fv(locLight, 1, vEyeLight); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); glUniform1i(locColorMap, 0); glUniform1i(locNormalMap, 1); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void animate() { frameNo++; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glUseProgram(shader); //cameraAngleX += randf() * 5.0; //cameraAngleY += randf() * 2.7; //cameraAngleZ += randf() * 50.0; cameraBothZ += randf() * 10.0; matrixStack.LoadIdentity(); matrixStack.PushMatrix(); matrixStack.Scale(0.1,0.1,0.1); //Perspektywa + krêcenie kamery matrixStack.Rotate(40, 1, 0, 0); matrixStack.Rotate(cameraBothZ, 0, 0, 1); glUniformMatrix4fv(PMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix()); float ambient[] = {0.5,0.2,0.2}, diffuse[] = {0.5,0.2,1}, specular[] = {0.2,1,0.2}; material.setMaterial(ambient, diffuse, specular, 1); float color[] = {1,1,1}, position[] = {0,0,-1}; light.setLight(position, color, 180, 1, 1, 2); float ambientLight[] = {1,1,1}; glUniform3fv(ambientLightLocation, 1, ambientLight); float small_color[] = {1,1,1}, small_position[] = {5 + 2*cos(frameNo/180.0*PI/2.0), 5 + 2*sin(frameNo/180.0*PI/2.0), -1}; small_light.setLight(small_position, small_color, 180, 1, 1, 2); matrixStack.PopMatrix(); //siatka pushSiatka(); float ambient2[] = {0.2,0.2,0.2}; material.setMaterial(ambient2, diffuse, specular, 1); RenderDwudziestoscian(5,5,-2,0.8); RenderDwudziestoscian(-5,-5,-2,0.5); RenderDwudziestoscian(small_position[0], small_position[1], small_position[2], 0.2); glutSwapBuffers(); }
/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld() { modelViewMatrix.Translate(0.0f, 0.8f, 0.0f); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(-0.3f, 0.f, 0.0f); modelViewMatrix.Scale(0.40, 0.8, 0.40); modelViewMatrix.Rotate(50.0, 0.0, 10.0, 0.0); glSampleMaski(0, 0x02); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtYellow); glass1Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.4f, 0.0f, 0.0f); modelViewMatrix.Scale(0.5, 0.8, 1.0); modelViewMatrix.Rotate(-20.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x04); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtGreen); glass2Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(1.0f, 0.0f, -0.6f); modelViewMatrix.Scale(0.3, 0.9, 1.0); modelViewMatrix.Rotate(-40.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x08); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtMagenta); glass3Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(-0.8f, 0.0f, -0.60f); modelViewMatrix.Scale(0.6, 0.9, 0.40); modelViewMatrix.Rotate(60.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x10); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtBlue); glass4Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.1f, 0.0f, 0.50f); modelViewMatrix.Scale(0.4, 0.9, 0.4); modelViewMatrix.Rotate(205.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x20); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtPink); glass4Batch.Draw(); modelViewMatrix.PopMatrix(); }
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) { static CStopWatch rotTimer; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); { modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.f, 0.0f, 1.0f, 0.0f); glUseProgram(toonShader); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeLine.GetModelViewMatrix()); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeLine.GetModelViewProjectionMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeLine.GetNormalMatrix()); glUniform3fv(locLP, 1, vEyeLight); glUniform1i(locColorTable, 0); torusBatch.Draw(); } modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 13.0f, 1.0f, 0.0f, 0.0f); GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f }; GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f }; GLfloat vDiffuseColor[] = { 0.1f, 1.0f, 0.1f, 1.0f }; GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glUseProgram(explodeProgram); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); float push_out = sinf(rotTimer.GetElapsedSeconds() * 3.0f) * 0.1f + 0.2f; glUniform1f(locPushOut, push_out); torusBatch.Draw(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld(GLfloat yRot) { M3DMatrix44f mCamera; modelViewMatrix.GetMatrix(mCamera); // Need light position relative to the Camera M3DVector4f vLightTransformed; m3dTransformVector4(vLightTransformed, vLightPos, mCamera); // Draw the light source as a small white unshaded sphere modelViewMatrix.PushMatrix(); modelViewMatrix.Translatev(vLightPos); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vWhite); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); // Draw stuff relative to the camera modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.2f, -2.5f); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeline.GetProjectionMatrix(), vLightTransformed, vGreen, 0); torusBatch.Draw(); modelViewMatrix.PopMatrix(); }
// Called to draw scene static void RenderScene(void) { static CStopWatch rotTimer; // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); modelViewMatrix.Rotate(40.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Rotate(20.0f, 1.0f, 0.0f, 0.0f); float f = (float)rotTimer.GetElapsedSeconds(); GLfloat vViewpoint[] = { sinf(f * 3.1f) * 30.0f, cosf(f * 2.4f) * 30.0f, sinf(f * 1.7f) * 30.0f }; glUseProgram(cullingShader); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); glUniform3fv(locViewpoint, 1, vViewpoint); torusBatch.Draw(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); 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(); }
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); modelViewMatrix.Translate(0.0f, 0.0f, 800.0f); modelViewMatrix.Rotate(-12.0, 1.0f, 0.0f, 0.0f); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 15.0f, 0.0f, 1.0f, 0.0f); glUseProgram(grassShader); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glBindVertexArray(vao); glDrawArraysInstancedARB(GL_TRIANGLE_STRIP, 0, 6, 1024 * 1024); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void drawTorus(GLfloat yRot) { M3DMatrix44f mCamera; M3DVector4f vLightTransform; modelViewMatrix.GetMatrix(mCamera); m3dTransformVector4(vLightTransform,vLightPosition,mCamera); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0,0.5,-1.0); modelViewMatrix.Rotate(yRot,0.0,1.0,0.0); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeline.GetProjectionMatrix(), vLightTransform,vGreen,0); torusBatch.Draw(); modelViewMatrix.PopMatrix(); }
/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld(GLfloat yRot) { M3DMatrix44f mCamera; modelViewMatrix.GetMatrix(mCamera); // Need light position relative to the Camera M3DVector4f vLightTransformed; m3dTransformVector4(vLightTransformed, vLightPos, mCamera); // Draw the light source as a small white unshaded sphere modelViewMatrix.PushMatrix(); modelViewMatrix.Translatev(vLightPos); if(bUseFBO) UseProcessProgram(vLightPos, vWhite, -1); else shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vWhite); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); // Draw stuff relative to the camera modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.2f, -2.5f); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.0, (GLfloat)-0.60, 0.0); modelViewMatrix.Scale((GLfloat)0.02, (GLfloat)0.006, (GLfloat)0.02); glBindTexture(GL_TEXTURE_2D, ninjaTex[0]); if(bUseFBO) { UseProcessProgram(vLightTransformed, vWhite, 0); } else { shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeline.GetModelViewProjectionMatrix(), 0); } ninja.Render(0,0); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); }
void DrawMaennchen(float angle) { //float overallScaleFactor = 0.2 * cos(GL_PI / 200 * angle) + 1; float jumpFactor = abs(cos(GL_PI/10 * angle)); /** * Rumpf zeichnen **/ modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(angle, 0, -1, 0); // generelle Verschiebung aus dem Mittelpunkt heraus modelViewMatrix.Translate(200.0f, 0.0f, 0.0f); // Verschiebung fuer Huepfbahn modelViewMatrix.Translate(0.0f, 30 * jumpFactor, 0); //modelViewMatrix.Scale(overallScaleFactor, overallScaleFactor, overallScaleFactor); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.9, 1.0, 0.7); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCylinder(); modelViewMatrix.PopMatrix(); // Hals modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 55.0f, 0.0f); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.25, 0.15, 0.25); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCylinder(); modelViewMatrix.PopMatrix(); // Kopf modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 40.0f, 0.0f); modelViewMatrix.Scale(0.72, 0.72, 0.72); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawSphere(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); // Giedmaßen zeichnen - abhaengig vom Rumpf! DrawLimbs(angle); modelViewMatrix.PopMatrix(); }
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(); }
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; GLenum e; // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 20.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 17.0f, 1.0f, 0.0f, 0.0f); GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f }; GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f }; GLfloat vDiffuseColor[] = { 0.1f, 1.0f, 0.1f, 1.0f }; GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glUseProgram(toonShader); // glUniform3fv(locLight, 1, vEyeLight); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); e = glGetError(); // torusBatch.Draw(); // cubeBatch.Draw(); glDisable(GL_CULL_FACE); e = glGetError(); glBindVertexArray(vao); e = glGetError(); glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, NULL); e = glGetError(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); 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 }; // 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(); // Draw the ground shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor); floorBatch.Draw(); // Draw the spinning Torus modelViewMatrix.Translate(0.0f, 0.0f, -2.5f); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vTorusColor); torusBatch.Draw(); // Restore the previous modleview matrix (the idenity matrix) modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Tell GLUT to do it again glutPostRedisplay(); }
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(viewFrame); modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f); GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f }; GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f }; GLfloat vDiffuseColor[] = { 0.1f, 1.0f, 0.1f, 1.0f }; GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glUseProgram(ADSDissloveShader); glUniform4fv(locAmbient, 1, vAmbientColor); glUniform4fv(locDiffuse, 1, vDiffuseColor); glUniform4fv(locSpecular, 1, vSpecularColor); glUniform3fv(locLight, 1, vEyeLight); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix()); glUniform1i(locTexture, 1); float fFactor = fmod(rotTimer.GetElapsedSeconds(), 10.0f); fFactor /= 10.0f; glUniform1f(locDissolveFactor, fFactor); torusBatch.Draw(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void RenderScene(void) { static CStopWatch rotTimer; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mvMatrix.PushMatrix(viewFrame); mvMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f); GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f }; GLfloat vDiffuseColor[] = { 0.0f, 0.0f, 1.0f, 1.0f }; GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f }; glUseProgram(ADSGouraudShader); glUniform4fv(locAC, 1, vAmbientColor); glUniform4fv(locDC, 1, vDiffuseColor); glUniform4fv(locSC, 1, vSpecularColor); glUniform3fv(locLP, 1, vEyeLight); glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeLine.GetModelViewProjectionMatrix()); glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeLine.GetModelViewMatrix()); glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeLine.GetNormalMatrix()); sphereBatch.Draw(); mvMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
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 DrawSongAndDance(GLfloat yRot) // Called to draw dancing objects { static GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f }; static GLfloat vLightPos[] = { 0.0f, 3.0f, 0.0f, 1.0f }; // Get the light position in eye space M3DVector4f vLightTransformed; M3DMatrix44f mCamera; modelViewMatrix.GetMatrix(mCamera); m3dTransformVector4(vLightTransformed, vLightPos, mCamera); // Draw the light source modelViewMatrix.PushMatrix(); modelViewMatrix.Translatev(vLightPos); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeLine.GetModelViewProjectionMatrix(), vWhite); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); glBindTexture(GL_TEXTURE_2D, uiTextures[2]); for (int i = 0; i < NUM_SPHERES; i++) { modelViewMatrix.PushMatrix(); modelViewMatrix.MultMatrix(spheres[i]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeLine.GetProjectionMatrix(), vLightTransformed, vWhite, 0); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); } // Song and dance modelViewMatrix.Translate(0.0f, 0.2f, -2.5f); modelViewMatrix.PushMatrix(); // Saves the translated origin modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); // Draw stuff relative to the camera glBindTexture(GL_TEXTURE_2D, uiTextures[1]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeLine.GetProjectionMatrix(), vLightTransformed, vWhite, 0); torusBatch.Draw(); modelViewMatrix.PopMatrix(); // Erased the rotate modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.8f, 0.0f, 0.0f); glBindTexture(GL_TEXTURE_2D, uiTextures[2]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeLine.GetProjectionMatrix(), vLightTransformed, vWhite, 0); sphereBatch.Draw(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glFrontFace(GL_CW); glUseProgram(shader); M3DVector3f at={1.5f, 0.0f, 0.0f}; M3DVector3f up={-1.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]= 30.0f; LookAt(cameraFrame,eye,at,up); M3DVector3f ambientLight = {1.0f, 1.0f, 1.0f}; M3DVector3f position = {10.0f, 10.0f, 5.0f}; M3DVector3f color = {1.0f, 1.0f, 1.0f}; float l_angle = 90.0f; float attenuation0 = 0.01f; float attenuation1 = 0.01f; float attenuation2 = 0.01f; M3DVector3f ambientColor = {0.0f, 1.0, 0.0}; M3DVector3f diffuseColor = {0.0f, 1.0f, 1.0f}; M3DVector3f specularColor = {1.0f, 1.0f, 1.0f}; float specularExponent = 8; projection.LoadMatrix(viewFrustum.GetProjectionMatrix()); modelView.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); glPolygonOffset(1.0f, 1.0f); grid(); glEnable(GL_POLYGON_OFFSET_FILL); grid(); glDisable(GL_POLYGON_OFFSET_FILL); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-7.75f, -7.75f, 0.0f); modelView.Scale(0.25f, 0.25f, 0.25f); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-6.0f, -6.0f, 0.0f); modelView.Scale(0.5f, 0.5f, 0.5f); modelView.Rotate(angle*512, 0.0f, 0.0f, 2.0f); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); glDrawElements(GL_TRIANGLES,3*n_faces,GL_UNSIGNED_INT,0); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-4.0f, -4.0f, 0.0f); modelView.Scale(0.75f, 0.75f, 0.75f); modelView.Rotate(angle*512, 0.0f, 2.0f, 0.0f); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); piramida(); modelView.PopMatrix();` modelView.PushMatrix(); modelView.Translate(2.0f, 2.0f, 0.0f); modelView.Scale(1.5f, 1.5f, 1.5f); modelView.Rotate(angle*512, 2.0f, 2.0f, 0.0f); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-1.5f, -1.5f, 0.0f); modelView.Rotate(angle*512, 2.0f, 0.0f, 0.0f); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); DrawTriangles(20, vertices_tab, faces_tab); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(6.5f, 6.5f, 0.0f); modelView.Scale(2.5f, 2.5f, 2.5f); modelView.Rotate(angle*512, 2.0f, 2.0f, 2.0f); glUniform3fv(shaderPositionLocation, 1, position); glUniform3fv(shaderColorLocation, 1, color); glUniform1f(shaderAngleLocation, l_angle); glUniform1f(shaderAttenuation0Location, attenuation0); glUniform1f(shaderAttenuation1Location, attenuation1); glUniform1f(shaderAttenuation2Location, attenuation2); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewMatrix()); glUniformMatrix3fv(normalMatrixLocation,1,GL_FALSE,geometryPipeline.GetNormalMatrix()); glUniform3fv(ambientLightLocation, 1, ambientLight); glUniform3fv(shaderAmbientColorLocation, 1, ambientColor); glUniform3fv(shaderDiffuseColorLocation, 1, diffuseColor); glUniform3fv(shaderSpecularColorLocation, 1, specularColor); glUniform1f(shaderSpecularExponentLocation, specularExponent); DrawSmoothTriangles(20, vertices_tab, faces_tab); modelView.PopMatrix(); modelView.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); GLMatrixStack modelView; GLMatrixStack projection; GLGeometryTransform geometryPipeline; geometryPipeline.SetMatrixStacks(modelView,projection); M3DVector3f at={0,0,0}; M3DVector3f up={0,0,1}; M3DVector3f eye; float angle=timer.GetElapsedSeconds()*3.14f; eye[0]=40*cos(angle); eye[1]=40*sin(angle); eye[2]=30.0f; LookAt(frame,eye,at,up); projection.LoadMatrix(frustum.GetProjectionMatrix()); modelView.PushMatrix(); M3DMatrix44f mCamera; frame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glBegin(GL_LINES); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.5f, 0.5f, 0.5f); for (int i=-10; i<=10; i++) { glVertex3f(i,-10.0f,0); glVertex3f(i,10.0f,0); glVertex3f(-10.0f,i,0); glVertex3f(10.0f,i,0); } glEnd(); modelView.Translate(10.0f,1.0f,0.0f); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glBegin(GL_QUADS); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.5f, 0.5f, 0.5f); 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(0.0f, 0.0f, 2.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.0f, 0.0f, 0.8f); 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, 1.0f, 0.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, 1.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); glVertex3f(1.0f, -1.0f, 0.0f); glEnd(); modelView.PopMatrix(); modelView.Rotate(45.0,0,0,1); modelView.Translate(0.0,0.0,1.0); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); glBegin(GL_QUADS); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.5f, 0.5f, 0.5f); 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(0.0f, 0.0f, 2.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertexAttrib3f(GLT_ATTRIBUTE_COLOR, 0.0f, 0.0f, 0.8f); 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, 1.0f, 0.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, 1.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); glVertex3f(1.0f, -1.0f, 0.0f); glEnd(); modelView.PopMatrix(); modelView.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
/////////////////////////////////////////////////////////////////////////////// // Render a frame. The owning framework is responsible for buffer swaps, // flushes, etc. void RenderScene(void) { // Bind the FBO with multisample buffers glBindFramebuffer(GL_DRAW_FRAMEBUFFER, msFBO); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // User selected order independant transparency if (mode == USER_OIT) { // Use OIT, setup sample masks glSampleMaski(0, 0x01); glEnable(GL_SAMPLE_MASK); // Prevent depth test from culling covered surfaces glDepthFunc(GL_ALWAYS); } modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, -0.4f, -4.0f); modelViewMatrix.Rotate(worldAngle, 0.0, 1.0, 0.0); // Draw the background and disk to the first sample modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 3.0f, 0.0f); modelViewMatrix.Rotate(90.0, 1.0, 0.0, 0.0); modelViewMatrix.Rotate(90.0, 0.0, 0.0, 1.0); glBindTexture(GL_TEXTURE_2D, textures[1]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeline.GetModelViewProjectionMatrix(), 0); bckgrndCylBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.Translate(0.0f, -0.3f, 0.0f); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(90.0, 1.0, 0.0, 0.0); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vGrey); diskBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.Translate(0.0f, 0.1f, 0.0f); // User selected blending if (mode == USER_BLEND) { // Setup blend state glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); switch (blendMode) { case 1: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; case 2: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA); break; case 3: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); break; case 4: glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; case 5: glBlendFunc(GL_SRC_ALPHA, GL_DST_COLOR); break; case 6: glBlendFuncSeparate(GL_SRC_ALPHA, GL_DST_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; case 7: glBlendFuncSeparate(GL_SRC_COLOR, GL_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; default: glDisable(GL_BLEND); } } // Now draw the glass pieces DrawWorld(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); // Clean up all state glDepthFunc(GL_LEQUAL); glDisable(GL_BLEND); glDisable(GL_SAMPLE_MASK); glSampleMaski(0, 0xffffffff); // Resolve multisample buffer projectionMatrix.PushMatrix(); projectionMatrix.LoadMatrix(orthoMatrix); modelViewMatrix.PushMatrix(); modelViewMatrix.LoadIdentity(); // Setup and Clear the default framebuffer glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glViewport(0, 0, screenWidth, screenHeight); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (mode == USER_OIT) SetupOITResolveProg(); else if (mode == USER_BLEND) SetupResolveProg(); // Draw a full-size quad to resolve the multisample surfaces screenQuad.Draw(); modelViewMatrix.PopMatrix(); projectionMatrix.PopMatrix(); // Reset texture state glEnable(GL_DEPTH_TEST); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); // Do the buffer Swap glutSwapBuffers(); // Do it again 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) { 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(); }
/////////////////////////////////////////////////////////////////////////////// // 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(); }
/** * @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) { 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()); grid(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-7.75f, -7.75f, 0.0f); modelView.Scale(0.25f, 0.25f, 0.25f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-6.0f, -6.0f, 0.0f); modelView.Scale(0.5f, 0.5f, 0.5f); modelView.Rotate(angle*512, 0.0f, 0.0f, 2.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-4.0f, -4.0f, 0.0f); modelView.Scale(0.75f, 0.75f, 0.75f); modelView.Rotate(angle*512, 0.0f, 2.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-1.5f, -1.5f, 0.0f); modelView.Rotate(angle*512, 2.0f, 0.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(2.0f, 2.0f, 0.0f); modelView.Scale(1.5f, 1.5f, 1.5f); modelView.Rotate(angle*512, 2.0f, 2.0f, 0.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); piramida(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(6.5f, 6.5f, 0.0f); modelView.Scale(2.5f, 2.5f, 2.5f); modelView.Rotate(angle*512, 2.0f, 2.0f, 2.0f); glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); piramida(); modelView.PopMatrix(); modelView.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }