Guest User

Untitled

a guest
Jun 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "TdisplayImp.h"
  3. #include "Ground.h"
  4.  
  5.  
  6. void TDisplayImp::init(void)
  7. {
  8. }
  9.  
  10.  
  11. void TDisplayImp::initialiseOpenGL(int argc, char** argv)
  12. {
  13. glutInit(&argc, argv);
  14. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
  15. glutInitWindowSize (400, 400);
  16. glutInitWindowPosition (200, 200);
  17. glutCreateWindow ("Breakout Game");
  18. init();
  19. glutReshapeFunc(TDisplayImp::reshape);
  20. glutDisplayFunc(TDisplayImp::displayCallBack);
  21. glutKeyboardFunc(TDisplayImp::KeyboardCallBack);
  22. glutSpecialFunc(TDisplayImp::SpecialKeyboardCallBack);
  23. glutIdleFunc(TDisplayImp::idle);
  24. }
  25.  
  26.  
  27. void TDisplayImp::reshape(int w, int h)
  28. {
  29. glViewport(0,0,(GLsizei)w,(GLsizei)h);
  30. glMatrixMode(GL_PROJECTION);
  31. glLoadIdentity();
  32. gluPerspective(40.0,(GLdouble)w/(GLdouble)h, 1.0, 1000.0);
  33. glMatrixMode(GL_MODELVIEW);
  34. glLoadIdentity();
  35. }
  36.  
  37. void TDisplayImp::idle(void)
  38. {
  39. glutPostRedisplay();
  40. }
  41.  
  42.  
  43. void TDisplayImp::renderScene()
  44. {
  45. glutMainLoop();
  46. }
  47.  
  48.  
  49. void TDisplayImp::displayCallBack()
  50. {
  51. glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  52. gluLookAt(100,100,20,0,0,0,0,10,0);
  53. //glPushMatrix();
  54. TGround ground;
  55. ground.DrawGround();
  56. //glPopMatrix();
  57. glutSwapBuffers();
  58. }
  59.  
  60.  
  61. void TDisplayImp::KeyboardCallBack(unsigned char key, int A, int B)
  62. {
  63. glutPostRedisplay();
  64. }
  65.  
  66.  
  67. void TDisplayImp::SpecialKeyboardCallBack(int key1, int A, int B)
  68. {
  69. glutPostRedisplay();
  70. }
  71.  
  72.  
  73. void main(int argc, char** argv)
  74. {
  75. TDisplayImp::initialiseOpenGL(argc, argv);
  76. TDisplayImp::renderScene();
  77. }
Add Comment
Please, Sign In to add comment