Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Main file.
- * Set up GLUT and openGl, initialize the game class, awesomeness.
- */
- /* Includes */
- #include "main.h"
- /*
- * main():
- * Entry point for the game.
- */
- int
- main(int argc, char *argv[])
- {
- /*
- * Step 1.
- * Seeing as glut is not super-compatible with objective c++
- * we'll have to cheat a little bit. Basicly initialize glut here
- * instead of in the class itself.
- */
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize (GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT);
- glutInitWindowPosition (100, 100);
- /* Create our glut window */
- glutCreateWindow (GAME_TITLE);
- glClearColor (0.0, 0.0, 0.0, 0.0);
- /* Setup the viewport */
- glViewport(0, 0, GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT);
- /* Change the matrix so we have (0,0) at the top left */
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT, 0.0, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- /*
- * Step 2.
- * Set up the game class and initialize it.
- */
- // ...
- /*
- * Step 3.
- * So, glut has been setup. And basic openGL has been setup aswell.
- * From here we'll have a function that will call our class functions.
- */
- glutDisplayFunc(callDraw);
- glutIdleFunc(callLogic);
- glutKeyboardFunc(callKeyboard);
- glutSpecialFunc(callMovement);
- glutSpecialUpFunc(callMovementRelease);
- /* Fire off the main loop */
- glutMainLoop();
- return 0;
- }
- /*
- * callLogic():
- * Basicly just calls the gameLogic function from our main game class.
- */
- void
- callLogic()
- {
- /* Get the current time */
- timeNow = clock();
- /* Prevent the game FPS from reaching above 120 */
- if ((timeNow - timeMovement) > CLK_TCK / GAME_MAX_FPS) {
- timeMovement = timeNow;
- newGame->gameLogic();
- }
- }
- /*
- * callDraw():
- * And this little thingie calls the draw function from our main game class.
- */
- void
- callDraw()
- {
- //newGame->gameDraw();
- }
- /*
- * callKeyboard():
- * Sends the key pressed to our game keyboard controller.
- */
- void
- callKeyboard(unsigned char key, int x, int y)
- {
- //newGame->gameKeyboard(key, x, y);
- }
- /*
- * callMovement():
- * Sends the movement.
- */
- void
- callMovement(int key, int x, int y)
- {
- //newGame->gameMovement(key, x, y);
- }
- /*
- * callMovementRelase():
- * Releases the movement keys.
- */
- void
- callMovementRelease(int key, int x, int y)
- {
- //newGame->gameMovementRelease(key, x, y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement