MarouaneTheViper

Letter N

Mar 26th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 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(90, 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(0,0,0);
  22. glVertex3i(2,0,0);
  23. glVertex3i(0,2,0);
  24. glVertex3i(2,2,0);
  25. glEnd();
  26. glLoadIdentity();
  27. glutSwapBuffers();
  28. }
  29.  
  30. void mouse(int button, int state, int x, int y) {
  31. switch (button) {
  32. case GLUT_LEFT_BUTTON:
  33. if (state == GLUT_DOWN)
  34. exit(0);
  35. break;
  36. }
  37. }
  38.  
  39. void keyboard(unsigned char key, int x,int y)
  40. {}
  41.  
  42. static void idle(void)
  43. {
  44. glutPostRedisplay();
  45. }
  46.  
  47. int main(int argc, char *argv[])
  48. {
  49. glutInit(&argc, argv);
  50. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  51. glutInitWindowSize(900, 900);
  52. glutInitWindowPosition (100, 100);
  53. glutCreateWindow("Assignment 1");
  54. glutDisplayFunc(display);
  55. glutMouseFunc(mouse);
  56. glutKeyboardFunc(keyboard);
  57. glutIdleFunc(idle);
  58. glutMainLoop();
  59. return EXIT_SUCCESS;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment