Advertisement
Guest User

homedrowopengl

a guest
Apr 10th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.63 KB | None | 0 0
  1. /*
  2. Shamsuddin Ahmed
  3. 161-15-1027
  4.  
  5. Draw Home using lines
  6.  
  7. */
  8.  
  9.  
  10.  
  11.  
  12. #include<windows.h>
  13. #include <GL/glut.h>
  14.  
  15. void init(void)
  16. {
  17.     glClearColor(1.0, 1.0, 1.0, 0.0);   // Set display window colour to white
  18.  
  19.     glMatrixMode(GL_PROJECTION);        // Set projection parameters
  20.     gluOrtho2D(0.0, 400.0, 0.0, 400.0);
  21. }
  22.  
  23. void drawShapes(void)
  24. {
  25.     glClear(GL_COLOR_BUFFER_BIT);   // Clear display window
  26.  
  27.     //Set colour to black
  28.     glColor3f(0.0, 0.0, 0.0);
  29.     //Adjust the point size
  30.     glPointSize(5.0);
  31.  
  32.     //Set colour to red
  33.     glColor3f(1.0, 0.0, 0.0);
  34.  
  35.     // Draw an outlined triangle
  36.     glBegin(GL_LINES);
  37.  
  38.  
  39.         //Home shape Using Line
  40.         glVertex2i(40, 20); //A
  41.         glVertex2i(200, 20); //B
  42.  
  43.         glVertex2i(200, 20); //B
  44.         glVertex2i(200,120); //C
  45.  
  46.  
  47.         glVertex2i(200,120); //C
  48.         glVertex2i(40, 120); //D
  49.  
  50.         glVertex2i(40, 120); //D
  51.         glVertex2i(40, 20); //A
  52.         //Home shape End
  53.  
  54.         // Home roof start
  55.  
  56.         glVertex2i(40, 120); //D
  57.         glVertex2i(80, 160); //Q
  58.  
  59.         glVertex2i(80, 160); //Q
  60.         glVertex2i(160, 160); //R
  61.  
  62.         glVertex2i(160, 160); //R
  63.         glVertex2i(200,120); //C
  64.  
  65.         glVertex2i(200,120); //C
  66.         glVertex2i(40, 120); //D
  67.  
  68.  
  69.         //Home roof end
  70.  
  71.  
  72.         //Home Door Start
  73.  
  74.         glVertex2i(100, 20); //E
  75.         glVertex2i(100, 60); //F
  76.  
  77.         glVertex2i(100, 60); //F
  78.         glVertex2i(140, 60); //G
  79.  
  80.         glVertex2i(140, 60); //G
  81.         glVertex2i(140, 20); //H
  82.  
  83.         glVertex2i(140, 20); //H
  84.         glVertex2i(100, 20); //E
  85.  
  86.  
  87.         //Home Door End
  88.  
  89.         //Window Left start
  90.         glVertex2i(60, 80); //I
  91.         glVertex2i(80, 80); //J
  92.  
  93.         glVertex2i(80, 80); //J
  94.         glVertex2i(80, 60); //K
  95.  
  96.         glVertex2i(80, 60); //K
  97.         glVertex2i(60, 60); //L
  98.  
  99.         glVertex2i(60, 60); //L
  100.         glVertex2i(60, 80); //I
  101.  
  102.         //Window Left End
  103.  
  104.         //Window Right Start
  105.  
  106.         glVertex2i(160, 80); //M
  107.         glVertex2i(180, 80); //N
  108.  
  109.         glVertex2i(180, 80); //N
  110.         glVertex2i(180, 60); //O
  111.  
  112.         glVertex2i(180, 60); //O
  113.         glVertex2i(160, 60); //P
  114.  
  115.         glVertex2i(160, 60); //P
  116.         glVertex2i(160, 80); //M
  117.  
  118.         //Windows Right End
  119.  
  120.  
  121.     glEnd();
  122.  
  123.     glFlush();  // Process all OpenGL routines
  124. }
  125.  
  126. int main(int argc, char* argv[])
  127. {
  128.     glutInit(&argc, argv);                      // Initalise GLUT
  129.     glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);  // Set display mode
  130.  
  131.     glutInitWindowPosition(50, 100);                // Set window position
  132.     glutInitWindowSize(400, 300);                   // Set window size
  133.     glutCreateWindow("An Example OpenGL Program");  // Create display window
  134.  
  135.     init();                         // Execute initialisation procedure
  136.     glutDisplayFunc(drawShapes);        // Send graphics to display window
  137.     glutMainLoop();                 // Display everything and wait
  138.  
  139.     return 0;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement