Нема описа

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // main.cpp
  3. // ogamalBreakout
  4. //
  5. // Created by Osama Attia on 9/21/14.
  6. // ogamal@iastate.edu
  7. //
  8. #include <iostream>
  9. #include <assert.h>
  10. #include "math.h"
  11. #if defined(__APPLE__) || defined(MACOSX)
  12. #include <GLUT/glut.h>
  13. #else
  14. #include <GL/glut.h>
  15. #endif
  16. #include "Breakout.h"
  17. Breakout game;
  18. // Define the display function
  19. void myDisplay()
  20. {
  21. game.display();
  22. }
  23. // Define the reshape function
  24. void myReshape(int width, int height)
  25. {
  26. game.reshape(width, height);
  27. }
  28. // Define the mouse click events
  29. void myMouseClick(int button, int state, int x, int y)
  30. {
  31. game.mouseClick(button, state, x, y);
  32. }
  33. // Define the mouse drag events
  34. void myMouseMove(int x, int y)
  35. {
  36. game.mouseMove(x, y);
  37. }
  38. // Define keystroke events
  39. void myKeyStroke(unsigned char key, int x, int y)
  40. {
  41. game.keyStroke(key, x, y);
  42. }
  43. void mySpecialKeyStroke(int key, int x, int y)
  44. {
  45. game.specialKeyPos(key, x, y);
  46. }
  47. // The main function here
  48. int main(int argc, char ** argv)
  49. {
  50. // Init glut
  51. glutInit(&argc, argv);
  52. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_MULTISAMPLE);
  53. // Init display mode
  54. // Init window size, position, title
  55. glutInitWindowSize(WINWIDTH, WINHEIGHT);
  56. glutInitWindowPosition(100, 100);
  57. glutCreateWindow(WINTITLE);
  58. // Init game
  59. game.init();
  60. // Draw scene
  61. glutDisplayFunc(myDisplay);
  62. // Handle reshape
  63. glutReshapeFunc(myReshape);
  64. // Handle mouse clicks
  65. glutMouseFunc(myMouseClick);
  66. // Handle mouse motion
  67. // glutMotionFunc(myMouseMove);
  68. glutPassiveMotionFunc(myMouseMove);
  69. // Handle keyboard strokes
  70. glutKeyboardFunc(myKeyStroke);
  71. // specify keyboard special key input events
  72. glutSpecialFunc(mySpecialKeyStroke);
  73. // Enter the opengl event processing loop
  74. glutMainLoop();
  75. return 0;
  76. }