Advertisement
salmancreation

star CG

Jul 20th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1. #include<GL\glut.h>
  2. void init(void)
  3. {
  4.     glClearColor(0.0, 0.0, 1.0, 0.0);
  5.     glMatrixMode(GL_PROJECTION);
  6.     gluOrtho2D(-2000.0, 2000.0, -2000.0, 2000.0);
  7. }
  8.  
  9. void buildHouse(void)
  10. {
  11.     glClear(GL_COLOR_BUFFER_BIT);
  12.     glColor3f(1.0, 0.4, 0.0);
  13.  
  14.      //glTranslatef(-0.5f, 0.4f, 0.0f);
  15.     glBegin(GL_POLYGON);  //start left tree orange
  16.     glVertex2i(-200, 400);
  17.     glVertex2i(0, 600);
  18.     glVertex2i(200, 400);
  19.     glVertex2i(400, 400);
  20.     glVertex2i(200, 200);
  21.     glVertex2i(200, 0);
  22.     glVertex2i(0, 200);
  23.     glVertex2i(-200, 0);
  24.     glVertex2i(-200, 200);
  25.     glVertex2i(-400, 400);
  26.     glVertex2i(-200, 400);
  27.     glEnd();   //end house
  28.  
  29.     glTranslatef(-0.9f, 0.1f, 0.0f);  //2
  30.     glBegin(GL_POLYGON);  //start left tree orange
  31.     glVertex2i(200, 0);
  32.     glVertex2i(500, 0);
  33.     glVertex2i(600, 200);
  34.     glVertex2i(800, 0);
  35.     glVertex2i(1000, 0);
  36.     glVertex2i(800, -200);
  37.     glVertex2i(800, -400);
  38.     glVertex2i(600, -200);
  39.     glVertex2i(400, -400);
  40.     glVertex2i(400, -200);
  41.     glEnd();   //end house
  42.  
  43.      //glTranslatef(-0.5f, 0.4f, 0.0f);
  44.     glBegin(GL_POLYGON);  //start left tree orange
  45.     glVertex2i(-200, -400);
  46.     //glVertex2i(0, 600);
  47.     glVertex2i(0, -200);
  48.     glVertex2i(200, -400);
  49.     glVertex2i(400, -400);
  50.     glVertex2i(200, -600);
  51.     glVertex2i(200, -800);
  52.     glVertex2i(0, -600);
  53.     glVertex2i(-200, -800);
  54.     glVertex2i(-200, -600);
  55.     glVertex2i(-400, -400);
  56.     glEnd();   //end house
  57.  
  58.  
  59.      glTranslatef(-0.9f, 0.1f, 0.0f);  //2
  60.     glBegin(GL_POLYGON);  //start left tree orange
  61.     glVertex2i(-200, 0);
  62.     glVertex2i(-400, 0);
  63.     glVertex2i(-600, 200);
  64.  
  65.     glEnd();   //end house
  66.  
  67.  
  68.  
  69.  
  70.     glFlush();
  71. }
  72.  
  73. int main(int argc, char** argv)
  74. {
  75.     glutInit(&argc, argv);
  76.     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  77.     glutInitWindowPosition(50, 50);
  78.     glutInitWindowSize(1900, 1900);
  79.     glutCreateWindow("House Section OpenGL");
  80.     init();
  81.     glutDisplayFunc(buildHouse);
  82.     glutMainLoop();
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement