PDA

View Full Version : Resize display and keeping aspect ratio....



nexusone
04-04-2002, 06:08 AM
Under glut how can I enforce that when a window is reshaped that it keep's the aspect ratio of my scene?

Also is there a way to lock a windows size under glut?

endo
04-04-2002, 06:15 AM
I asked a similar question a couple of months ago. You can't lock the window size (at least not easily I believe) and I am still having trouble maintaining the aspect ratio.

I'll be interested to see if you get any better answers...

nexusone
04-04-2002, 06:43 AM
I did this and it works!!!!
With a little more work, I think the aspect also can be managed this way also.

void reshape (int w, int h)
{
if (( w != 500 ) | | ( h != 250 )) The fix size that I want.
{
glutReshapeWindow( 500, 250); Return window to my size.
w = 500; // for processing the rest of my reshape routine.
h = 250;
}
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho(0.0f, (GLfloat) w,(GLfloat) h, 0.0f,-10.0f,10.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
}

http://www.opengl.org/discussion_boards/ubb/smile.gif


Originally posted by endo:
I asked a similar question a couple of months ago. You can't lock the window size (at least not easily I believe) and I am still having trouble maintaining the aspect ratio.

I'll be interested to see if you get any better answers...



[This message has been edited by nexusone (edited 04-04-2002).]