cppbug

buggy cube - main.cpp

Apr 25th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include "cube.hpp"
  2. #include <windows.h>    // only on windows ;)
  3. #include <GL/glut.h>
  4.  
  5. Cube *cube = new Cube(75.0f);
  6.  
  7. void display()
  8. {
  9.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  10.     glPushMatrix();
  11.     cube->draw();
  12.     glPopMatrix();
  13.     glutSwapBuffers();
  14. }
  15. void timer(int = 0)
  16. {
  17.     cube->tick();
  18.     display();
  19.     glutTimerFunc(10, timer, 0);
  20. }
  21.  
  22. int main(int argc, char **argv)
  23. {
  24.     glutInit(&argc, argv);
  25.     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  26.     glutInitWindowSize(400, 400);
  27.     glutInitWindowPosition(600, 300);
  28.     glutCreateWindow("Cube");
  29.  
  30.     glClearColor(0, 0, 0, 1.0);
  31.     glMatrixMode(GL_PROJECTION);
  32.     glLoadIdentity();
  33.     glEnable(GL_DEPTH_TEST);
  34.  
  35.     gluPerspective(45, 1, 37, 500);
  36.     glMatrixMode(GL_MODELVIEW);
  37.  
  38.     glutDisplayFunc(display);
  39.  
  40.     timer();
  41.  
  42.     glutMainLoop();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment