Export (0) Print
Expand All
Expand Minimize

glFrustum function

Applies to: desktop apps only

The glFrustum function multiplies the current matrix by a perspective matrix.

Syntax

void WINAPI glFrustum(
  GLdouble left,
  GLdouble right,
  GLdouble bottom,
  GLdouble top,
  GLdouble zNear,
  GLdouble zFar
);

Parameters

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.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

NameMeaning
GL_INVALID_ENUM

zNear or zFar was not postitive.

GL_INVALID_OPERATION

The function was called between a call to glBegin and the corresponding call to glEnd.

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.

Dd373537.frust01(en-us,VS.85).pngDd373537.frust02(en-us,VS.85).png

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

Dd373537.frust03(en-us,VS.85).png

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

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Gl.h

Library

Opengl32.lib

DLL

Opengl32.dll

See also

glBegin
glEnd
glGet
glMatrixMode
glMultMatrix
glOrtho
glPopMatrix
glPushMatrix
glViewport

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft