Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- void RenderScene(void) {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1.0f, 0.0f, 0.0f);
- glRectf(-25.0f, 25.0f, 25.0f, -25.0f);
- glFlush();
- }
- void ColorSceneInit(void) {
- glClearColor(0.5f, 0.25f, 1.0f, 0.0f);
- }
- void ResizeWindow(GLsizei w, GLsizei h) {
- GLfloat ratio;
- if (h == 0) h = 1;
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- ratio = (GLfloat) w / (GLfloat) h;
- if (w <= h) {
- glOrtho(-100.0, 100.0, -100/ratio, 100.0/ratio, 1.0, -1.0);
- } else {
- glOrtho(-100.0 * ratio, 100.0 * ratio, -100.0, 100.0, 1.0, -1.0);
- }
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- void main(int argcp, char **argv) {
- glutInit(&argcp, argv);
- glutInitWindowSize(640, 480);
- glutInitWindowPosition(0, 0);
- glutCreateWindow("OpenGL Application");
- glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
- glutDisplayFunc(RenderScene);
- glutReshapeFunc(ResizeWindow);
- ColorSceneInit();
- glutMainLoop();
- }
Add Comment
Please, Sign In to add comment