void RenderScene() { // Give OpenGL our camera position glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); g_Camera.Look(); CVector3 vPos = g_Camera.Position(); CVector3 vNewPos = vPos; CVector3 vView = g_Camera.View(); if (introScreen == true) { GLTexture tex; tex.Load("Intro.bmp"); tex.Use(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0f, -1.0f, -1.5f); glTexCoord2f(1.0, 0.0); glVertex3f(1.0f, -1.0f, -1.5f); glTexCoord2f(1.0, 1.0); glVertex3f(1.0f, 1.0f, -1.5f); glTexCoord2f(0.0, 1.0); glVertex3f(-1.0f, 1.0f, -1.5f); glEnd(); glPopMatrix(); //If we are on an introscreen, we can render it here, else... } else { drawText(TimerText, 15, 25); //Draw text for the timer char xPos[100], yPos[100], zPos[100]; sprintf_s(xPos, "Camera X: %f", g_Camera.Position().x); sprintf_s(yPos, "Camera Y: %f", g_Camera.Position().y); sprintf_s(zPos, "Camera Z: %f", g_Camera.Position().z); drawText(xPos, 15, 45); drawText(yPos, 15, 65); drawText(zPos, 15, 85); perimeterCheck(); sprintf_s(LivesHUD, "Coins Collected: %d", CoinsCollected); drawText(LivesHUD, 15, 105); // Render the terrain as a simple quad - currently it is flat but it could be made into a terrain with a heightmap! RenderQuadTerrain(); //Draw the skybox CreateSkyBox(vNewPos.x, vNewPos.y, vNewPos.z,3500,3000,3500); DrawCoins(); CollisionTest(g_Camera.Position().x, g_Camera.Position().y, g_Camera.Position().z); DrawEnemy(); DrawEnemy1(); //Draw SecondaryObjects models DrawSecondaryObjects(); //Apply lighting effects LightingEffects(); escapeAttempt(); if(playerdamageTaken){ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // additive blending float blendFactor = 1.0; glColor4f(1, 0, 0, blendFactor); glDisable(GL_DEPTH_TEST);// when blendFactor = 0, the quad won't be visible. When blendFactor=1, the scene will be bathed in redness glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); } } SwapBuffers(g_hDC); // Swap the backbuffers to the foreground }