Advertisement
Guest User

OpenGL Lesson 1

a guest
Jan 4th, 2011
19,426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #if defined(linux) || defined(_WIN32)
  2. #include <GL/glut.h>    /*Для Linux и Windows*/
  3. #else
  4. #include <GLUT/GLUT.h>  /*Для Mac OS*/
  5. #endif
  6.  
  7. void reshape(int w, int h)
  8. {
  9.     glViewport(0, 0, w, h);
  10.    
  11.     glMatrixMode(GL_PROJECTION);
  12.     glLoadIdentity();
  13.     gluOrtho2D(0, w, 0, h);
  14.    
  15.     glMatrixMode(GL_MODELVIEW);
  16.     glLoadIdentity();
  17. }
  18.  
  19. void display()
  20. {
  21.     glClear(GL_COLOR_BUFFER_BIT);
  22.    
  23.     glBegin(GL_QUADS);
  24.     glColor3f(1.0, 1.0, 1.0);
  25.     glVertex2i(250, 450);
  26.     glColor3f(0.0, 0.0, 1.0);
  27.     glVertex2i(250, 150);
  28.     glColor3f(0.0, 1.0, 0.0);
  29.     glVertex2i(550, 150);
  30.     glColor3f(1.0, 0.0, 0.0);
  31.     glVertex2i(550, 450);
  32.     glEnd();
  33.    
  34.     glutSwapBuffers();
  35. }
  36.  
  37. int main (int argc, char * argv[])
  38. {
  39.     glutInit(&argc, argv);
  40.     glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
  41.    
  42.     glutInitWindowSize(800, 600);
  43.     glutCreateWindow("OpenGL lesson 1");
  44.    
  45.     glutReshapeFunc(reshape);
  46.     glutDisplayFunc(display);
  47.    
  48.     glutMainLoop();
  49.    
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement