Advertisement
GURPSONE

Untitled

Jul 31st, 2012
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. void RenderScene()
  2. { // Give OpenGL our camera position
  3. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
  4. glLoadIdentity();
  5. g_Camera.Look();
  6. CVector3 vPos = g_Camera.Position();
  7. CVector3 vNewPos = vPos;
  8. CVector3 vView = g_Camera.View();
  9.  
  10. if (introScreen == true) {
  11.  
  12. GLTexture tex;
  13. tex.Load("Intro.bmp");
  14. tex.Use();
  15. glMatrixMode(GL_MODELVIEW);
  16. glPushMatrix();
  17. glLoadIdentity();
  18. glBegin(GL_QUADS);
  19. glTexCoord2f(0.0, 0.0);
  20. glVertex3f(-1.0f, -1.0f, -1.5f);
  21. glTexCoord2f(1.0, 0.0);
  22. glVertex3f(1.0f, -1.0f, -1.5f);
  23. glTexCoord2f(1.0, 1.0);
  24. glVertex3f(1.0f, 1.0f, -1.5f);
  25. glTexCoord2f(0.0, 1.0);
  26. glVertex3f(-1.0f, 1.0f, -1.5f);
  27. glEnd();
  28. glPopMatrix();
  29.  
  30.  
  31. //If we are on an introscreen, we can render it here, else...
  32. } else {
  33.  
  34. drawText(TimerText, 15, 25); //Draw text for the timer
  35. char xPos[100], yPos[100], zPos[100];
  36. sprintf_s(xPos, "Camera X: %f", g_Camera.Position().x);
  37. sprintf_s(yPos, "Camera Y: %f", g_Camera.Position().y);
  38. sprintf_s(zPos, "Camera Z: %f", g_Camera.Position().z);
  39. drawText(xPos, 15, 45);
  40. drawText(yPos, 15, 65);
  41. drawText(zPos, 15, 85);
  42. perimeterCheck();
  43. sprintf_s(LivesHUD, "Coins Collected: %d", CoinsCollected);
  44. drawText(LivesHUD, 15, 105);
  45.  
  46.  
  47.  
  48. // Render the terrain as a simple quad - currently it is flat but it could be made into a terrain with a heightmap!
  49. RenderQuadTerrain();
  50.  
  51. //Draw the skybox
  52. CreateSkyBox(vNewPos.x, vNewPos.y, vNewPos.z,3500,3000,3500);
  53. DrawCoins();
  54.  
  55. CollisionTest(g_Camera.Position().x, g_Camera.Position().y, g_Camera.Position().z);
  56. DrawEnemy();
  57. DrawEnemy1();
  58.  
  59. //Draw SecondaryObjects models
  60. DrawSecondaryObjects();
  61.  
  62. //Apply lighting effects
  63. LightingEffects();
  64. escapeAttempt();
  65. if(playerdamageTaken){
  66. glEnable(GL_BLEND);
  67. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // additive blending
  68. float blendFactor = 1.0;
  69. glColor4f(1, 0, 0, blendFactor);
  70. glDisable(GL_DEPTH_TEST);// when blendFactor = 0, the quad won't be visible. When blendFactor=1, the scene will be bathed in redness
  71.  
  72. glBegin(GL_QUADS); // Draw A Quad
  73. glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
  74. glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
  75. glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
  76. glVertex3f(-1.0f,-1.0f, 0.0f);
  77.  
  78. // Bottom Left
  79. glEnd();
  80. glEnable(GL_DEPTH_TEST);
  81. glDisable(GL_BLEND);
  82. }
  83. }
  84. SwapBuffers(g_hDC); // Swap the backbuffers to the foreground
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement