Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include "stdafx.h"
  2. #ifdef __APPLE__
  3. #include <GLUT/glut.h>
  4. #else
  5. #include <GL/glut.h>
  6. #endif
  7.  
  8. void RenderScene(void) {
  9. glClear(GL_COLOR_BUFFER_BIT);
  10. glColor3f(1.0f, 0.0f, 0.0f);
  11. //dziewiecokat
  12. glBegin(GL_TRIANGLE_FAN);
  13. glVertex2f(0.0, 0.0);
  14. glVertex2f(-25.0, -25.0);
  15. glVertex2f(25.0, -25.0);
  16.  
  17. glVertex2f(0.0, 0.0);
  18. glVertex2f(-25.0, -25.0);
  19. glVertex2f(-27.5, -12.5);
  20. glEnd();
  21.  
  22. glFlush();
  23. }
  24.  
  25. void SetupRC(void) {
  26. glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
  27. }
  28.  
  29. void ChangeSize(int w, int h) {
  30. GLfloat aspectRatio;
  31. if (h == 0) h = 1;
  32. glViewport(0, 0, w, h);
  33. glMatrixMode(GL_PROJECTION);
  34. glLoadIdentity();
  35. aspectRatio = (GLfloat)w / (GLfloat)h;
  36. if (w <= h) glOrtho(-100.0, 100.0, -100 / aspectRatio, 100.0 / aspectRatio, 1.0, -1.0);
  37. else glOrtho(-100.0 * aspectRatio, 100.0 * aspectRatio, -100.0, 100.0, 1.0, -1.0);
  38. glMatrixMode(GL_MODELVIEW); glLoadIdentity();
  39. }
  40.  
  41. int main(int argc, char* argv[]) {
  42. glutInit(&argc, argv);
  43. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  44. glutInitWindowSize(800, 600);
  45. glutCreateWindow("GLRect");
  46. glutDisplayFunc(RenderScene);
  47. glutReshapeFunc(ChangeSize);
  48. SetupRC();
  49. glutMainLoop();
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement