MarouaneTheViper

Rotating letter V (Question 3)

Mar 26th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #ifdef __APPLE__
  2. #include <GLUT/glut.h>
  3. #else
  4. #include <GL/glut.h>
  5. #endif
  6.  
  7. #include <stdlib.h>
  8.  
  9. int angle = 0;
  10.  
  11. void display(void)
  12. {
  13. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  14. glMatrixMode(GL_MODELVIEW);
  15. glLoadIdentity();
  16. glRotatef(180+angle, 0, 0, 1);
  17. glScalef(0.5f,0.5f,0.5f);
  18. glLineWidth(4.0);
  19. glBegin(GL_LINE_STRIP);
  20. glColor3f(1.0f,0.0f,1.0f);
  21. glVertex3i(-1,-2,0);
  22. glVertex3i(0,0,0);
  23. glVertex3i(1,-2,0);
  24. glEnd();
  25. glLoadIdentity();
  26. glutSwapBuffers();
  27. }
  28.  
  29. void mouse(int button, int state, int x, int y) {
  30. switch (button) {
  31. case GLUT_LEFT_BUTTON:
  32. if (state == GLUT_DOWN)
  33. exit(0);
  34. break;
  35. case GLUT_RIGHT_BUTTON:
  36. angle += 10;
  37. break;
  38. }
  39. }
  40.  
  41. void keyboard(unsigned char key, int x,int y)
  42. {}
  43.  
  44. static void idle(void)
  45. {
  46. glutPostRedisplay();
  47. }
  48.  
  49. int main(int argc, char *argv[])
  50. {
  51. glutInit(&argc, argv);
  52. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  53. glutInitWindowSize(900, 900);
  54. glutInitWindowPosition (100, 100);
  55. glutCreateWindow("Assignment 1");
  56. glutDisplayFunc(display);
  57. glutMouseFunc(mouse);
  58. glutKeyboardFunc(keyboard);
  59. glutIdleFunc(idle);
  60. glutMainLoop();
  61. return EXIT_SUCCESS;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment