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