Commit | Line | Data |
---|---|---|
7faf1d71 AW |
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>glFrustum</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="glFrustum"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glFrustum — multiply the current matrix by a perspective 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">glFrustum</b>(</code></td><td>GLdouble </td><td><var class="pdparam">left</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">right</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">bottom</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">top</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">nearVal</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">farVal</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>left</code></em>, </span><span class="term"><em class="parameter"><code>right</code></em></span></dt><dd><p> | |
4 | Specify the coordinates for the left and right vertical clipping planes. | |
5 | </p></dd><dt><span class="term"><em class="parameter"><code>bottom</code></em>, </span><span class="term"><em class="parameter"><code>top</code></em></span></dt><dd><p> | |
6 | Specify the coordinates for the bottom and top horizontal clipping planes. | |
7 | </p></dd><dt><span class="term"><em class="parameter"><code>nearVal</code></em>, </span><span class="term"><em class="parameter"><code>farVal</code></em></span></dt><dd><p> | |
8 | Specify the distances to the near and far depth clipping planes. | |
9 | Both distances must be positive. | |
10 | </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p> | |
11 | <code class="function">glFrustum</code> describes a perspective matrix that produces a perspective projection. | |
12 | The current matrix (see <a class="citerefentry" href="glMatrixMode.xml"><span class="citerefentry"><span class="refentrytitle">glMatrixMode</span></span></a>) is multiplied by this matrix | |
13 | and the result replaces the current matrix, as if | |
14 | <a class="citerefentry" href="glMultMatrix.xml"><span class="citerefentry"><span class="refentrytitle">glMultMatrix</span></span></a> were called with the following matrix | |
15 | as its argument: | |
16 | </p><p> | |
17 | </p><p> | |
18 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
19 | ||
20 | <mml:mfenced open="[" close="]"> | |
21 | <mml:mtable> | |
22 | <mml:mtr> | |
23 | <mml:mtd> | |
24 | <mml:mfenced open="" close=""> | |
25 | <mml:mfrac> | |
26 | <mml:mfenced open="" close=""> | |
27 | <mml:mrow> | |
28 | <mml:mn>2</mml:mn> | |
29 | <mml:mo></mml:mo> | |
30 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
31 | </mml:mrow> | |
32 | </mml:mfenced> | |
33 | <mml:mfenced open="" close=""> | |
34 | <mml:mrow> | |
35 | <mml:mi mathvariant="italic">right</mml:mi> | |
36 | <mml:mo>-</mml:mo> | |
37 | <mml:mi mathvariant="italic">left</mml:mi> | |
38 | </mml:mrow> | |
39 | </mml:mfenced> | |
40 | </mml:mfrac> | |
41 | </mml:mfenced> | |
42 | </mml:mtd> | |
43 | <mml:mtd> | |
44 | <mml:mn>0</mml:mn> | |
45 | </mml:mtd> | |
46 | <mml:mtd> | |
47 | <mml:mi mathvariant="italic">A</mml:mi> | |
48 | </mml:mtd> | |
49 | <mml:mtd> | |
50 | <mml:mn>0</mml:mn> | |
51 | </mml:mtd> | |
52 | </mml:mtr> | |
53 | <mml:mtr> | |
54 | <mml:mtd> | |
55 | <mml:mn>0</mml:mn> | |
56 | </mml:mtd> | |
57 | <mml:mtd> | |
58 | <mml:mfenced open="" close=""> | |
59 | <mml:mfrac> | |
60 | <mml:mfenced open="" close=""> | |
61 | <mml:mrow> | |
62 | <mml:mn>2</mml:mn> | |
63 | <mml:mo></mml:mo> | |
64 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
65 | </mml:mrow> | |
66 | </mml:mfenced> | |
67 | <mml:mfenced open="" close=""> | |
68 | <mml:mrow> | |
69 | <mml:mi mathvariant="italic">top</mml:mi> | |
70 | <mml:mo>-</mml:mo> | |
71 | <mml:mi mathvariant="italic">bottom</mml:mi> | |
72 | </mml:mrow> | |
73 | </mml:mfenced> | |
74 | </mml:mfrac> | |
75 | </mml:mfenced> | |
76 | </mml:mtd> | |
77 | <mml:mtd> | |
78 | <mml:mi mathvariant="italic">B</mml:mi> | |
79 | </mml:mtd> | |
80 | <mml:mtd> | |
81 | <mml:mn>0</mml:mn> | |
82 | </mml:mtd> | |
83 | </mml:mtr> | |
84 | <mml:mtr> | |
85 | <mml:mtd> | |
86 | <mml:mn>0</mml:mn> | |
87 | </mml:mtd> | |
88 | <mml:mtd> | |
89 | <mml:mn>0</mml:mn> | |
90 | </mml:mtd> | |
91 | <mml:mtd> | |
92 | <mml:mi mathvariant="italic">C</mml:mi> | |
93 | </mml:mtd> | |
94 | <mml:mtd> | |
95 | <mml:mi mathvariant="italic">D</mml:mi> | |
96 | </mml:mtd> | |
97 | </mml:mtr> | |
98 | <mml:mtr> | |
99 | <mml:mtd> | |
100 | <mml:mn>0</mml:mn> | |
101 | </mml:mtd> | |
102 | <mml:mtd> | |
103 | <mml:mn>0</mml:mn> | |
104 | </mml:mtd> | |
105 | <mml:mtd> | |
106 | <mml:mn>-1</mml:mn> | |
107 | </mml:mtd> | |
108 | <mml:mtd> | |
109 | <mml:mn>0</mml:mn> | |
110 | </mml:mtd> | |
111 | </mml:mtr> | |
112 | </mml:mtable> | |
113 | </mml:mfenced> | |
114 | </mml:math></div><p> | |
115 | </p><p> | |
116 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
117 | ||
118 | <mml:mrow> | |
119 | <mml:mi mathvariant="italic">A</mml:mi> | |
120 | <mml:mo>=</mml:mo> | |
121 | <mml:mfrac> | |
122 | <mml:mfenced open="" close=""> | |
123 | <mml:mrow> | |
124 | <mml:mi mathvariant="italic">right</mml:mi> | |
125 | <mml:mo>+</mml:mo> | |
126 | <mml:mi mathvariant="italic">left</mml:mi> | |
127 | </mml:mrow> | |
128 | </mml:mfenced> | |
129 | <mml:mfenced open="" close=""> | |
130 | <mml:mrow> | |
131 | <mml:mi mathvariant="italic">right</mml:mi> | |
132 | <mml:mo>-</mml:mo> | |
133 | <mml:mi mathvariant="italic">left</mml:mi> | |
134 | </mml:mrow> | |
135 | </mml:mfenced> | |
136 | </mml:mfrac> | |
137 | </mml:mrow> | |
138 | </mml:math></div><p> | |
139 | </p><p> | |
140 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
141 | ||
142 | <mml:mrow> | |
143 | <mml:mi mathvariant="italic">B</mml:mi> | |
144 | <mml:mo>=</mml:mo> | |
145 | <mml:mfrac> | |
146 | <mml:mfenced open="" close=""> | |
147 | <mml:mrow> | |
148 | <mml:mi mathvariant="italic">top</mml:mi> | |
149 | <mml:mo>+</mml:mo> | |
150 | <mml:mi mathvariant="italic">bottom</mml:mi> | |
151 | </mml:mrow> | |
152 | </mml:mfenced> | |
153 | <mml:mfenced open="" close=""> | |
154 | <mml:mrow> | |
155 | <mml:mi mathvariant="italic">top</mml:mi> | |
156 | <mml:mo>-</mml:mo> | |
157 | <mml:mi mathvariant="italic">bottom</mml:mi> | |
158 | </mml:mrow> | |
159 | </mml:mfenced> | |
160 | </mml:mfrac> | |
161 | </mml:mrow> | |
162 | </mml:math></div><p> | |
163 | </p><p> | |
164 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
165 | ||
166 | <mml:mrow> | |
167 | <mml:mi mathvariant="italic">C</mml:mi> | |
168 | <mml:mo>=</mml:mo> | |
169 | <mml:mrow> | |
170 | <mml:mo>-</mml:mo> | |
171 | <mml:mfenced open="" close=""> | |
172 | <mml:mfrac> | |
173 | <mml:mfenced open="" close=""> | |
174 | <mml:mrow> | |
175 | <mml:mi mathvariant="italic">farVal</mml:mi> | |
176 | <mml:mo>+</mml:mo> | |
177 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
178 | </mml:mrow> | |
179 | </mml:mfenced> | |
180 | <mml:mfenced open="" close=""> | |
181 | <mml:mrow> | |
182 | <mml:mi mathvariant="italic">farVal</mml:mi> | |
183 | <mml:mo>-</mml:mo> | |
184 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
185 | </mml:mrow> | |
186 | </mml:mfenced> | |
187 | </mml:mfrac> | |
188 | </mml:mfenced> | |
189 | </mml:mrow> | |
190 | </mml:mrow> | |
191 | </mml:math></div><p> | |
192 | </p><p> | |
193 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
194 | ||
195 | <mml:mrow> | |
196 | <mml:mi mathvariant="italic">D</mml:mi> | |
197 | <mml:mo>=</mml:mo> | |
198 | <mml:mrow> | |
199 | <mml:mo>-</mml:mo> | |
200 | <mml:mfenced open="" close=""> | |
201 | <mml:mfrac> | |
202 | <mml:mfenced open="" close=""> | |
203 | <mml:mrow> | |
204 | <mml:mn>2</mml:mn> | |
205 | <mml:mo></mml:mo> | |
206 | <mml:mi mathvariant="italic">farVal</mml:mi> | |
207 | <mml:mo></mml:mo> | |
208 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
209 | </mml:mrow> | |
210 | </mml:mfenced> | |
211 | <mml:mfenced open="" close=""> | |
212 | <mml:mrow> | |
213 | <mml:mi mathvariant="italic">farVal</mml:mi> | |
214 | <mml:mo>-</mml:mo> | |
215 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
216 | </mml:mrow> | |
217 | </mml:mfenced> | |
218 | </mml:mfrac> | |
219 | </mml:mfenced> | |
220 | </mml:mrow> | |
221 | </mml:mrow> | |
222 | </mml:math></div><p> | |
223 | </p><p> | |
224 | </p><p> | |
225 | Typically, the matrix mode is <code class="constant">GL_PROJECTION</code>, and | |
226 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
227 | ||
228 | <mml:mfenced open="(" close=")"> | |
229 | <mml:mi mathvariant="italic">left</mml:mi> | |
230 | <mml:mi mathvariant="italic">bottom</mml:mi> | |
231 | <mml:mrow> | |
232 | <mml:mo>-</mml:mo> | |
233 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
234 | </mml:mrow> | |
235 | </mml:mfenced> | |
236 | </mml:math> | |
237 | and | |
238 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
239 | ||
240 | <mml:mfenced open="(" close=")"> | |
241 | <mml:mi mathvariant="italic">right</mml:mi> | |
242 | <mml:mi mathvariant="italic">top</mml:mi> | |
243 | <mml:mrow> | |
244 | <mml:mo>-</mml:mo> | |
245 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
246 | </mml:mrow> | |
247 | </mml:mfenced> | |
248 | </mml:math> | |
249 | specify the points on the near clipping plane that are mapped | |
250 | to the lower left and upper right corners of the window, | |
251 | assuming that the eye is located at (0, 0, 0). | |
252 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
253 | ||
254 | <mml:mrow> | |
255 | <mml:mo>-</mml:mo> | |
256 | <mml:mi mathvariant="italic">farVal</mml:mi> | |
257 | </mml:mrow> | |
258 | </mml:math> | |
259 | specifies the location of the far clipping plane. | |
260 | Both <em class="parameter"><code>nearVal</code></em> and <em class="parameter"><code>farVal</code></em> must be positive. | |
261 | </p><p> | |
262 | Use <a class="citerefentry" href="glPushMatrix.xml"><span class="citerefentry"><span class="refentrytitle">glPushMatrix</span></span></a> and <a class="citerefentry" href="glPopMatrix.xml"><span class="citerefentry"><span class="refentrytitle">glPopMatrix</span></span></a> to save and restore | |
263 | the current matrix stack. | |
264 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p> | |
265 | Depth buffer precision is affected by the values specified for | |
266 | <em class="parameter"><code>nearVal</code></em> and <em class="parameter"><code>farVal</code></em>. | |
267 | The greater the ratio of <em class="parameter"><code>farVal</code></em> to <em class="parameter"><code>nearVal</code></em> is, | |
268 | the less effective the depth buffer will be at distinguishing between | |
269 | surfaces that are near each other. | |
270 | If | |
271 | </p><p> | |
272 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
273 | ||
274 | <mml:mrow> | |
275 | <mml:mi mathvariant="italic">r</mml:mi> | |
276 | <mml:mo>=</mml:mo> | |
277 | <mml:mfrac> | |
278 | <mml:mi mathvariant="italic">farVal</mml:mi> | |
279 | <mml:mi mathvariant="italic">nearVal</mml:mi> | |
280 | </mml:mfrac> | |
281 | </mml:mrow> | |
282 | </mml:math> | |
283 | </p><p> | |
284 | roughly | |
285 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
286 | ||
287 | <mml:mrow> | |
288 | <mml:msub><mml:mi mathvariant="italic">log</mml:mi> | |
289 | <mml:mn>2</mml:mn> | |
290 | </mml:msub> | |
291 | <mml:mo></mml:mo> | |
292 | <mml:mfenced open="(" close=")"> | |
293 | <mml:mi mathvariant="italic">r</mml:mi> | |
294 | </mml:mfenced> | |
295 | </mml:mrow> | |
296 | </mml:math> | |
297 | bits of depth buffer precision are lost. | |
298 | Because | |
299 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">r</mml:mi></mml:math> | |
300 | approaches infinity as <em class="parameter"><code>nearVal</code></em> approaches 0, | |
301 | <em class="parameter"><code>nearVal</code></em> must never be set to 0. | |
302 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p> | |
303 | <code class="constant">GL_INVALID_VALUE</code> is generated if <em class="parameter"><code>nearVal</code></em> or <em class="parameter"><code>farVal</code></em> is not | |
304 | positive, or if <em class="parameter"><code>left</code></em> = <em class="parameter"><code>right</code></em>, or <em class="parameter"><code>bottom</code></em> = <em class="parameter"><code>top</code></em>, | |
305 | or <em class="parameter"><code>near</code></em> = <em class="parameter"><code>far</code></em>. | |
306 | </p><p> | |
307 | <code class="constant">GL_INVALID_OPERATION</code> is generated if <code class="function">glFrustum</code> | |
308 | is executed between the execution of <a class="citerefentry" href="glBegin.xml"><span class="citerefentry"><span class="refentrytitle">glBegin</span></span></a> | |
309 | and the corresponding execution of <a class="citerefentry" href="glEnd.xml"><span class="citerefentry"><span class="refentrytitle">glEnd</span></span></a>. | |
310 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="associatedgets"></a><h2>Associated Gets</h2><p> | |
311 | <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_MATRIX_MODE</code> | |
312 | </p><p> | |
313 | <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_MODELVIEW_MATRIX</code> | |
314 | </p><p> | |
315 | <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_PROJECTION_MATRIX</code> | |
316 | </p><p> | |
317 | <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_TEXTURE_MATRIX</code> | |
318 | </p><p> | |
319 | <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_COLOR_MATRIX</code> | |
320 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p> | |
321 | <a class="citerefentry" href="glOrtho.xml"><span class="citerefentry"><span class="refentrytitle">glOrtho</span></span></a>, | |
322 | <a class="citerefentry" href="glMatrixMode.xml"><span class="citerefentry"><span class="refentrytitle">glMatrixMode</span></span></a>, | |
323 | <a class="citerefentry" href="glMultMatrix.xml"><span class="citerefentry"><span class="refentrytitle">glMultMatrix</span></span></a>, | |
324 | <a class="citerefentry" href="glPushMatrix.xml"><span class="citerefentry"><span class="refentrytitle">glPushMatrix</span></span></a>, | |
325 | <a class="citerefentry" href="glViewport.xml"><span class="citerefentry"><span class="refentrytitle">glViewport</span></span></a> | |
326 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p> | |
327 | Copyright <span class="trademark"></span>© 1991-2006 | |
328 | Silicon Graphics, Inc. This document is licensed under the SGI | |
329 | Free Software B License. For details, see | |
330 | <a class="ulink" href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>. | |
331 | </p></div></div></body></html> |