Guest User

Untitled

a guest
Feb 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. void renderScene(void)
  2. {
  3. glClear(GL_COLOR_BUFFER_BIT);
  4.  
  5. glRectf(-25.0f,25.0f,25.0f,-25.0f);
  6.  
  7. glFlush();
  8. }
  9.  
  10. void changeSize(int w, int h)
  11. {
  12. if (h == 0)
  13. h=1;
  14. glViewport(0,0,w,h);
  15. glMatrixMode(GL_PROJECTION);
  16. glLoadIdentity();
  17. float ratio = w/h;
  18. if (w<=h)
  19. glOrtho (-100,100,-100/ratio, 100/ratio, 1,-1);
  20. else
  21. glOrtho (-100*ratio,100*ratio, -100,100,1,-1);
  22. glMatrixMode(GL_MODELVIEW);
  23. glLoadIdentity();
  24. }
  25.  
  26. int main (void)
  27. {
  28. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
  29. glutInitWindowPosition(100,100);
  30. glutInitWindowSize(500,500);
  31.  
  32. glutCreateWindow("he");
  33. glutDisplayFunc(renderScene);
  34. glutReshapeFunc(changeSize);
  35. glClearColor(0,0,1,1);
  36.  
  37. glutMainLoop();
  38.  
  39. return 0;
  40. }
Add Comment
Please, Sign In to add comment