MoistGorilla

Untitled

Apr 25th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. #include <GL/glut.h>
  2. #include <GL/freeglut.h>
  3. #include <GL/gl.h>
  4.  
  5.  
  6.  
  7. void display(void)
  8. {
  9.     /* Clear all pixels */
  10.     glClear(GL_COLOR_BUFFER_BIT);
  11.  
  12.     /*  draw white polygon (rectangle) with
  13.      *  corners at (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
  14.      */
  15.  
  16.     glColor3f(1.0, 1.0, 1.0);
  17.     glBegin(GL_POLYGON);
  18.         glVertex3f(0.25, 0.25, 0.0);
  19.         glVertex3f(0.75, 0.25, 0.0);
  20.         glVertex3f(0.75, 0.75, 0.0);
  21.         glVertex3f(0.25, 0.75, 0.0);
  22.     glEnd();
  23.  
  24.     /*  don't wait!
  25.      *  start processing buffered OpenGL routines
  26.      */
  27.  
  28.         glFlush();
  29. }
  30.  
  31. void init(void)
  32. {
  33.     /* Select clearing background color */
  34.     glClearColor(0.0, 0.0, 0.0, 0.0);
  35.  
  36.     /* Initialize viewing values */
  37.     glMatrixMode(GL_PROJECTION);
  38.     glLoadIdentity();
  39.     glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
  40. }
  41.  
  42.  
  43. /*
  44. * Declare initial window size, position, and display mode
  45. * (single buffer and RGBA). Open window with “hello”
  46. * in its title bar. Call initialization routines.
  47. * Register callback function to display graphics.
  48. * Enter main loop and process events.
  49. */
  50. int main(int argc, char** argv)
  51. {
  52.     glutInit(&argc, argv);
  53.     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  54.     glutInitWindowSize(250, 250);
  55.     glutInitWindowPosition(100, 100);
  56.     glutCreateWindow("hello");
  57.     init();
  58.     glutDisplayFunc(display);
  59.     glutMainLoop();
  60.     return 0; /* ISO C requires main to return int. */
  61. }
Advertisement
Add Comment
Please, Sign In to add comment