Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. /*
  2.  * Main file.
  3.  * Set up GLUT and openGl, initialize the game class, awesomeness.
  4.  */
  5.  
  6. /* Includes */
  7. #include "main.h"
  8.  
  9. /*
  10.  * main():
  11.  *      Entry point for the game.
  12.  */
  13. int
  14. main(int argc, char *argv[])
  15. {
  16.         /*
  17.          * Step 1.
  18.          *      Seeing as glut is not super-compatible with objective c++
  19.          *      we'll have to cheat a little bit. Basicly initialize glut here
  20.          *      instead of in the class itself.
  21.          */
  22.         glutInit(&argc, argv);
  23.         glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
  24.         glutInitWindowSize (GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT);
  25.         glutInitWindowPosition (100, 100);
  26.  
  27.         /* Create our glut window */
  28.         glutCreateWindow (GAME_TITLE);
  29.         glClearColor (0.0, 0.0, 0.0, 0.0);
  30.  
  31.         /* Setup the viewport */
  32.         glViewport(0, 0, GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT);
  33.  
  34.         /* Change the matrix so we have (0,0) at the top left */
  35.         glMatrixMode(GL_PROJECTION);
  36.         glLoadIdentity();
  37.         glOrtho(0.0, GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT, 0.0, -1.0, 1.0);
  38.         glMatrixMode(GL_MODELVIEW);
  39.         glLoadIdentity();
  40.  
  41.         /*
  42.          * Step 2.
  43.          *      Set up the game class and initialize it.
  44.          */
  45.  
  46.         // ...
  47.  
  48.         /*
  49.          * Step 3.
  50.          *      So, glut has been setup. And basic openGL has been setup aswell.
  51.          *      From here we'll have a function that will call our class functions.
  52.          */
  53.         glutDisplayFunc(callDraw);
  54.         glutIdleFunc(callLogic);
  55.         glutKeyboardFunc(callKeyboard);
  56.         glutSpecialFunc(callMovement);
  57.         glutSpecialUpFunc(callMovementRelease);
  58.  
  59.         /* Fire off the main loop */
  60.         glutMainLoop();
  61.  
  62.         return 0;
  63. }
  64.  
  65. /*
  66.  * callLogic():
  67.  *      Basicly just calls the gameLogic function from our main game class.
  68.  */
  69. void
  70. callLogic()
  71. {
  72.         /* Get the current time */
  73.         timeNow = clock();
  74.  
  75.         /* Prevent the game FPS from reaching above 120 */
  76.         if ((timeNow - timeMovement) > CLK_TCK / GAME_MAX_FPS) {
  77.                 timeMovement = timeNow;
  78.                 newGame->gameLogic();
  79.         }
  80.  
  81. }
  82.  
  83. /*
  84.  * callDraw():
  85.  *      And this little thingie calls the draw function from our main game class.
  86.  */
  87. void
  88. callDraw()
  89. {
  90.         //newGame->gameDraw();
  91. }
  92.  
  93. /*
  94.  * callKeyboard():
  95.  *      Sends the key pressed to our game keyboard controller.
  96.  */
  97. void
  98. callKeyboard(unsigned char key, int x, int y)
  99. {
  100.         //newGame->gameKeyboard(key, x, y);
  101. }
  102.  
  103. /*
  104.  * callMovement():
  105.  *      Sends the movement.
  106.  */
  107. void
  108. callMovement(int key, int x, int y)
  109. {
  110.         //newGame->gameMovement(key, x, y);
  111. }
  112.  
  113. /*
  114.  * callMovementRelase():
  115.  *      Releases the movement keys.
  116.  */
  117. void
  118. callMovementRelease(int key, int x, int y)
  119. {
  120.         //newGame->gameMovementRelease(key, x, y);
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement