Advertisement
NB52053

GRAPHICS_LAB_#3

Feb 17th, 2019
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.95 KB | None | 0 0
  1. #include<windows.h>
  2. #include <GL/glut.h>
  3. #include <stdlib.h>
  4.  
  5. void init()
  6. {
  7.     glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
  8.     glOrtho(-15,10,-5,10,-5,5);
  9. }
  10. void myDisplay()
  11. {
  12.     glClear(GL_COLOR_BUFFER_BIT);
  13.  
  14.     glColor3f(0.0f, 1.0f, 0.0f);
  15.  
  16.      glColor3f(1.0f, 0.0f, 0.0f);
  17.  
  18.  
  19.     glColor3f(0.0f, 0.0f, 1.0f);
  20.  
  21.  
  22.     /*glBegin(GL_QUADS); // DRAWING 4 SIDED QUADRILATERAL
  23.          glVertex2d(-2.0,-4.0);
  24.          glVertex2d(4.0,-2.0);
  25.          glVertex2d(4.0,2.0);
  26.         glVertex2d(-2.0,4.0);
  27.     glEnd();*/
  28.  
  29.  
  30.     glBegin(GL_TRIANGLES); // DRAWING 3 SIDED TRIANGLE
  31.  
  32.         // Set 6
  33.         glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  34.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(6,0); //2nd
  35.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,2);  // 1st
  36.  
  37.  
  38.  
  39.          glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  40.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(-6,0); //2nd
  41.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,2);  // 1st
  42.  
  43.  
  44.  
  45.  
  46.     //------Set 5
  47.         glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  48.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(5,0); //2nd
  49.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,3);  // 1st
  50.  
  51.  
  52.           glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  53.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(-5,0); //2nd
  54.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,3);  // 1st
  55.  
  56.  
  57.  
  58.  
  59.  
  60.           //-----Set 4--------------------------------------------------------------
  61.          glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  62.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(4,0); //2nd
  63.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,5);  // 1st
  64.  
  65.  
  66.           glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  67.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(-4,0); //2nd
  68.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,5);  // 1st
  69.  
  70. //------Set 3---------------------------------------------------------------
  71.  
  72.          glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  73.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(3,0); //2nd
  74.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,7);  // 1st
  75.  
  76.  
  77.          glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  78.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(-3,0); //2nd
  79.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,7);  // 1st
  80.  
  81.           //-----Set 2-----------------------------------------------------
  82.          glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  83.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(2,0); //2nd
  84.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,8.7);  // 1st
  85.  
  86.  
  87.  
  88.         glColor3f(0.44f, 0.52f, 0.50f);   glVertex2d(0,0);  //3rd
  89.          glColor3f(1.0f, 1.0f, 1.0f);      glVertex2d(-2,0); //2nd
  90.          glColor3f(0.464f, 0.531f, 0.597f); glVertex2d(0,8.7);  // 1st
  91.  
  92. //-----SET 1------------------------------------------------------
  93.          glColor3f(0.44f, 0.52f, 0.50f); glVertex2d(0,1);  //3rd
  94.          glColor3f(1.0f, 1.0f, 1.0f); glVertex2d(1,0); //2nd
  95.          glColor3f(0.464f, 0.531f, 0.597f);   glVertex2d(0,10);  // 1st
  96.  
  97.  
  98.            glColor3f(0.44f, 0.52f, 0.50f); glVertex2d(0,1);  //3rd
  99.            glColor3f(0.464f, 0.531f, 0.597f);    glVertex2d(0,10);// 1st
  100.           glColor3f(1.0f, 1.0f, 1.0f); glVertex2d(-1,0); //2nd
  101. //----------------------------------------------------------------------------
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.     glEnd();
  113.  
  114.  
  115.      glBegin(GL_QUADS);
  116.  
  117.  
  118.       glVertex2d(0,1);  //3rd
  119.       glVertex2d(-10,0);// 1st
  120.       glVertex2d(5,-0); //2nd
  121.       glVertex2d(-10,-5);
  122.  
  123.     glEnd();
  124.  
  125.  
  126. */
  127.  
  128.  
  129.     glFlush();
  130. }
  131.  
  132. int main()
  133. {
  134.     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  135.     glutInitWindowSize(600, 450);
  136.     glutInitWindowPosition(100, 100);
  137.     glutCreateWindow("Raffid_011152053");
  138.     init();
  139.     glutDisplayFunc(myDisplay);
  140.     glutMainLoop();
  141.     return 0;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement