mattropolis
04-29-2011, 10:54 AM
Ugh - been beating my brains out on this one for better part of a day. Could really use a guiding hand. :(
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:
http://mattfife.net/special/ogl/1.jpg
http://mattfife.net/special/ogl/2.jpg (Squished!)
However, what I want is for the cubes to stay in their original perspective/not be squished stretched when the window resizes.
http://mattfife.net/special/ogl/3.jpg 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?
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:
http://mattfife.net/special/ogl/1.jpg
http://mattfife.net/special/ogl/2.jpg (Squished!)
However, what I want is for the cubes to stay in their original perspective/not be squished stretched when the window resizes.
http://mattfife.net/special/ogl/3.jpg 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?