PDA

View Full Version : reshape function using gluPerspective



cpl
02-04-2001, 07:29 PM
Hi,

I'm a newbie, playing with objects and the window-resizing function. I found that when using an orthographic projection, changing the x or y axis of the window resizes nicely. However, when I use a perspective projection, changing the length of the window along y will resize the object as with the other projection, but changing the size along x just recenters the object w/o taking into account the new aspect ratio.

I've found some demos that behave like this, but also some that don't... would like to have the perspective projection respond to resize on either axis...

Any thoughts?

Thanks for any hints!

void reshape(GLsizei w, GLsizei h)
{
float r;
if(h == 0) h = 1;
r = w/h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(60, r, 1, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}