imtiazaasif

GL line

Jun 18th, 2022
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <GL/gl.h>
  2. #include <GL/glut.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. void display(void)
  7. {
  8.  
  9.     glClear(GL_COLOR_BUFFER_BIT);
  10.     glBegin(GL_LINES);
  11.     glColor3f(0.0, 1.0, 1.0);
  12.     glVertex2f(10, 10);
  13.     glVertex2f(40, 20);
  14.     glEnd();
  15.  
  16.     glutSwapBuffers();
  17. }
  18.  
  19. void init(void)
  20. {
  21.  
  22.     glClearColor(0.0, 0.0, 0.0, 0.0); /* select clearing (background) color */
  23.     glMatrixMode(GL_PROJECTION);      /* initialize viewing values */
  24.     glLoadIdentity();
  25.     glOrtho(0.0, 200.0, 0.0, 200.0, -200.0, 200.0);
  26. }
  27.  
  28. int main(int argc, char **argv)
  29. {
  30.  
  31.     glutInit(&argc, argv);
  32.     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  33.     glutInitWindowSize(300, 300);
  34.     glutInitWindowPosition(100, 100);
  35.     glutCreateWindow("hello");
  36.     init();
  37.     glutDisplayFunc(display);
  38.     glutMainLoop();
  39.     return 0; /* ISO C requires main to return int. */
  40. }
Advertisement
Add Comment
Please, Sign In to add comment