I created a rectangle with four 2D-vertices using glVertex2D. If i put a glRotatef-command before glBegin(GL_QUADS), the rectangle gets rotated but does not keep its aspect ratio (only if my window is a square…).
Settings the perspective the following way…
The OpenGL defaults for modelview and projection matrices is the identity. An identity in the projection matrix is an orthographic projection of the unit cube with radius 1.0 around the origin. (Check the math in the OpenGL Programming Guide appendix F).
When your window is square, the OpenGL projection maps to square pixels.
What you need is to setup the glOrtho to have the aspect ratio of the window.
Looks like this in GLUT
void reshape(int w, int h)
GLdouble aspectRatio = 1.0;
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
if (w > 0 && h > 0)
aspectRatio = (GLdouble) w / (GLdouble) h;
glOrtho(-aspectRatio, aspectRatio, -1.0, 1.0, -1.0, 1.0);
int main(int argc, char** argv)