#include "stdafx.h"
#include "glut.h"
#include "GL.h"
#include "GLAux.h"
#include "GLU.H"
void DisplayFunc();
void reshape(GLsizei w, GLsizei h);
void reshape(int w, int h)
{
if (h = 0) h=1;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
{
gluOrtho2D(0.0, 30.0 * (float)w / (float)h, 0.0, 30.0);
}
else
{
gluOrtho2D(0.0, 30.0 * (float)w / (float)h, 0.0, 30.0);
}
glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
}
void DisplayFunc()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 0.0f);
glRectf(0.0f, 0.0f, 25.0f, 25.0f);
glFlush();
}
int main (int argc, char * argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("OpenGL lesson 1");
glutReshapeFunc(reshape);
glutDisplayFunc(DisplayFunc);
glutMainLoop();
return 0;
}