Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #define GLUT_DISABLE_ATEXIT_HACK
  2. #include <GL/gl.h>
  3. #include <GL/glu.h>
  4. #include <GL/glut.h>
  5.  
  6. int screenWidth = 600;
  7. int screenHeight = 600;
  8.  
  9. void display() {
  10. glClear(GL_COLOR_BUFFER_BIT);
  11. glColor3f(0.0, 1.0, 0.0);
  12. glBegin(GL_LINE_LOOP);
  13. glVertex3f(100, 100, 0);
  14. glVertex3f(150, 100, 0);
  15. glVertex3f(150, 300, 0);
  16. glVertex3f(300, 300, 0);
  17. glVertex3f(300, 350, 0);
  18. glVertex3f(150, 350, 0);
  19. glVertex3f(150, 370, 0);
  20. glVertex3f(300, 370, 0);
  21. glVertex3f(300, 420, 0);
  22. glVertex3f(100, 420, 0);
  23. glEnd();
  24. glutSwapBuffers();
  25. }
  26.  
  27. void reshape(int w, int h) {
  28. glViewport(0, 0, (GLsizei) w, (GLsizei) h);
  29. glMatrixMode(GL_PROJECTION);
  30. glLoadIdentity();
  31. glOrtho(0.0, (GLdouble) w, 0.0, (GLdouble) h, 100, -100);
  32. glMatrixMode(GL_MODELVIEW);
  33. glLoadIdentity();
  34. }
  35.  
  36. void keyboard(unsigned char key, int x, int y){
  37. switch (key){
  38. case 27 :
  39. case 'q':
  40. exit(0);
  41. break;
  42. }
  43. }
  44.  
  45. int main(int argc, char *argv[]) {
  46. glutInit(&argc, argv);
  47. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  48. glutInitWindowSize(screenWidth, screenHeight);
  49. glutCreateWindow(argv[0]);
  50. glutDisplayFunc(display);
  51. glutReshapeFunc(reshape);
  52. glutKeyboardFunc(keyboard);
  53. glutMainLoop();
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement