Advertisement
rana1704

Rectangular draw

Dec 1st, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/glut.h>
  2.  
  3. void init2D(float r, float g, float b)
  4. {
  5.     glClearColor(r,g,b,0.0);  
  6.     glMatrixMode (GL_PROJECTION);
  7.     gluOrtho2D (0.0, 200.0, 0.0, 150.0);
  8. }
  9.  
  10. void display(void)
  11. {
  12.     glClear(GL_COLOR_BUFFER_BIT);
  13.     glColor3f(0.0,50.0,0.0);
  14.     glLineWidth(5);
  15.  
  16.     glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  17.  
  18.     glBegin(GL_POLYGON);
  19.         glVertex2i(50,90);
  20.         glVertex2i(100,90);
  21.         glVertex2i(100,140);
  22.         glVertex2i(50,140);
  23.     glEnd();
  24.  
  25.     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  26.  
  27.     glFlush();  
  28. }
  29. //////////////////////////////////////////////////////////////////////////////////////
  30. void main(int argc,char *argv[])
  31. {
  32.     glutInit(&argc,argv);
  33.     glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  34.     glutInitWindowSize (500, 500);
  35.     glutInitWindowPosition (100, 100);
  36.     glutCreateWindow ("points and lines");
  37.     init2D(0.0,0.0,0.0);
  38.     glutDisplayFunc(display);
  39.     glutMainLoop();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement