Advertisement
T1G3R7

Untitled

Nov 5th, 2020
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <gl/glut.h>
  2. void Draw()
  3. { float s[6][2];
  4.   s[0][0]=-0.3; s[0][1]=-0.2; /* initialize Matrix */
  5.     s[1][0]=0.3; s[1][1]=-0.2;
  6.     s[2][0]=0.3; s[2][1]=0.0;
  7.     s[3][0]=-0.3; s[3][1]=0.0;
  8.     s[4][0]=-0.3; s[4][1]=0.2;
  9.     s[5][0]=0.3; s[5][1]=0.2;
  10. int nrPoints=6;
  11. glClear(GL_COLOR_BUFFER_BIT);
  12. glColor3f(1.0, 0.0, 0.0);
  13. glBegin(GL_LINES);
  14.     for(int i=0;i<nrPoints-1;i++){
  15.       glVertex2f(s[i][0],s[i][1]);
  16.       glVertex2f(s[i+1][0],s[i+1][1]);
  17.     }
  18.     glEnd();
  19.       glFlush();
  20. }
  21. void Initialize()
  22. {
  23.   glClearColor(0.0, 0.0, 0.0, 0.0);
  24.   glMatrixMode(GL_PROJECTION);
  25.   glLoadIdentity();
  26.   glOrtho(1.0, 1.0, 0.0, 1.0, -1.0, 1.0);
  27. }
  28. int main(int iArgc, char** cppArgv)
  29. {
  30.   glutInit(&iArgc, cppArgv);
  31.   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  32.   glutInitWindowSize(200, 200);
  33.   glutInitWindowPosition(200, 200);
  34.   glutCreateWindow("UIST Line");
  35.   Initialize();
  36.   glutDisplayFunc(Draw);
  37.   glutMainLoop();
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement