Advertisement
shoroujjahan

Untitled

Jul 12th, 2021
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/gl.h>
  2. #include <GL/glut.h>
  3.  
  4. void display(void)
  5. {
  6. /*  clear all pixels  */
  7.     glClear (GL_COLOR_BUFFER_BIT);
  8.  
  9. /*  draw white polygon (rectangle) with corners at
  10.  *  (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
  11.  */
  12.  
  13.  glColor3f(0.0f, 0.5f, 1.0f);//baby Blue Sky
  14.     glBegin(GL_POLYGON);
  15.         glVertex3f (00, 50, 0.0);
  16.         glVertex3f (100, 50, 0.0);
  17.         glVertex3f (100, 100, 0.0);
  18.         glVertex3f (00, 100, 0.0);
  19.     glEnd();
  20.  
  21.    glColor3f(0.0f, 0.5f, 0.5f);//Blue-Green Ground
  22.     glBegin(GL_POLYGON);
  23.         glVertex3f (00, 00, 0.0);
  24.         glVertex3f (100, 00, 0.0);
  25.         glVertex3f (100, 50, 0.0);
  26.         glVertex3f (00, 50, 0.0);
  27.     glEnd();
  28.  
  29.  
  30.     glColor3f(0.5f, 0.5f, 0.5f);//Violet(House)
  31.     glBegin(GL_POLYGON);
  32.         glVertex3f (15, 20, 0.0);
  33.         glVertex3f (50, 20, 0.0);
  34.         glVertex3f (50, 50, 0.0);
  35.         glVertex3f (15, 50, 0.0);
  36.     glEnd();
  37.  
  38.    glColor3f(0.1f, 0.1f, 0.1f);//Dark grey(House Ground)
  39.     glBegin(GL_POLYGON);
  40.         glVertex3f (13, 18, 0.0);
  41.         glVertex3f (52, 18, 0.0);
  42.         glVertex3f (52, 20, 0.0);
  43.         glVertex3f (13, 20, 0.0);
  44.     glEnd();
  45.  
  46.  glColor3f(0.1f, 0.1f, 0.0f);//Bronze(Tree)
  47.     glBegin(GL_POLYGON);
  48.         glVertex3f (75, 20, 0.0);
  49.         glVertex3f (77, 20, 0.0);
  50.         glVertex3f (77, 50, 0.0);
  51.         glVertex3f (75, 50, 0.0);
  52.     glEnd();
  53.  
  54.     glBegin(GL_POLYGON);
  55.         glVertex3f (85, 20, 0.0);
  56.         glVertex3f (87, 20, 0.0);
  57.         glVertex3f (87, 43, 0.0);
  58.         glVertex3f (85, 43, 0.0);
  59.     glEnd();
  60.  
  61. glColor3f(0.1f, 0.0f, 0.0f);//Brown Door
  62.     glBegin(GL_POLYGON);
  63.         glVertex3f (29, 20, 0.0);
  64.         glVertex3f (36, 20, 0.0);
  65.         glVertex3f (36, 35, 0.0);
  66.         glVertex3f (29, 35, 0.0);
  67.     glEnd();
  68.  
  69.                        glColor4f(1.0f, 0.5f, 0.0f, 0.0f);//orange/brown Door Line
  70.                     glBegin(GL_POLYGON);
  71.                         glVertex3f (32.30f, 20, 0.0);
  72.                         glVertex3f (32.70f, 20, 0.0);
  73.                         glVertex3f (32.70f, 35, 0.0);
  74.                         glVertex3f (32.30f, 35, 0.0);
  75.                     glEnd();
  76.  
  77.  
  78.  
  79.     glColor3f(0.1f, 0.0f, 0.0f);//Brown Window
  80.     glBegin(GL_POLYGON);
  81.         glVertex3f (40, 33, 0.0);
  82.         glVertex3f (46, 33, 0.0);
  83.         glVertex3f (46, 40, 0.0);
  84.         glVertex3f (40, 40, 0.0);
  85.     glEnd();
  86.  
  87.     glColor3f(0.1f, 0.0f, 0.0f);//Brown Window
  88.     glBegin(GL_POLYGON);
  89.         glVertex3f (25, 33, 0.0);
  90.         glVertex3f (19, 33, 0.0);
  91.         glVertex3f (19, 40, 0.0);
  92.         glVertex3f (25, 40, 0.0);
  93.     glEnd();
  94.  
  95.  
  96.  glColor3f(0.0f, 0.1f, 0.0f);//Forest Green  Roof
  97.    glBegin(GL_TRIANGLES);
  98. //Triangle
  99.      glVertex3f(13, 50, 0.0f);
  100.      glVertex3f(52, 50, 0.0f);
  101.      glVertex3f(32.5f, 65, 0.0f);
  102.  
  103.     glColor3f(0.0f, 1.0f, 0.0f);//Green
  104.  
  105.      glVertex3f(69, 49, 0.0f);
  106.      glVertex3f(83, 49, 0.0f);
  107.      glVertex3f(76, 55, 0.0f);
  108.  
  109.      glVertex3f(69, 53, 0.0f);
  110.      glVertex3f(83, 53, 0.0f);
  111.      glVertex3f(76, 60, 0.0f);
  112.  
  113.      glVertex3f(69, 57, 0.0f);
  114.      glVertex3f(83, 57, 0.0f);
  115.      glVertex3f(76, 67, 0.0f);
  116.  
  117.      glVertex3f(79, 42, 0.0f);
  118.      glVertex3f(93, 42, 0.0f);
  119.      glVertex3f(86, 50, 0.0f);
  120.  
  121.      glVertex3f(79, 46, 0.0f);
  122.      glVertex3f(93, 46, 0.0f);
  123.      glVertex3f(86, 55, 0.0f);
  124.  
  125.      glVertex3f(79, 50, 0.0f);
  126.      glVertex3f(93, 50, 0.0f);
  127.      glVertex3f(86, 60, 0.0f);
  128. glEnd();
  129.  
  130.  
  131.  
  132. /*  don't wait!
  133.  *  start processing buffered OpenGL routines
  134.  */
  135.     glFlush ();
  136. }
  137.  
  138. void init (void)
  139. {
  140. /*  select clearing (background) color       */
  141.     glClearColor (0.0, 0.0, 0.0, 0.0);
  142.  
  143. /*  initialize viewing values  */
  144.     glMatrixMode(GL_PROJECTION);
  145.     glLoadIdentity();
  146.     glOrtho(0.0, 100, 0.0, 100, -1.0, 1.0);
  147. }
  148.  
  149. /*
  150.  *  Declare initial window size, position, and display mode
  151.  *  (single buffer and RGBA).  Open window with "hello"
  152.  *  in its title bar.  Call initialization routines.
  153.  *  Register callback function to display graphics.
  154.  *  Enter main loop and process events.
  155.  */
  156. int main(int argc, char** argv)
  157. {
  158.     glutInit(&argc, argv);
  159.     glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  160.     glutInitWindowSize (600, 500);
  161.     glutInitWindowPosition (75,75);
  162.     glutCreateWindow ("Fist Lab Task");
  163.     init ();
  164.     glutDisplayFunc(display);
  165.     glutMainLoop();
  166.     return 0;   /* ISO C requires main to return int. */
  167. }
  168.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement