Advertisement
axyd

lab_8

Mar 14th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <GL/glut.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. void display(void)
  6. {
  7.     glClear(GL_COLOR_BUFFER_BIT);   //flush gl
  8. //  glColor3f(1.0, 0.0, 0.0);       //red
  9.  
  10.     //hexagon
  11.     glBegin(GL_POLYGON);
  12.             glColor3f(1.0, 0.0, 0.0);       //red
  13.         glVertex2i(40,80);      //left
  14.         glVertex2i(80,120);     //LT
  15.             glColor3f(0.0, 1.0, 0.0);       //green
  16.         glVertex2i(160,120);    //RT
  17.         glVertex2i(200,80); //Right
  18.             glColor3f(0.0, 0.0, 1.0);       //blue
  19.         glVertex2i(160,40);     //RB
  20.         glVertex2i(80,40);      //RL
  21.     glEnd();
  22.    
  23.    
  24.  
  25.     glFlush();  //force immidiate display
  26. }
  27.  
  28. int main(int argc,char *argv[])
  29. {
  30.     glutInit(&argc,argv);                   //prepare glut
  31.     glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);       //set the display mode
  32.     glutInitWindowSize (500, 500);          //the size of the program window
  33.     glutInitWindowPosition (100, 100);      //initial position for the window
  34.     glutCreateWindow ("points and lines");  //create window with a title
  35.    
  36.     glClearColor(255,255,255,0.0);          //background color
  37.     glMatrixMode (GL_PROJECTION);           //2d envyronment
  38.     gluOrtho2D (40.0, 200.0, 40.0, 120.0);  //matrix dimensions
  39.    
  40.     glutDisplayFunc(display);               //show thee actual program
  41.     glutMainLoop();
  42.    
  43.     return EXIT_SUCCESS;                    //exit the program
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement