Advertisement
dapit

modul3 3

Jun 2nd, 2018
3,762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include <GL/glut.h>
  2. #include <windows.h>
  3. #include <GL/gl.h>
  4.  
  5. void init (void) {
  6. glClearColor (1.0, 1.0, 1.0, 0.0);
  7. glLineWidth (1.0);
  8. glColor3f (1.0, 0.0, 0.0);
  9. glOrtho (-6,6, -6,6, -6,6);
  10. }
  11. void Display (void) {
  12. glClear (GL_COLOR_BUFFER_BIT);
  13. glBegin (GL_LINES);
  14. glVertex2f (-5.5, 0.0);
  15. glColor3f (1.0, 0.0, 0.0);
  16. glVertex2f (5.5, 0.0);
  17. glEnd ();
  18. glBegin (GL_LINES);
  19. glVertex2f (0.0, -5.5);
  20. glColor3f (1.0, 0.0, 0.0);
  21. glVertex2f (0.0, 5.5);
  22. glEnd ();
  23.  
  24.  
  25. glBegin (GL_TRIANGLES);
  26. glColor3f (1.0, 0.0, 0.0);
  27. glVertex2f (1.0, 1.0);
  28. glColor3f (0.0, 0.0, 1.0);
  29. glVertex2f (4.0, 1.0);
  30. glColor3f (0.0, 1.0, 0.0);
  31. glVertex2f (1.0, 5.0);
  32. glEnd ();
  33.  
  34. glBegin (GL_POLYGON);
  35. glColor3f (0.0, 1.0, 0.0);
  36. glVertex2f (-2.0, -1.0);
  37. glColor3f (0.0, 0.0, 1.0);
  38. glVertex2f (-3.0, -3.0);
  39. glColor3f (1.0, 0.0, 0.0);
  40. glVertex2f (-2.0, -5.0);
  41. glColor3f (0.0, 0.0, 1.0);
  42. glVertex2f (-1.0, -3.0);
  43. glEnd ();
  44.  
  45. glBegin (GL_POLYGON);
  46. glColor3f (1.0, 1.0, 0.0);
  47. glVertex2f (2.0, -1.0);
  48. glColor3f (1.0, 0.43, 0.78);
  49. glVertex2f (1.0, -3.0);
  50. glColor3f (0.0, 1.0, 1.0);
  51. glVertex2f (2.0, -5.0);
  52. glColor3f (1.0, 0.43, 0.78);
  53. glVertex2f (3.0, -3.0);
  54. glEnd ();
  55.  
  56. glBegin (GL_TRIANGLES);
  57. glColor3f (0.0, 1.0, 1.0);
  58. glVertex2f (-1.0, 1.0);
  59. glColor3f (1.0, 0.43, 0.78);
  60. glVertex2f (-4.0, 1.0);
  61. glColor3f (1.0, 1.0, 0.0);
  62. glVertex2f (-1.0, 5.0);
  63. glEnd ();
  64.  
  65. glutSwapBuffers ();
  66.  
  67. }
  68.  
  69. int main (int argc, char** argv) {
  70. glutInit (&argc, argv);
  71. glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
  72. glutInitWindowPosition (0, 0);
  73. glutInitWindowSize (1500, 1500);
  74. glutCreateWindow ("bangun dasar grafik");
  75. init ();
  76.  
  77.  
  78. glutDisplayFunc (Display);
  79. glutMainLoop ();
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement