# 3D clipping & gluPerspective()

• 02-20-2003
Perspective
3D clipping & gluPerspective()
i am a little confused about 3D clipping using gluPerspective(). from what ive read, i thought that anything out side of the viewable 'perspective' should not be rendered (ie. no projection calculations done). but i did a little test and i dont think this is the case...

i added 50 high poly models to an area of the scene. when looking at them (they are inside viewable frustum) the program was slow and choppy as excpected. When i turned the camera away from them (no longer in the viewable perspective/frustum) the program was still slow and choppy which implies rendering calculations are still being done for these non-viewable objects.

my question is: do i have to manually calculate what is viewable and only draw/render that? or can openGL (gluPerspective) do this for me. if it can do the 3D clipping for me, what am i doing wrong??

this is how i set up my perspective...
Code:

`gluPerspective(55.0f,(GLfloat)width/(GLfloat)height,0.1f,50.0f);`
• 02-20-2003
MrWizard
Isn't the first parameter FOV in Radians?
• 02-20-2003
Perspective
• 02-20-2003
SAMSAM
FOV is in degrees.

but why most of the math functions in C math lib are in radiant,

like sin() cos() tan()

does it serve a purpose?
• 02-20-2003
Calculations are done on everything that you tell OpenGL to render, but only the things that are inside the frustum get put to the screen. In order to skip calculations of things that are outisde the frustum you have to manually do a lot of crazy math to determine if it lies in front or behind the planes that make up the view frustum. Depending on what you are working with you will typically have the world partitioned into segments (poly knows all about this he did a binary space partitioner) and you first determine what segment (read: sector) you are in, then you check all of the polygon data in that sector (and all the sectors that are visible from that sector) to determine if they are within the frustum or not.

EDIT:
SAMSAM I have no clue why degrees are used anywhere, radians make more sense. My math teacher (he's a really old guy btw) threatens to beat us up whenever we mention degrees instead of radians. I would also like to know why glRotatef uses degrees instead of radians, I mean come on radians are rotations. I would bet money that OpenGL only does that because people are more comfortable with degrees, that you pass in a degree measure but opengl converts it to radians and then performs the necessary operations.
• 02-21-2003
Perspective
hmmmm... space partitioning sounds like alot of work. i think im just gonna keep 5 plane equations (ie. the frustum) and check world coordinates to see if objects are inside the viewable region or not. thanx for the help!
• 02-21-2003