dapit

pelangi2

Apr 27th, 2018
2,411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <GL/glut.h>
  2.  
  3. void persegi();
  4. int main(int argc, char** argv)
  5. {
  6. glutInit(&argc,argv);
  7. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  8. glutInitWindowSize(640,640);
  9. glutCreateWindow("Membuat Persegi Pelangi");
  10. glutDisplayFunc(persegi);
  11. glutMainLoop();
  12. }
  13. void persegi()
  14. {
  15.  
  16. glBegin(GL_POLYGON);
  17. glColor3f(1.0, 0.0 ,0.0);
  18. glVertex2f(-0.8,0.7);
  19. glVertex2f(-0.8,0.8);
  20. glVertex2f(0.8,0.8);
  21. glVertex2f(0.8,0.7);
  22. glEnd();
  23.  
  24. glBegin(GL_POLYGON);
  25. glColor3f(1.0, 0.5, 0.0);
  26. glVertex2f(-0.8,0.6);
  27. glVertex2f(-0.8,0.7);
  28. glVertex2f(0.8,0.7);
  29. glVertex2f(0.8,0.6);
  30. glEnd();
  31.  
  32. glBegin(GL_POLYGON);
  33. glColor3f(1.0, 1.0, 0.0);
  34. glVertex2f(-0.8,0.5);
  35. glVertex2f(-0.8,0.6);
  36. glVertex2f(0.8,0.6);
  37. glVertex2f(0.8,0.5);
  38. glEnd();
  39.  
  40. glBegin(GL_POLYGON);
  41. glColor3f(0.0, 1.0, 0.0);
  42. glVertex2f(-0.8,0.4);
  43. glVertex2f(-0.8,0.5);
  44. glVertex2f(0.8,0.5);
  45. glVertex2f(0.8,0.4);
  46. glEnd();
  47.  
  48. glBegin(GL_POLYGON);
  49. glColor3f(0.0, 1.0, 1.0);
  50. glVertex2f(-0.8,0.3);
  51. glVertex2f(-0.8,0.4);
  52. glVertex2f(0.8,0.4);
  53. glVertex2f(0.8,0.3);
  54. glEnd();
  55.  
  56. glBegin(GL_POLYGON);
  57. glColor3f(0.0, 0.0, 1.0);
  58. glVertex2f(-0.8,0.2);
  59. glVertex2f(-0.8,0.3);
  60. glVertex2f(0.8,0.3);
  61. glVertex2f(0.8,0.2);
  62. glEnd();
  63.  
  64. glBegin(GL_POLYGON);
  65. glColor3f(0.53, 0.12, 0.47);
  66. glVertex2f(-0.8,0.1);
  67. glVertex2f(-0.8,0.2);
  68. glVertex2f(0.8,0.2);
  69. glVertex2f(0.8,0.1);
  70. glEnd();
  71.  
  72. glFlush();
  73. }
Advertisement
Add Comment
Please, Sign In to add comment