// G³ówna funkcja rysowania. Tutaj wywo³ujemy wszystkie obiekty do narysowania. void display() { currentTime = glutGet(GLUT_ELAPSED_TIME); CalcCarPosition(); glm::vec4 &worldLightPos = carPosition; glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); { glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); lightPosCameraSpace = modelMatrix.Top() * worldLightPos; setDefaultLightParams(&adsShader, worldLightPos, direction, nextLight); { glutil::PushStack push(modelMatrix); // Pod³oga { glutil::PushStack push(modelMatrix); glm::mat4 invTransform = glm::inverse(modelMatrix.Top()); glUseProgram(adsShader.theProgram); glUniformMatrix4fv(adsShader.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform3f(adsShader.Ks, 0.0f, 0.0f, 0.0f); // niech pod³oga nie ma odbicia g_pPlaneMesh->Render("lit-color"); glUseProgram(0); } drawCylinder(modelMatrix, worldLightPos); drawCar(modelMatrix, worldLightPos); drawSphere1(modelMatrix, worldLightPos); drawSphere2(modelMatrix, worldLightPos); drawTetrahedron1(modelMatrix, worldLightPos); } } glutPostRedisplay(); glutSwapBuffers(); oldTime = currentTime; }
//Called whenever a key on the keyboard was pressed. //The key is given by the ''key'' parameter, which is in ASCII. //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to //exit the program. void keyboard(unsigned char key, int x, int y) { bool bChangedShininess = false; bool bChangedLightModel = false; switch (key) { case 27: delete g_pScene; g_pScene = NULL; glutLeaveMainLoop(); return; case 'p': g_lights.TogglePause(g_eTimerMode); break; case '-': g_lights.RewindTime(g_eTimerMode, 1.0f); break; case '=': g_lights.FastForwardTime(g_eTimerMode, 1.0f); break; case 't': g_bDrawCameraPos = !g_bDrawCameraPos; break; case '1': g_eTimerMode = TIMER_ALL; printf("All\n"); break; case '2': g_eTimerMode = TIMER_SUN; printf("Sun\n"); break; case '3': g_eTimerMode = TIMER_LIGHTS; printf("Lights\n"); break; case 'l': SetupDaytimeLighting(); break; case 'L': SetupNighttimeLighting(); break; case 'k': SetupHDRLighting(); break; case 32: { float sunAlpha = g_lights.GetSunTime(); float sunTimeHours = sunAlpha * 24.0f + 12.0f; sunTimeHours = sunTimeHours > 24.0f ? sunTimeHours - 24.0f : sunTimeHours; int sunHours = int(sunTimeHours); float sunTimeMinutes = (sunTimeHours - sunHours) * 60.0f; int sunMinutes = int(sunTimeMinutes); printf("%02i:%02i\n", sunHours, sunMinutes); } break; } g_viewPole.CharPress(key); }
void display() { g_LightTimer.Update(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh) { glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); const glm::vec4 &worldLightPos = CalcLightPosition(); const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos; ProgramData &whiteProg = g_Programs[g_eLightModel].whiteProg; ProgramData &colorProg = g_Programs[g_eLightModel].colorProg; glUseProgram(whiteProg.theProgram); glUniform4f(whiteProg.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(whiteProg.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUniform3fv(whiteProg.cameraSpaceLightPosUnif,1, glm::value_ptr(lightPosCameraSpace)); glUniform1f(whiteProg.lightAttenuationUnif, g_fLightAttenuation); glUniform1f(whiteProg.shininessFactorUnif, g_matParams); glUniform4fv(whiteProg.baseDiffuseColorUnif, 1, g_bDrawDark ? glm::value_ptr(g_darkColor) : glm::value_ptr(g_lightColor)); glUseProgram(colorProg.theProgram); glUniform4f(colorProg.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(colorProg.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUniform3fv(colorProg.cameraSpaceLightPosUnif, 1, glm::value_ptr(lightPosCameraSpace)); glUniform1f(colorProg.lightAttenuationUnif, g_fLightAttenuation); glUniform1f(colorProg.shininessFactorUnif, g_matParams); glUseProgram(0); { glutil::PushStack push(modelMatrix); //Render the ground plane. { glutil::PushStack push(modelMatrix); glm::mat3 normMatrix(modelMatrix.Top()); normMatrix = glm::transpose(glm::inverse(normMatrix)); glUseProgram(whiteProg.theProgram); glUniformMatrix4fv(whiteProg.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix3fv(whiteProg.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pPlaneMesh->Render(); glUseProgram(0); } //Render the Cylinder { glutil::PushStack push(modelMatrix); modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix()); if(g_bScaleCyl) modelMatrix.Scale(1.0f, 1.0f, 0.2f); glm::mat3 normMatrix(modelMatrix.Top()); normMatrix = glm::transpose(glm::inverse(normMatrix)); ProgramData &prog = g_bDrawColoredCyl ? colorProg : whiteProg; glUseProgram(prog.theProgram); glUniformMatrix4fv(prog.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix3fv(prog.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); if(g_bDrawColoredCyl) g_pCylinderMesh->Render("lit-color"); else g_pCylinderMesh->Render("lit"); glUseProgram(0); } //Render the light if(g_bDrawLightSource) { glutil::PushStack push(modelMatrix); modelMatrix.Translate(glm::vec3(worldLightPos)); modelMatrix.Scale(0.1f, 0.1f, 0.1f); glUseProgram(g_Unlit.theProgram); glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform4f(g_Unlit.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f); g_pCubeMesh->Render("flat"); } } } glutPostRedisplay(); glutSwapBuffers(); }
//Called to update the display. //You should call glutSwapBuffers after all of your rendering to display what you rendered. //If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function. void display() { g_lights.UpdateTime(); glm::vec4 bkg = g_lights.GetBackgroundColor(); glClearColor(bkg[0], bkg[1], bkg[2], bkg[3]); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); const glm::mat4 &worldToCamMat = modelMatrix.Top(); LightBlock lightData = g_lights.GetLightInformation(worldToCamMat); glBindBuffer(GL_UNIFORM_BUFFER, g_lightUniformBuffer); glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(lightData), &lightData); glBindBuffer(GL_UNIFORM_BUFFER, 0); if(g_pScene) { glutil::PushStack push(modelMatrix); g_pScene->Draw(modelMatrix, g_materialBlockIndex, g_lights.GetTimerValue("tetra")); } { glutil::PushStack push(modelMatrix); //Render the sun { glutil::PushStack push(modelMatrix); glm::vec3 sunlightDir(g_lights.GetSunlightDirection()); modelMatrix.Translate(sunlightDir * 500.0f); modelMatrix.Scale(30.0f, 30.0f, 30.0f); glUseProgram(g_Unlit.theProgram); glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::vec4 lightColor = g_lights.GetSunlightIntensity(); glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor)); g_pScene->GetSphereMesh()->Render("flat"); } //Render the lights if(g_bDrawLights) { for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++) { glutil::PushStack push(modelMatrix); modelMatrix.Translate(g_lights.GetWorldLightPosition(light)); glUseProgram(g_Unlit.theProgram); glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::vec4 lightColor = g_lights.GetPointLightIntensity(light); glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor)); g_pScene->GetCubeMesh()->Render("flat"); } } if(g_bDrawCameraPos) { glutil::PushStack push(modelMatrix); modelMatrix.SetIdentity(); modelMatrix.Translate(glm::vec3(0.0f, 0.0f, -g_viewPole.GetView().radius)); glDisable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); glUseProgram(g_Unlit.theProgram); glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform4f(g_Unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f); g_pScene->GetCubeMesh()->Render("flat"); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glUniform4f(g_Unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f); g_pScene->GetCubeMesh()->Render("flat"); } } glutPostRedisplay(); glutSwapBuffers(); }
void display() { g_LightTimer.Update(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh) { glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); const glm::vec4 &worldLightPos = CalcLightPosition(); glm::vec4 lightPosCameraSpace = modelMatrix.Top() * worldLightPos; glUseProgram(g_WhiteDiffuseColor.theProgram); glUniform3fv(g_WhiteDiffuseColor.lightPosUnif, 1, glm::value_ptr(lightPosCameraSpace)); glUseProgram(g_VertexDiffuseColor.theProgram); glUniform3fv(g_VertexDiffuseColor.lightPosUnif, 1, glm::value_ptr(lightPosCameraSpace)); glUseProgram(g_WhiteDiffuseColor.theProgram); glUniform4f(g_WhiteDiffuseColor.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(g_WhiteDiffuseColor.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUseProgram(g_VertexDiffuseColor.theProgram); glUniform4f(g_VertexDiffuseColor.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(g_VertexDiffuseColor.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUseProgram(0); { glutil::PushStack push(modelMatrix); //Render the ground plane. { glutil::PushStack push(modelMatrix); glUseProgram(g_WhiteDiffuseColor.theProgram); glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(g_WhiteDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pPlaneMesh->Render(); glUseProgram(0); } //Render the Cylinder { glutil::PushStack push(modelMatrix); modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix()); if(g_bDrawColoredCyl) { glUseProgram(g_VertexDiffuseColor.theProgram); glUniformMatrix4fv(g_VertexDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(g_VertexDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pCylinderMesh->Render("lit-color"); } else { glUseProgram(g_WhiteDiffuseColor.theProgram); glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(g_WhiteDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pCylinderMesh->Render("lit"); } glUseProgram(0); } //Render the light if(g_bDrawLight) { glutil::PushStack push(modelMatrix); modelMatrix.Translate(glm::vec3(worldLightPos)); modelMatrix.Scale(0.1f, 0.1f, 0.1f); glUseProgram(g_Unlit.theProgram); glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform4f(g_Unlit.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f); g_pCubeMesh->Render("flat"); } } } glutPostRedisplay(); glutSwapBuffers(); }
//Called to update the display. //You should call glutSwapBuffers after all of your rendering to display what you rendered. //If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function. void display() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(g_pPlaneMesh && g_pCylinderMesh) { glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection; glUseProgram(g_WhiteDiffuseColor.theProgram); glUniform3fv(g_WhiteDiffuseColor.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace)); glUseProgram(g_VertexDiffuseColor.theProgram); glUniform3fv(g_VertexDiffuseColor.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace)); glUseProgram(0); { glutil::PushStack push(modelMatrix); //Render the ground plane. { glutil::PushStack push(modelMatrix); glUseProgram(g_WhiteDiffuseColor.theProgram); glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(g_WhiteDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); glUniform4f(g_WhiteDiffuseColor.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f); g_pPlaneMesh->Render(); glUseProgram(0); } //Render the Cylinder { glutil::PushStack push(modelMatrix); modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix()); if(g_bScaleCyl) modelMatrix.Scale(1.0f, 1.0f, 0.2f); glUseProgram(g_VertexDiffuseColor.theProgram); glUniformMatrix4fv(g_VertexDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); if(g_bDoInvTranspose) { normMatrix = glm::transpose(glm::inverse(normMatrix)); } glUniformMatrix3fv(g_VertexDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); glUniform4f(g_VertexDiffuseColor.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f); g_pCylinderMesh->Render("lit-color"); glUseProgram(0); } } } glutSwapBuffers(); }
GLUSboolean display(GLUSfloat time) { g_LightTimer.Update(time); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); const glm::vec4 &worldLightPos = CalcLightPosition(); const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos; glUseProgram(g_MonoDiffuseProgram.program); glUniform4f(g_MonoDiffuseProgram.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(g_MonoDiffuseProgram.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUniform3fv(g_MonoDiffuseProgram.cameraSpaceLightPosUnif,1, glm::value_ptr(lightPosCameraSpace)); glUniform1f(g_MonoDiffuseProgram.lightAttenuationUnif, g_fLightAttenuation); glUniform1f(g_MonoDiffuseProgram.shininessFactorUnif, g_fGaussianRoughness); glUniform4fv(g_MonoDiffuseProgram.baseDiffuseColorUnif, 1, g_bDrawDark ? glm::value_ptr(g_darkColor) : glm::value_ptr(g_lightColor)); glUseProgram(g_ColorDiffuseProgram.program); glUniform4f(g_ColorDiffuseProgram.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(g_ColorDiffuseProgram.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUniform3fv(g_ColorDiffuseProgram.cameraSpaceLightPosUnif, 1, glm::value_ptr(lightPosCameraSpace)); glUniform1f(g_ColorDiffuseProgram.lightAttenuationUnif, g_fLightAttenuation); glUniform1f(g_ColorDiffuseProgram.shininessFactorUnif, g_fGaussianRoughness); glUseProgram(0); { glutil::PushStack push(modelMatrix); { glutil::PushStack push(modelMatrix); glm::mat3 normMatrix(modelMatrix.Top()); normMatrix = glm::transpose(glm::inverse(normMatrix)); glUseProgram(g_MonoDiffuseProgram.program); glUniformMatrix4fv(g_MonoDiffuseProgram.modelViewUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix3fv(g_MonoDiffuseProgram.modelViewForNormalUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pPlaneMesh->render(); glUseProgram(0); } { glutil::PushStack push(modelMatrix); modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix()); if (g_bScaleCyl) { modelMatrix.Scale(1.0f, 1.0f, 0.2f); } glm::mat3 normMatrix(modelMatrix.Top()); normMatrix = glm::transpose(glm::inverse(normMatrix)); ProgramData &prog = g_bDrawColoredCyl ? g_ColorDiffuseProgram : g_MonoDiffuseProgram; glUseProgram(prog.program); glUniformMatrix4fv(prog.modelViewUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix3fv(prog.modelViewForNormalUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pCylinderMesh->render(g_bDrawColoredCyl ? "lit-color" : "lit"); glUseProgram(0); } if (g_bDrawLightSource) { glutil::PushStack push(modelMatrix); modelMatrix.Translate(glm::vec3(worldLightPos)); modelMatrix.Scale(0.1f, 0.1f, 0.1f); glUseProgram(g_UnlitProgram.program); glUniformMatrix4fv(g_UnlitProgram.modelViewUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform4f(g_UnlitProgram.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f); g_pCubeMesh->render("flat"); } } return GLUS_TRUE; }
void display() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(g_pPlaneMesh && g_pCylinderMesh) { glutil::MatrixStack modelMatrix; modelMatrix.SetMatrix(g_viewPole.CalcMatrix()); glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection; ProgramData &whiteDiffuse = g_bShowAmbient ? g_WhiteAmbDiffuseColor : g_WhiteDiffuseColor; ProgramData &vertexDiffuse = g_bShowAmbient ? g_VertexAmbDiffuseColor : g_VertexDiffuseColor; if(g_bShowAmbient) { glUseProgram(whiteDiffuse.theProgram); glUniform4f(whiteDiffuse.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(whiteDiffuse.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); glUseProgram(vertexDiffuse.theProgram); glUniform4f(vertexDiffuse.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f); glUniform4f(vertexDiffuse.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f); } else { glUseProgram(whiteDiffuse.theProgram); glUniform4f(whiteDiffuse.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f); glUseProgram(vertexDiffuse.theProgram); glUniform4f(vertexDiffuse.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f); } glUseProgram(whiteDiffuse.theProgram); glUniform3fv(whiteDiffuse.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace)); glUseProgram(vertexDiffuse.theProgram); glUniform3fv(vertexDiffuse.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace)); glUseProgram(0); { glutil::PushStack push(modelMatrix); //Render the ground plane. { glutil::PushStack push(modelMatrix); glUseProgram(whiteDiffuse.theProgram); glUniformMatrix4fv(whiteDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(whiteDiffuse.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pPlaneMesh->Render(); glUseProgram(0); } //Render the Cylinder { glutil::PushStack push(modelMatrix); modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix()); if(g_bDrawColoredCyl) { glUseProgram(vertexDiffuse.theProgram); glUniformMatrix4fv(vertexDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(vertexDiffuse.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pCylinderMesh->Render("lit-color"); } else { glUseProgram(whiteDiffuse.theProgram); glUniformMatrix4fv(whiteDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glm::mat3 normMatrix(modelMatrix.Top()); glUniformMatrix3fv(whiteDiffuse.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix)); g_pCylinderMesh->Render("lit"); } glUseProgram(0); } } } glutSwapBuffers(); }