Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <glut.h>
  2. #include <cmath>
  3. #include <math.h>
  4.  
  5. float rotace = 0;
  6. float posunPL = 0;
  7. float posunND = 0;
  8.  
  9. void onResize(int w, int h)
  10. {
  11. glViewport(0, 0, w, h);
  12. glMatrixMode(GL_PROJECTION);
  13. glLoadIdentity();
  14. glOrtho(0, w, 0, h, -800, 800);
  15. }
  16.  
  17. void Zobrazeni(void)
  18. {
  19. glClearColor(0.0, 0.0, 0.0, 0.0);
  20. glClear(GL_COLOR_BUFFER_BIT);
  21.  
  22. glColor3f(0.0f, 1.0f, 0.0f);
  23. glLineWidth(3.0f);
  24. glEnable(GL_LINE_SMOOTH);
  25. glMatrixMode(GL_MODELVIEW);
  26.  
  27. glLoadIdentity();
  28. glTranslatef(800+posunPL, 500.0f+posunND, 500);
  29. glRotatef(rotace, 1.0f, 0, 0.0f);
  30.  
  31.  
  32. glColor3f(1.0, 1.0, 1.0);
  33. //glBegin(GL_POLYGON);
  34. /*glVertex3i(150, 150, 0);
  35. glVertex3i(450, 150, 0);
  36. glVertex3i(450, 450, 0);
  37. //glColor3f(1.0, 0.0, 1.0);
  38. glVertex3i(250, 450, 0);
  39. //glColor3f(0.0, 0.0, 1.0);
  40. glVertex3i(150, 250, 0);
  41. glVertex3i(150, 150, 0);
  42. glEnd();*/
  43.  
  44. glutSolidTeapot(50);
  45.  
  46.  
  47. glFlush();
  48.  
  49. }
  50.  
  51. void onKeyboard(unsigned char key, int x, int y)
  52. {
  53. switch (key)
  54. {
  55. case 27:
  56. exit(0);
  57. break;
  58. case 'r':
  59. rotace += 15;
  60. glutPostRedisplay();
  61. break;
  62. case 'd':
  63. posunPL += 1;
  64. glutPostRedisplay();
  65. break;
  66. case 'a':
  67. posunPL -= 1;
  68. glutPostRedisplay();
  69. break;
  70. case 'w':
  71. posunND += 1;
  72. glutPostRedisplay();
  73. break;
  74. case 's':
  75. posunND -= 1;
  76. glutPostRedisplay();
  77. break;
  78.  
  79. }
  80. }
  81.  
  82. int main(int argc, char **argv)
  83. {
  84. glutInit(&argc, argv);
  85. glutCreateWindow("OpenGL okno");
  86. glutReshapeWindow(1920, 1080);
  87. glutPositionWindow(0, 0);
  88. glutDisplayFunc(Zobrazeni);
  89. glutReshapeFunc(onResize);
  90. glutKeyboardFunc(onKeyboard);
  91. glutMainLoop();
  92. return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement