1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd">
2 <!-- saved from url=(0013)about:internet -->
3 <?xml-stylesheet type=
"text/xsl" href=
"mathml.xsl"?><html xmlns=
"http://www.w3.org/1999/xhtml" xmlns:
pref=
"http://www.w3.org/2002/Math/preference" pref:
renderer=
"mathplayer-dl"><head><meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" /><title>gluPerspective
</title><meta name=
"generator" content=
"DocBook XSL Stylesheets V1.73.2" /></head><body><div class=
"refentry" lang=
"en" xml:
lang=
"en"><a id=
"gluPerspective"></a><div class=
"titlepage"></div><div class=
"refnamediv"><h2>Name
</h2><p>gluPerspective — set up a perspective projection matrix
</p></div><div class=
"refsynopsisdiv"><h2>C Specification
</h2><div class=
"funcsynopsis"><table border=
"0" summary=
"Function synopsis" cellspacing=
"0" cellpadding=
"0"><tr><td><code class=
"funcdef">void
<b class=
"fsfunc">gluPerspective
</b>(
</code></td><td>GLdouble
</td><td><var class=
"pdparam">fovy
</var>,
</td></tr><tr><td> </td><td>GLdouble
</td><td><var class=
"pdparam">aspect
</var>,
</td></tr><tr><td> </td><td>GLdouble
</td><td><var class=
"pdparam">zNear
</var>,
</td></tr><tr><td> </td><td>GLdouble
</td><td><var class=
"pdparam">zFar
</var><code>)
</code>;
</td></tr></table></div></div><div class=
"refsect1" lang=
"en" xml:
lang=
"en"><a id=
"parameters"></a><h2>Parameters
</h2><div class=
"variablelist"><dl><dt><span class=
"term"><em class=
"parameter"><code>fovy
</code></em></span></dt><dd><p>
4 Specifies the field of view angle, in degrees, in the
<span class=
"emphasis"><em>y
</em></span> direction.
5 </p></dd><dt><span class=
"term"><em class=
"parameter"><code>aspect
</code></em></span></dt><dd><p>
6 Specifies the aspect ratio that determines
7 the field of view in the
<span class=
"emphasis"><em>x
</em></span> direction.
8 The aspect ratio is the ratio of
<span class=
"emphasis"><em>x
</em></span> (width) to
<span class=
"emphasis"><em>y
</em></span> (height).
9 </p></dd><dt><span class=
"term"><em class=
"parameter"><code>zNear
</code></em></span></dt><dd><p>
10 Specifies the distance from the viewer to the near clipping plane
12 </p></dd><dt><span class=
"term"><em class=
"parameter"><code>zFar
</code></em></span></dt><dd><p>
13 Specifies the distance from the viewer to the far clipping plane
15 </p></dd></dl></div></div><div class=
"refsect1" lang=
"en" xml:
lang=
"en"><a id=
"description"></a><h2>Description
</h2><p>
16 <code class=
"function">gluPerspective
</code> specifies a viewing frustum into the world coordinate system.
17 In general, the aspect ratio in
<code class=
"function">gluPerspective
</code> should match the aspect ratio
18 of the associated viewport. For example,
19 <mml:math xmlns:
mml=
"http://www.w3.org/1998/Math/MathML" overflow=
"scroll">
22 <mml:mi mathvariant=
"italic">aspect
</mml:mi>
29 angle of view is twice as wide in
<span class=
"emphasis"><em>x
</em></span> as it is in
<span class=
"emphasis"><em>y
</em></span>.
31 twice as wide as it is tall, it displays the image without distortion.
33 The matrix generated by
<code class=
"function">gluPerspective
</code> is multipled by the current matrix,
34 just as if
<a class=
"citerefentry" href=
"glMultMatrix.xml"><span class=
"citerefentry"><span class=
"refentrytitle">glMultMatrix
</span></span></a> were called with the generated matrix.
35 To load the perspective matrix onto the current matrix stack instead,
36 precede the call to
<code class=
"function">gluPerspective
</code> with a call to
<a class=
"citerefentry" href=
"glLoadIdentity.xml"><span class=
"citerefentry"><span class=
"refentrytitle">glLoadIdentity
</span></span></a>.
38 Given
<span class=
"emphasis"><em>f
</em></span> defined as follows:
40 </p><div class=
"informalequation"><mml:math xmlns:
mml=
"http://www.w3.org/1998/Math/MathML" overflow=
"scroll">
43 <mml:mi mathvariant=
"italic">f
</mml:mi>
46 <mml:mi mathvariant=
"italic">cotangent
</mml:mi>
48 <mml:mfenced open=
"(" close=
")">
50 <mml:mi mathvariant=
"italic">fovy
</mml:mi>
57 The generated matrix is
59 </p><div class=
"informalequation"><mml:math xmlns:
mml=
"http://www.w3.org/1998/Math/MathML" overflow=
"scroll">
61 <mml:mfenced open=
"(" close=
")">
66 <mml:mi mathvariant=
"italic">f
</mml:mi>
67 <mml:mi mathvariant=
"italic">aspect
</mml:mi>
85 <mml:mi mathvariant=
"italic">f
</mml:mi>
103 <mml:mfenced open=
"" close=
"">
105 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
107 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
110 <mml:mfenced open=
"" close=
"">
112 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
114 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
121 <mml:mfenced open=
"" close=
"">
125 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
127 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
130 <mml:mfenced open=
"" close=
"">
132 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
134 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
157 </p></div><div class=
"refsect1" lang=
"en" xml:
lang=
"en"><a id=
"notes"></a><h2>Notes
</h2><p>
158 Depth buffer precision is affected by the values specified for
159 <em class=
"parameter"><code>zNear
</code></em> and
<em class=
"parameter"><code>zFar
</code></em>.
160 The greater the ratio of
<em class=
"parameter"><code>zFar
</code></em> to
<em class=
"parameter"><code>zNear
</code></em> is,
161 the less effective the depth buffer will be at distinguishing between
162 surfaces that are near each other.
165 <mml:math xmlns:
mml=
"http://www.w3.org/1998/Math/MathML" overflow=
"scroll">
168 <mml:mi mathvariant=
"italic">r
</mml:mi>
171 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
172 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
179 <mml:math xmlns:
mml=
"http://www.w3.org/1998/Math/MathML" overflow=
"scroll">
182 <mml:msub><mml:mi mathvariant=
"italic">log
</mml:mi>
186 <mml:mfenced open=
"(" close=
")">
187 <mml:mi mathvariant=
"italic">r
</mml:mi>
191 bits of depth buffer precision are lost.
193 <mml:math xmlns:
mml=
"http://www.w3.org/1998/Math/MathML" overflow=
"scroll"><mml:mi mathvariant=
"italic">r
</mml:mi></mml:math>
194 approaches infinity as
<em class=
"parameter"><code>zNear
</code></em> approaches
0,
195 <em class=
"parameter"><code>zNear
</code></em> must never be set to
0.
196 </p></div><div class=
"refsect1" lang=
"en" xml:
lang=
"en"><a id=
"seealso"></a><h2>See Also
</h2><p>
197 <a class=
"citerefentry" href=
"gluOrtho2D.xml"><span class=
"citerefentry"><span class=
"refentrytitle">gluOrtho2D
</span></span></a>,
198 <a class=
"citerefentry" href=
"glFrustum.xml"><span class=
"citerefentry"><span class=
"refentrytitle">glFrustum
</span></span></a>,
199 <a class=
"citerefentry" href=
"glLoadIdentity.xml"><span class=
"citerefentry"><span class=
"refentrytitle">glLoadIdentity
</span></span></a>,
200 <a class=
"citerefentry" href=
"glMultMatrix.xml"><span class=
"citerefentry"><span class=
"refentrytitle">glMultMatrix
</span></span></a>
201 </p></div><div class=
"refsect1" lang=
"en" xml:
lang=
"en"><a id=
"Copyright"></a><h2>Copyright
</h2><p>
202 Copyright
<span class=
"trademark"></span>©
1991-
2006
203 Silicon Graphics, Inc. This document is licensed under the SGI
204 Free Software B License. For details, see
205 <a class=
"ulink" href=
"http://oss.sgi.com/projects/FreeB/" target=
"_top">http://oss.sgi.com/projects/FreeB/
</a>.
206 </p></div></div></body></html>