Contents / Previous / Next


Perspective Projection

The farther an object is from the camera, the smaller it appears in the final image.
This occurs because the viewing volume for a perspective projection is a frustum of a pyramid (a truncated pyramid whose top has been cut off by a plane parallel to its base).

Objects that fall within the viewing volume are projected toward the apex of the pyramid, where the camera or viewpoint is. Objects that are closer to the viewpoint appear larger because they occupy a proportionally larger amount of the viewing volume than those that are farther away.

The command to define a frustum, glFrustum(), calculates a matrix that accomplishes perspective projection and multiplies the current projection matrix (typically the identity matrix) by it.

Recall that the viewing volume is used to clip objects that lie outside of it; the four sides of the frustum, its top, and its base correspond to the six clipping planes of the viewing volume.

  void glFrustum(GLdouble left, GLdouble right, 
                 GLdouble bottom, GLdouble top, 
		 GLdouble near, GLdouble far);
Creates a matrix for a perspective-view frustum and multiplies the current matrix by it. The frustum's viewing volume is defined by the parameters: (left, bottom, -near) and (right, top, -near) specify the (x, y, z) coordinates of the lower-left and upper-right corners of the near clipping plane; near and far give the distances from the viewpoint to the near and far clipping planes. They should always be positive.

glFrustum() does not require you to define a symmetric viewing volume.


The call glFrustum(l, r, b, t, n, f ) generates R, where:



R is defined as long as l not equal to r, t not equal to b, and n not equal to f.



The gluPerspective() routine creates a viewing volume of the same shape as glFrustum() does, but you specify it in a different way.

Rather than specifying corners of the near clipping plane, you specify the angle of the field of view (fovy=theta) in the y direction and the aspect ratio of the width to height (x/y). (For a square portion of the screen, the aspect ratio is 1.0.) These two parameters are enough to determine an untruncated pyramid along the line of sight.

You also specify the distance between the viewpoint and the near and far clipping planes, thereby truncating the pyramid.

  void gluPerspective( GLdouble fovy, GLdouble aspect,
                       GLdouble near, GLdouble far );

fovy, the angle of the field of view in the x-z plane must be in the range [0.0,180.0].
aspect is the aspect ratio of the frustum, its width divided by its height.
near and far values the distances between the viewpoint and the clipping planes, along the negative z-axis.
They should always be positive.

Note that gluPerspective() is limited to creating frustums that are symmetric in both the x- and y-axes along the line of sight, but this is usually what you want.