1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"gluPerspective">
9 <holder>Silicon Graphics, Inc.
</holder>
12 <refentrytitle>gluPerspective
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>gluPerspective
</refname>
17 <refpurpose>set up a perspective projection matrix
</refpurpose>
19 <refsynopsisdiv><title>C Specification
</title>
22 <funcdef>void
<function>gluPerspective
</function></funcdef>
23 <paramdef>GLdouble
<parameter>fovy
</parameter></paramdef>
24 <paramdef>GLdouble
<parameter>aspect
</parameter></paramdef>
25 <paramdef>GLdouble
<parameter>zNear
</parameter></paramdef>
26 <paramdef>GLdouble
<parameter>zFar
</parameter></paramdef>
30 <!-- eqn: ignoring delim $$ -->
31 <refsect1 id=
"parameters"><title>Parameters
</title>
34 <term><parameter>fovy
</parameter></term>
37 Specifies the field of view angle, in degrees, in the
<emphasis>y
</emphasis> direction.
42 <term><parameter>aspect
</parameter></term>
45 Specifies the aspect ratio that determines
46 the field of view in the
<emphasis>x
</emphasis> direction.
47 The aspect ratio is the ratio of
<emphasis>x
</emphasis> (width) to
<emphasis>y
</emphasis> (height).
52 <term><parameter>zNear
</parameter></term>
55 Specifies the distance from the viewer to the near clipping plane
61 <term><parameter>zFar
</parameter></term>
64 Specifies the distance from the viewer to the far clipping plane
71 <refsect1 id=
"description"><title>Description
</title>
73 <function>gluPerspective
</function> specifies a viewing frustum into the world coordinate system.
74 In general, the aspect ratio in
<function>gluPerspective
</function> should match the aspect ratio
75 of the associated viewport. For example,
76 <inlineequation><mml:math>
77 <!-- eqn: aspect = 2.0:-->
79 <mml:mi mathvariant=
"italic">aspect
</mml:mi>
83 </mml:math></inlineequation>
86 angle of view is twice as wide in
<emphasis>x
</emphasis> as it is in
<emphasis>y
</emphasis>.
88 twice as wide as it is tall, it displays the image without distortion.
91 The matrix generated by
<function>gluPerspective
</function> is multipled by the current matrix,
92 just as if
<citerefentry><refentrytitle>glMultMatrix
</refentrytitle></citerefentry> were called with the generated matrix.
93 To load the perspective matrix onto the current matrix stack instead,
94 precede the call to
<function>gluPerspective
</function> with a call to
<citerefentry><refentrytitle>glLoadIdentity
</refentrytitle></citerefentry>.
97 Given
<emphasis>f
</emphasis> defined as follows:
100 <informalequation><mml:math>
101 <!-- eqn: f = cotangent(fovy over 2):-->
103 <mml:mi mathvariant=
"italic">f
</mml:mi>
106 <mml:mi mathvariant=
"italic">cotangent
</mml:mi>
107 <mml:mo>⁡</mml:mo>
108 <mml:mfenced open=
"(" close=
")">
110 <mml:mi mathvariant=
"italic">fovy
</mml:mi>
116 </mml:math></informalequation>
117 The generated matrix is
120 <informalequation><mml:math>
121 <!-- eqn: left ( 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 ):-->
122 <mml:mfenced open=
"(" close=
")">
127 <mml:mi mathvariant=
"italic">f
</mml:mi>
128 <mml:mi mathvariant=
"italic">aspect
</mml:mi>
146 <mml:mi mathvariant=
"italic">f
</mml:mi>
164 <mml:mfenced open=
"" close=
"">
166 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
168 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
171 <mml:mfenced open=
"" close=
"">
173 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
175 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
182 <mml:mfenced open=
"" close=
"">
185 <mml:mo>×</mml:mo>
186 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
187 <mml:mo>×</mml:mo>
188 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
191 <mml:mfenced open=
"" close=
"">
193 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
195 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
217 </mml:math></informalequation>
220 <refsect1 id=
"notes"><title>Notes
</title>
222 Depth buffer precision is affected by the values specified for
223 <parameter>zNear
</parameter> and
<parameter>zFar
</parameter>.
224 The greater the ratio of
<parameter>zFar
</parameter> to
<parameter>zNear
</parameter> is,
225 the less effective the depth buffer will be at distinguishing between
226 surfaces that are near each other.
230 <inlineequation><mml:math>
231 <!-- eqn: r = zFar over zNear:-->
233 <mml:mi mathvariant=
"italic">r
</mml:mi>
236 <mml:mi mathvariant=
"italic">zFar
</mml:mi>
237 <mml:mi mathvariant=
"italic">zNear
</mml:mi>
240 </mml:math></inlineequation>
246 <inlineequation><mml:math>
247 <!-- eqn: log sub 2 (r):-->
249 <mml:msub><mml:mi mathvariant=
"italic">log
</mml:mi>
252 <mml:mo>⁡</mml:mo>
253 <mml:mfenced open=
"(" close=
")">
254 <mml:mi mathvariant=
"italic">r
</mml:mi>
257 </mml:math></inlineequation>
258 bits of depth buffer precision are lost.
260 <inlineequation><mml:math><mml:mi mathvariant=
"italic">r
</mml:mi></mml:math></inlineequation>
261 approaches infinity as
<parameter>zNear
</parameter> approaches
0,
262 <parameter>zNear
</parameter> must never be set to
0.
265 <refsect1 id=
"seealso"><title>See Also
</title>
267 <citerefentry><refentrytitle>gluOrtho2D
</refentrytitle></citerefentry>,
268 <citerefentry><refentrytitle>glFrustum
</refentrytitle></citerefentry>,
269 <citerefentry><refentrytitle>glLoadIdentity
</refentrytitle></citerefentry>,
270 <citerefentry><refentrytitle>glMultMatrix
</refentrytitle></citerefentry>
273 <refsect1 id=
"Copyright"><title>Copyright
</title>
275 Copyright
<trademark class=
"copyright"></trademark> 1991-
2006
276 Silicon Graphics, Inc. This document is licensed under the SGI
277 Free Software B License. For details, see
278 <ulink url=
"http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/
</ulink>.