PDA

View Full Version : How to fit an Object in a window ???



jerin3D
02-19-2002, 07:36 PM
Hi,

i want to display a 3D object to fit in a window.I know the co-ordinate of all the object.But when i displayed the object is smaller.How i can zoom the object initally to fit the window ?.How it possible...?

Thanks,
Jerry

kschroed
02-19-2002, 09:57 PM
You can either scale Your object with
glScale() to fit the window or You change the size of Your coordinate system. That means You'll have to call glOrtho() or manipulate the matrix in any other way.
The default window coordinates are allways
(-1,-1) to (1,1).
With this code below You transform Your window coordinates to exactly the pixel size of it ...


glViewport(0, 0, WinWidth, WinHeight);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, WinWidth, 0, WinHeight, -z, z);

glMatrixMode(GL_MODELVIEW);