Guest User

Untitled

a guest
Jun 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #include <GL/glut.h>
  2.  
  3. void render(void)
  4. {
  5. //house
  6. glClear(GL_COLOR_BUFFER_BIT);
  7. glBegin(GL_POLYGON);
  8. glColor3f(1, 0, 0);
  9. glVertex2f(-0.4, 0.4);
  10. glVertex2f(0.4, 0.4);
  11. glVertex2f(0.4, -0.4);
  12. glVertex2f(-0.4, -0.4);
  13. glEnd();
  14.  
  15. //right window
  16. glBegin(GL_POLYGON);
  17. glColor3f(0, 0, 1);
  18. glVertex2f(0.3, 0.3);
  19. glVertex2f(0.2, 0.3);
  20. glVertex2f(0.2, 0.2);
  21. glVertex2f(0.3, 0.2);
  22. glEnd();
  23.  
  24. //left window
  25. glBegin(GL_POLYGON);
  26. glColor3f(0, 0, 1);
  27. glVertex2f(-0.3, 0.3);
  28. glVertex2f(-0.2, 0.3);
  29. glVertex2f(-0.2, 0.2);
  30. glVertex2f(-0.3, 0.2);
  31. glEnd();
  32.  
  33. //door
  34. glBegin(GL_POLYGON);
  35. glColor3f(0, 1, 1);
  36. glVertex2f(-0.1, -0.4);
  37. glVertex2f(0.1, -0.4);
  38. glVertex2f(0.1, 0.0);
  39. glVertex2f(-0.1, 0.0);
  40. glEnd();
  41.  
  42. //path strip 1
  43. glBegin(GL_POLYGON);
  44. glColor3f(0, 1, 0);
  45. glVertex2f(-0.1, -0.4);
  46. glVertex2f(0.1, -0.4);
  47. glVertex2f(-0.1, -0.5);
  48. glVertex2f(-0.3, -0.5);
  49. glEnd();
  50.  
  51. //path strip 2
  52. glBegin(GL_POLYGON);
  53. glColor3f(0, 0, 1);
  54. glVertex2f(-0.3, -0.5);
  55. glVertex2f(-0.1, -0.5);
  56. glVertex2f(-0.3, -0.6);
  57. glVertex2f(-0.5, -0.6);
  58. glEnd();
  59.  
  60. //path strip 3
  61. glBegin(GL_POLYGON);
  62. glColor3f(1, 0, 1);
  63. glVertex2f(-0.5, -0.6);
  64. glVertex2f(-0.3, -0.6);
  65. glVertex2f(-0.5, -0.7);
  66. glVertex2f(-0.7, -0.7);
  67. glEnd();
  68.  
  69. //roof
  70. glBegin(GL_TRIANGLES);
  71. glColor3f(0, 1, 0);
  72. glVertex2f(0.4, 0.4);
  73. glVertex2f(-0.4, 0.4);
  74. glVertex2f(0.0, 0.8);
  75. glEnd();
  76. glFlush();
  77. }
  78.  
  79. int main(int argc, char** argv)
  80. {
  81. glutInit(&argc, argv);
  82. glutInitDisplayMode(GLUT_SINGLE);
  83. glutInitWindowSize(1000, 1000);
  84. glutInitWindowPosition(100, 100);
  85. glutCreateWindow("House");
  86. glutDisplayFunc(render);
  87. glutMainLoop();
  88. return 0;
  89. }
Add Comment
Please, Sign In to add comment