Advertisement
axyd

Opengl Pentagram

Dec 7th, 2021
2,601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1: #include <GL/glut.h>
  2. 2: #include <stdlib.h>
  3. 3:
  4. 4:
  5. 5: void display(void)
  6. 6: {
  7. 7: glClear(GL_COLOR_BUFFER_BIT); //flush gl
  8. 8: glColor3f(1.0, 0.0, 0.0); //red line color
  9. 9:
  10. 10: //outer pentagram, clockwise
  11. 11: glBegin(GL_LINE_LOOP);
  12. 12: glVertex2i(20,80);
  13. 13: glVertex2i(70,120);
  14. 14: glVertex2i(120,80);
  15. 15: glVertex2i(100,20);
  16. 16: glVertex2i(40,20);
  17. 17: glEnd();
  18. 18:
  19. 19: //inner pentagram
  20. 20: glBegin(GL_LINE_LOOP);
  21. 21: glVertex2i(70,100);
  22. 22: glVertex2i(90,40);
  23. 23: glVertex2i(40,70);
  24. 24: glVertex2i(100,70);
  25. 25: glVertex2i(50,40);
  26. 26: glEnd();
  27. 27:
  28. 28: //connectors
  29. 29: glBegin(GL_LINES);
  30. 30: //north
  31. 31: glVertex2i(70,120);
  32. 32: glVertex2i(70,100);
  33. 33: //north-east
  34. 34: glVertex2i(120,80);
  35. 35: glVertex2i(100,70);
  36. 36: //south-east
  37. 37: glVertex2i(100,20);
  38. 38: glVertex2i(90,40);
  39. 39: //south-west
  40. 40: glVertex2i(40,20);
  41. 41: glVertex2i(50,40);
  42. 42: //north-west
  43. 43: glVertex2i(20,80);
  44. 44: glVertex2i(40,70);
  45. 45: glEnd();
  46. 46:
  47. 47: glFlush(); //force immidiate display
  48. 48: }
  49. 49:
  50. 50: int main(int argc,char *argv[])
  51. 51: {
  52. 52: glutInit(&argc,argv); //prepare glut
  53. 53: glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); //set the display m
  54. 54: glutInitWindowSize (500, 500); //the size of the program windo
  55. 55: glutInitWindowPosition (100, 100); //initial position for the wind
  56. 56: glutCreateWindow ("points and lines"); //create window with a title
  57. 57:
  58. 58: glClearColor(255,255,255,0.0); //background color
  59. 59: glMatrixMode (GL_PROJECTION); //2d envyronment
  60. 60: gluOrtho2D (0.0, 200.0, 0.0, 150.0); //matrix dimensions
  61. 61:
  62. 62: glutDisplayFunc(display); //show thee actual program
  63. 63: glutMainLoop();
  64. 64:
  65. 65: return EXIT_SUCCESS; //exit the program
  66. 66: }
  67. 67:
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement