OGL3.1 - Resize that stays in shape

Ugh - been beating my brains out on this one for better part of a day. Could really use a guiding hand. :frowning:

OpenGL 3.1, Win7 x64, GLEW, no GLUT/etc.

Most guides will tell you when handing a resize event, to use:
glViewport(0, 0, width, height);
and then recalculate your perspective matrix for the shader, or use:
gluPerspective(45.0f,width/height, 0.1f, 100.0f);
(I’ve tried both)

But when you resize, you get the squash/stretch effect:

(Squished!)

However, what I want is for the cubes to stay in their original perspective/not be squished stretched when the window resizes.
Cubes don’t squish.

I know it can be done, I have code in a freeGLUT project that does it (it uses the two lines I had above); but in tracing through the code, I believe I’m doing everything it’s doing but I still get the squish effect.

Anyone got a light they can shine on this one? Do I need a different perspective/projection matrix?

It looks like aspect (the second parameter of gluPerspective()) is constant in your application, or at least changes in steps.
Try this:

gluPerspective(45.0f,(float)width/(float)height, 0.1f, 100.0f);

Ugh - lordy - I figured it out.

My calculations and everything were correct, but I was updating the projection matrix constant buffer on the wrong shader. I had a previous shader still bound from a render pass. I bound the right shader and the problem went away and projection is perfect.