glOrtho vs. glFrustum

Started by
2 comments, last by nerdtron 14 years ago
My understanding is that with glOrtho, the near and far values are relative to the origin. I say this because the docs indicate that if near or far is negative then they're the behind you and if they're positive they're in front. So relative to the origin, you're specifying the distance and direction (+/-) to the near and far planes which define the viewing volume. The docs for glFrustum, however, indicate that both near and far must be positive. So where is the origin with glFrustum? Is the eye point at the origin and the viewing volume out in front? Or is it assumed that the near and far planes are centered about the origin? I'm leaning to the eye point being at the origin as it seems with the other way there'd be no way for the fov to be computed.
Advertisement
With glOrtho it is not important if clipping planes are in front of behind the origin (where the eye is) because it is not a perspective projection and projector rays are parallel.

glFrustum requires positive values for both clipping planes distances (those are distances from the eye), and the eye is at the origin (where projector rays intersect each other).
FYI, glOrtho creates an orthographic projection, hence the name. Like Ask9 said, the rays are parallel, unlike in a perspective projection.
so from what you're saying, then, with glFrustum, the eye is at the origin of the view coordinate system looking toward the near and then far planes which are placed at distances away from the eye. as opposed to glOrtho where you're just setting up planes all relative to the origin and including everything in that volume.

any advice on converting from glOrtho to glFrustum? I already have glOrtho setup and working and I'd like to include (roughly) the same size and objects in the view (I understand the viewing volume will be shaped differently), I just want the perspective effect so that objects farther away are smaller, etc.

I tried creating a frustum shaped viewing volume to match my ortho viewimg volume where the size in the xy plane (left,right,top,bottom) matched at the near plane in the frustum. So, given a fov, I compued the near and far planes such that the near plane would be the same size as the ortho viewing volume.

I end up getting everything looking too small.

This topic is closed to new replies.

Advertisement