glFrustum

Definition: include pGUI.e
include opengl.e

glFrustum(atom left, right, top, bottom, zNear, zFar)
Description: The glFrustum function multiplies the current matrix by a perspective matrix.

left: The coordinate for the left-vertical clipping plane.
right: The coordinate for the right-vertical clipping plane.
bottom: The coordinate for the bottom-horizontal clipping plane.
top: The coordinate for the bottom-horizontal clipping plane.
zNear: The distances to the near-depth clipping plane. Must be positive.
zFar: The distances to the far-depth clipping planes. Must be positive.

If zNear or zFar was not postitive, glGetError() will return GL_INVALID_ENUM. If glFrustum is called between glBegin and glEnd, glGetError() will return GL_INVALID_OPERATION.
Remarks The glFrustum function describes a perspective matrix that produces a perspective projection.
The (left, bottom, zNear) and (right, top, zNear) parameters specify the points on the near clipping plane that are mapped to the lower-left and upper-right corners of the window, respectively, assuming that the eye is located at (0,0,0).
The zFar parameter specifies the location of the far clipping plane.
Both zNear and zFar must be positive.
The corresponding matrix is shown in the following image.



The glFrustum function multiplies the current matrix by this matrix, with the result replacing the current matrix.
That is, if M is the current matrix and F is the frustum perspective matrix, then glFrustum replaces M with M • F.

Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.
Depth-buffer precision is affected by the values specified for zNear and zFar.
The greater the ratio of zFar to zNear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If



roughly log2 (r) bits of depth buffer precision are lost.
Because r approaches infinity as zNear approaches zero, you should never set zNear to zero.

The following functions retrieve information about glFrustum:
glGet with argument GL_MATRIX_MODE
glGet with argument GL_MODELVIEW_MATRIX
glGet with argument GL_PROJECTION_MATRIX
glGet with argument GL_TEXTURE_MATRIX
See Also: glBegin, glEnd, ?glEnd, glMatrixMode, ?glEnd, glPopMatrix, glPushMatrix, glViewport
DEV See also --glBegin --glEnd glGet --glMatrixMode glMultMatrix glOrtho --glPopMatrix --glPushMatrix --glViewport