void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
left, right | Specify the coordinates for the left and right vertical clipping planes. |
bottom, top | Specify the coordinates for the bottom and top horizontal clipping planes. |
zNear, zFar | Specify the distances to the near and far depth clipping planes. Both distances must be positive. |
| | (2 * zNear) / (right - left | 0 | A | 0 | | |
| | 0 | (2 * zNear) / (top - bottom) | B | 0 | | |
| | 0 | 0 | C | D | | |
| | 0 | 0 | -1 | 0 | | |
A = (right + left) / (right - left)
B = (top + bottom) / (top - bottom)
C = -(zFar + zNear) / (zFar - zNear)
D = (-2 * zFar * zNear) / (zFar - zNear)
Typically, the matrix mode is GL_PROJECTION, and (left,
bottom, -zNear) and (right, top, -zNear)
specify the points on the near clipping plane that are mapped to the lower
left and upper right corners of the window, assuming that the eye
is located at
Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.
r = zFar / zNear
roughly log2r bits of depth buffer precision are lost. Because r approaches infinity as zNear approaches 0, zNear must never be set to 0.
GL_INVALID_OPERATION is generated if glFrustum is executed between the execution of glBegin and the corresponding execution of glEnd.