Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1.  
  2. #include <GL/gl.h>
  3. #include <GL/glut.h>
  4. void display(void)
  5. {
  6. /* clear all pixels */
  7. glClear (GL_COLOR_BUFFER_BIT);
  8. /* draw white polygon (rectangle) with corners at
  9. * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
  10. */
  11. glColor3d (1,1,1);
  12. glBegin(GL_POLYGON);
  13. glVertex2d(200,260);
  14. glVertex2d(266,400);
  15. glVertex2d(246,440);
  16. glVertex2d(180,300);
  17. glEnd();
  18.  
  19. glColor3d (1,1,1);
  20. glBegin(GL_POLYGON);
  21. glVertex2d(260,300);
  22. glVertex2d(300,360);
  23. glVertex2d(340,365);
  24. glVertex2d(350,400);
  25. glVertex2d(276,400);
  26. glVertex2d(210,260);
  27. glVertex2d(300,260);
  28.  
  29. glEnd();
  30.  
  31. glColor3d (1,1,1);
  32. glBegin(GL_POLYGON);
  33. glVertex2d(276,410);
  34. glVertex2d(350,410);
  35. glVertex2d(330,450);
  36. glVertex2d(256,450);
  37. glEnd();
  38. /* don't wait!
  39. * start processing buffered OpenGL routines
  40. */
  41. glFlush ();
  42. }
  43. void init (void)
  44. {
  45. /* select clearing (background) color */
  46. glClearColor (0.0, 0.0, 0.0, 0.0);
  47. /* initialize viewing values */
  48. glMatrixMode(GL_PROJECTION);
  49. glLoadIdentity();
  50. gluOrtho2D(0,700,0,700);
  51. }
  52. /*
  53. * Declare initial window size, position, and display mode
  54. * (single buffer and RGBA). Open window with "hello"
  55. * in its title bar. Call initialization routines.
  56. * Register callback function to display graphics.
  57. * Enter main loop and process events.
  58. */
  59. int main(int argc, char** argv)
  60. {
  61. glutInit(&argc, argv);
  62. glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  63. glutInitWindowSize (500, 500);
  64. glutInitWindowPosition (100, 100);
  65. glutCreateWindow ("hello");
  66. init ();
  67. glutDisplayFunc(display);
  68. glutMainLoop();
  69. return 0; /* ISO C requires main to return int. */
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement