/
glFrustum.xml
420 lines (420 loc) · 20 KB
/
glFrustum.xml
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry id="glFrustum">
<refmeta>
<refmetainfo>
<copyright>
<year>1991-2006</year>
<holder>Silicon Graphics, Inc.</holder>
</copyright>
</refmetainfo>
<refentrytitle>glFrustum</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refname>glFrustum</refname>
<refpurpose>multiply the current matrix by a perspective matrix</refpurpose>
</refnamediv>
<refsynopsisdiv><title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glFrustum</function></funcdef>
<paramdef>GLdouble <parameter>left</parameter></paramdef>
<paramdef>GLdouble <parameter>right</parameter></paramdef>
<paramdef>GLdouble <parameter>bottom</parameter></paramdef>
<paramdef>GLdouble <parameter>top</parameter></paramdef>
<paramdef>GLdouble <parameter>nearVal</parameter></paramdef>
<paramdef>GLdouble <parameter>farVal</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<!-- eqn: ignoring delim $$ -->
<refsect1 id="parameters"><title>Parameters</title>
<variablelist>
<varlistentry>
<term><parameter>left</parameter></term>
<term><parameter>right</parameter></term>
<listitem>
<para>
Specify the coordinates for the left and right vertical clipping planes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>bottom</parameter></term>
<term><parameter>top</parameter></term>
<listitem>
<para>
Specify the coordinates for the bottom and top horizontal clipping planes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>nearVal</parameter></term>
<term><parameter>farVal</parameter></term>
<listitem>
<para>
Specify the distances to the near and far depth clipping planes.
Both distances must be positive.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="description"><title>Description</title>
<para>
<function>glFrustum</function> describes a perspective matrix that produces a perspective projection.
The current matrix (see <citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>) is multiplied by this matrix
and the result replaces the current matrix, as if
<citerefentry><refentrytitle>glMultMatrix</refentrytitle></citerefentry> were called with the following matrix
as its argument:
</para>
<para>
</para>
<para>
<informalequation><mml:math>
<!-- eqn: left [ matrix { ccol { {{2 nearVal} over {right - left}} above 0 above 0 above 0 } ccol { 0 above {{2 nearVal} over {top - bottom}} above 0 above 0 } ccol { A above B above C above -1 } ccol { 0 above 0 above D above 0} } right ]:-->
<mml:mfenced open="[" close="]">
<mml:mtable>
<mml:mtr>
<mml:mtd>
<mml:mfenced open="" close="">
<mml:mfrac>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mn>2</mml:mn>
<mml:mo>⁢</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">right</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">left</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mfrac>
</mml:mfenced>
</mml:mtd>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mi mathvariant="italic">A</mml:mi>
</mml:mtd>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
</mml:mtr>
<mml:mtr>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mfenced open="" close="">
<mml:mfrac>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mn>2</mml:mn>
<mml:mo>⁢</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">top</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">bottom</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mfrac>
</mml:mfenced>
</mml:mtd>
<mml:mtd>
<mml:mi mathvariant="italic">B</mml:mi>
</mml:mtd>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
</mml:mtr>
<mml:mtr>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mi mathvariant="italic">C</mml:mi>
</mml:mtd>
<mml:mtd>
<mml:mi mathvariant="italic">D</mml:mi>
</mml:mtd>
</mml:mtr>
<mml:mtr>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mn>-1</mml:mn>
</mml:mtd>
<mml:mtd>
<mml:mn>0</mml:mn>
</mml:mtd>
</mml:mtr>
</mml:mtable>
</mml:mfenced>
</mml:math></informalequation>
</para>
<para>
<informalequation><mml:math>
<!-- eqn: A = {right + left} over {right - left}:-->
<mml:mrow>
<mml:mi mathvariant="italic">A</mml:mi>
<mml:mo>=</mml:mo>
<mml:mfrac>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">right</mml:mi>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">left</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">right</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">left</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mfrac>
</mml:mrow>
</mml:math></informalequation>
</para>
<para>
<informalequation><mml:math>
<!-- eqn: B = {top + bottom} over {top - bottom}:-->
<mml:mrow>
<mml:mi mathvariant="italic">B</mml:mi>
<mml:mo>=</mml:mo>
<mml:mfrac>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">top</mml:mi>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">bottom</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">top</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">bottom</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mfrac>
</mml:mrow>
</mml:math></informalequation>
</para>
<para>
<informalequation><mml:math>
<!-- eqn: C = -{{farVal + nearVal} over {farVal - nearVal}}:-->
<mml:mrow>
<mml:mi mathvariant="italic">C</mml:mi>
<mml:mo>=</mml:mo>
<mml:mrow>
<mml:mo>-</mml:mo>
<mml:mfenced open="" close="">
<mml:mfrac>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">farVal</mml:mi>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">farVal</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mfrac>
</mml:mfenced>
</mml:mrow>
</mml:mrow>
</mml:math></informalequation>
</para>
<para>
<informalequation><mml:math>
<!-- eqn: D = -{{2 farVal nearVal} over {farVal - nearVal}}:-->
<mml:mrow>
<mml:mi mathvariant="italic">D</mml:mi>
<mml:mo>=</mml:mo>
<mml:mrow>
<mml:mo>-</mml:mo>
<mml:mfenced open="" close="">
<mml:mfrac>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mn>2</mml:mn>
<mml:mo>⁢</mml:mo>
<mml:mi mathvariant="italic">farVal</mml:mi>
<mml:mo>⁢</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mfenced open="" close="">
<mml:mrow>
<mml:mi mathvariant="italic">farVal</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mfrac>
</mml:mfenced>
</mml:mrow>
</mml:mrow>
</mml:math></informalequation>
</para>
<para>
</para>
<para>
Typically, the matrix mode is <constant>GL_PROJECTION</constant>, and
<inlineequation><mml:math>
<!-- eqn: (left, bottom, -nearVal):-->
<mml:mfenced open="(" close=")">
<mml:mi mathvariant="italic">left</mml:mi>
<mml:mi mathvariant="italic">bottom</mml:mi>
<mml:mrow>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>
and
<inlineequation><mml:math>
<!-- eqn: (right, top, -nearVal):-->
<mml:mfenced open="(" close=")">
<mml:mi mathvariant="italic">right</mml:mi>
<mml:mi mathvariant="italic">top</mml:mi>
<mml:mrow>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>
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).
<inlineequation><mml:math>
<!-- eqn: -farVal:-->
<mml:mrow>
<mml:mo>-</mml:mo>
<mml:mi mathvariant="italic">farVal</mml:mi>
</mml:mrow>
</mml:math></inlineequation>
specifies the location of the far clipping plane.
Both <parameter>nearVal</parameter> and <parameter>farVal</parameter> must be positive.
</para>
<para>
Use <citerefentry><refentrytitle>glPushMatrix</refentrytitle></citerefentry> and <citerefentry><refentrytitle>glPopMatrix</refentrytitle></citerefentry> to save and restore
the current matrix stack.
</para>
</refsect1>
<refsect1 id="notes"><title>Notes</title>
<para>
Depth buffer precision is affected by the values specified for
<parameter>nearVal</parameter> and <parameter>farVal</parameter>.
The greater the ratio of <parameter>farVal</parameter> to <parameter>nearVal</parameter> is,
the less effective the depth buffer will be at distinguishing between
surfaces that are near each other.
If
</para>
<para>
<inlineequation><mml:math>
<!-- eqn: r = farVal over nearVal:-->
<mml:mrow>
<mml:mi mathvariant="italic">r</mml:mi>
<mml:mo>=</mml:mo>
<mml:mfrac>
<mml:mi mathvariant="italic">farVal</mml:mi>
<mml:mi mathvariant="italic">nearVal</mml:mi>
</mml:mfrac>
</mml:mrow>
</mml:math></inlineequation>
</para>
<para>
roughly
<inlineequation><mml:math>
<!-- eqn: log sub 2 (r):-->
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">log</mml:mi>
<mml:mn>2</mml:mn>
</mml:msub>
<mml:mo>⁡</mml:mo>
<mml:mfenced open="(" close=")">
<mml:mi mathvariant="italic">r</mml:mi>
</mml:mfenced>
</mml:mrow>
</mml:math></inlineequation>
bits of depth buffer precision are lost.
Because
<inlineequation><mml:math><mml:mi mathvariant="italic">r</mml:mi></mml:math></inlineequation>
approaches infinity as <parameter>nearVal</parameter> approaches 0,
<parameter>nearVal</parameter> must never be set to 0.
</para>
</refsect1>
<refsect1 id="errors"><title>Errors</title>
<para>
<constant>GL_INVALID_VALUE</constant> is generated if <parameter>nearVal</parameter> or <parameter>farVal</parameter> is not
positive, or if <parameter>left</parameter> = <parameter>right</parameter>, or <parameter>bottom</parameter> = <parameter>top</parameter>,
or <parameter>near</parameter> = <parameter>far</parameter>.
</para>
<para>
<constant>GL_INVALID_OPERATION</constant> is generated if <function>glFrustum</function>
is executed between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry>
and the corresponding execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
</para>
</refsect1>
<refsect1 id="associatedgets"><title>Associated Gets</title>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MATRIX_MODE</constant>
</para>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_MODELVIEW_MATRIX</constant>
</para>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_PROJECTION_MATRIX</constant>
</para>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_TEXTURE_MATRIX</constant>
</para>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_COLOR_MATRIX</constant>
</para>
</refsect1>
<refsect1 id="seealso"><title>See Also</title>
<para>
<citerefentry><refentrytitle>glOrtho</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMultMatrix</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPushMatrix</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glViewport</refentrytitle></citerefentry>
</para>
</refsect1>
<refsect1 id="Copyright"><title>Copyright</title>
<para>
Copyright <trademark class="copyright"></trademark> 1991-2006
Silicon Graphics, Inc. This document is licensed under the SGI
Free Software B License. For details, see
<ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>.
</para>
</refsect1>
</refentry>