View Full Version : gluPerspective and glFrustum
Im new to 3D programming/math and i can't really understand gluPerspective
I mean how do I know based on the parameters
what the coordinates at the far right, left, top, bottom will be it seems like I have no control, I tried to use glFrustum instead but when I created an object at the specified far right it ended up halfway there
i know this must sound stupid but i got no clue on how this works
thanks in advance
12-03-2001, 11:46 PM
hehe, don't worry I know exactly what you are going thru.
First and foremost I recommend getting the OpenGL Programming Guide. Its very easy to learn from and covers the different viewing volumns. Plus it tells you how to calculate the matrices for these volumns in the appendices.
In the mean time, gluPerspective and glFrustum create a parallelpiped viewing volumn. Just in case you dont remember what that is think of a pyramid with the top cut off. The near plane is the top of the modified pyramid and the far plane is the bottom, and the camera would be at where the top of the original pyramid was, looking down.
As your object gets farther away it becomes smaller and the width of your view volume increases. So if your near plane is x = -1 to +1, z = +1 and you draw a object at x = +1 z = +1 it will appear on the right side of the screen but as you move it close to the far plane it will not be on the right side of the screen anymore since the volume has increased in the x direction.
I hope that makes sense, sorry if I consfuse you more.
Thanks for the help.
I have now read some on glFurstum and gluPerspective but im still missing something
im calculating the Furstum like gluPerspective does:
ymax = zNear * tan(fovy)
ymin = -ymax
xmin = ymin * aspect
xmax = ymax * aspect
now lets say:
fovy = 45
aspect = 4/3
zNear = 1
then i get:
glFrustum(-1.3, 1.3, -1, 1, 1, 100)
now when i check to see if an object has an X value greater then 1.3 and if so place it at 1.3 it still just get stuck somwhere on the way to the far right of the screen
what is it im missing here??
thanks in advance
12-18-2001, 08:13 PM
You don't say what the Z value is and that affects where it shows up on the screen.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.