NAME

gluPerspective - set up a perspective projection matrix

C SPECIFICATION

void gglluuPPeerrssppeeccttiivvee( GLdouble _f_o_v_y,
                     GLdouble _a_s_p_e_c_t,
                     GLdouble _z_N_e_a_r,
                     GLdouble _z_F_a_r )

delim $$

PARAMETERS

_f_o_v_y
Specifies the field of view angle, in degrees, in the _y direction.
_a_s_p_e_c_t
Specifies the aspect ratio that determines the field of view in the _x direction. The aspect ratio is the ratio of _x (width) to _y (height).
_z_N_e_a_r
Specifies the distance from the viewer to the near clipping plane (always positive).
_z_F_a_r
Specifies the distance from the viewer to the far clipping plane (always positive).

DESCRIPTION

gglluuPPeerrssppeeccttiivvee specifies a viewing frustum into the world coordinate system. In general, the aspect ratio in gglluuPPeerrssppeeccttiivvee should match the aspect ratio of the associated viewport. For example, $ "aspect" ~=~ 2.0 $ means the viewer's angle of view is twice as wide in _x as it is in _y. If the viewport is twice as wide as it is tall, it displays the image without distortion.

The matrix generated by gglluuPPeerrssppeeccttiivvee is multiplied by the current matrix, just as if ggllMMuullttMMaattrriixx were called with the generated matrix. To load the perspective matrix onto the current matrix stack instead, precede the call to gglluuPPeerrssppeeccttiivvee with a call to ggllLLooaaddIIddeennttiittyy.

Given _f defined as follows:

f ~=~ cotangent"("{"fovy" over 2}")" The generated matrix is

left ( ~~ down 130 { matrix { ccol { {f over "aspect"} above 0 above 0 above 0 } ccol { 0 above f above 0 above 0 } ccol { 0 above 0 above {{"zFar" + "zNear"} over {"zNear" - "zFar"}} above -1 } ccol { 0 above 0 above {{2 * "zFar" * "zNear"} over {"zNear" - "zFar"}} above 0} }} ~~~ right )

NOTES

Depth buffer precision is affected by the values specified for _z_N_e_a_r and _z_F_a_r. The greater the ratio of _z_F_a_r to _z_N_e_a_r is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If

$r ~=~ "zFar" over "zNear"$

roughly $log sub 2 r$ bits of depth buffer precision are lost. Because $r$ approaches infinity as _z_N_e_a_r approaches 0, _z_N_e_a_r must never be set to 0.

SEE ALSO

ggllFFrruussttuumm((33GG)), ggllLLooaaddIIddeennttiittyy((33GG)), ggllMMuullttMMaattrriixx((33GG)), gglluuOOrrtthhoo22DD((33GG))