Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #ifdef __APPLE__
- #include <GLUT/glut.h>
- #else
- #include <GL/glut.h>
- #endif
- void RenderScene(void) {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1.0f, 0.0f, 0.0f);
- //dziewiecokat
- glBegin(GL_TRIANGLE_FAN);
- glVertex2f(0.0, 0.0);
- glVertex2f(-25.0, -25.0);
- glVertex2f(25.0, -25.0);
- glVertex2f(0.0, 0.0);
- glVertex2f(-25.0, -25.0);
- glVertex2f(-27.5, -12.5);
- glEnd();
- glFlush();
- }
- void SetupRC(void) {
- glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
- }
- void ChangeSize(int w, int h) {
- GLfloat aspectRatio;
- if (h == 0) h = 1;
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- aspectRatio = (GLfloat)w / (GLfloat)h;
- if (w <= h) glOrtho(-100.0, 100.0, -100 / aspectRatio, 100.0 / aspectRatio, 1.0, -1.0);
- else glOrtho(-100.0 * aspectRatio, 100.0 * aspectRatio, -100.0, 100.0, 1.0, -1.0);
- glMatrixMode(GL_MODELVIEW); glLoadIdentity();
- }
- int main(int argc, char* argv[]) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(800, 600);
- glutCreateWindow("GLRect");
- glutDisplayFunc(RenderScene);
- glutReshapeFunc(ChangeSize);
- SetupRC();
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement