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">
9 <holder>Silicon Graphics, Inc.
</holder>
12 <refentrytitle>glFog
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>glFog
</refname>
17 <refpurpose>specify fog parameters
</refpurpose>
19 <refsynopsisdiv><title>C Specification
</title>
22 <funcdef>void
<function>glFogf
</function></funcdef>
23 <paramdef>GLenum
<parameter>pname
</parameter></paramdef>
24 <paramdef>GLfloat
<parameter>param
</parameter></paramdef>
29 <funcdef>void
<function>glFogi
</function></funcdef>
30 <paramdef>GLenum
<parameter>pname
</parameter></paramdef>
31 <paramdef>GLint
<parameter>param
</parameter></paramdef>
35 <!-- eqn: ignoring delim $$ -->
36 <refsect1 id=
"parameters"><title>Parameters
</title>
39 <term><parameter>pname
</parameter></term>
42 Specifies a single-valued fog parameter.
43 <constant>GL_FOG_MODE
</constant>,
44 <constant>GL_FOG_DENSITY
</constant>,
45 <constant>GL_FOG_START
</constant>,
46 <constant>GL_FOG_END
</constant>,
47 <constant>GL_FOG_INDEX
</constant>, and
48 <constant>GL_FOG_COORD_SRC
</constant>
54 <term><parameter>param
</parameter></term>
57 Specifies the value that
<parameter>pname
</parameter> will be set to.
63 <refsynopsisdiv><title>C Specification
</title>
66 <funcdef>void
<function>glFogfv
</function></funcdef>
67 <paramdef>GLenum
<parameter>pname
</parameter></paramdef>
68 <paramdef>const GLfloat *
<parameter>params
</parameter></paramdef>
73 <funcdef>void
<function>glFogiv
</function></funcdef>
74 <paramdef>GLenum
<parameter>pname
</parameter></paramdef>
75 <paramdef>const GLint *
<parameter>params
</parameter></paramdef>
79 <refsect1 id=
"parameters2"><title>Parameters
</title>
82 <term><parameter>pname
</parameter></term>
85 Specifies a fog parameter.
86 <constant>GL_FOG_MODE
</constant>,
87 <constant>GL_FOG_DENSITY
</constant>,
88 <constant>GL_FOG_START
</constant>,
89 <constant>GL_FOG_END
</constant>,
90 <constant>GL_FOG_INDEX
</constant>,
91 <constant>GL_FOG_COLOR
</constant>, and
92 <constant>GL_FOG_COORD_SRC
</constant>
98 <term><parameter>params
</parameter></term>
101 Specifies the value or values to be assigned to
<parameter>pname
</parameter>.
102 <constant>GL_FOG_COLOR
</constant> requires an array of four values.
103 All other parameters accept an array containing only a single value.
109 <refsect1 id=
"description"><title>Description
</title>
111 Fog is initially disabled.
112 While enabled, fog affects rasterized geometry,
113 bitmaps, and pixel blocks, but not buffer clear operations. To enable
114 and disable fog, call
<citerefentry><refentrytitle>glEnable
</refentrytitle></citerefentry> and
<citerefentry><refentrytitle>glDisable
</refentrytitle></citerefentry> with argument
115 <constant>GL_FOG
</constant>.
118 <function>glFog
</function> assigns the value or values in
<parameter>params
</parameter> to the fog parameter
119 specified by
<parameter>pname
</parameter>.
120 The following values are accepted for
<parameter>pname
</parameter>:
124 <term><constant>GL_FOG_MODE
</constant></term>
127 <parameter>params
</parameter> is a single integer or floating-point value that specifies
128 the equation to be used to compute the fog blend factor,
129 <inlineequation><mml:math><mml:mi mathvariant=
"italic">f
</mml:mi></mml:math></inlineequation>.
130 Three symbolic constants are accepted:
131 <constant>GL_LINEAR
</constant>,
132 <constant>GL_EXP
</constant>,
133 and
<constant>GL_EXP2
</constant>.
134 The equations corresponding to these symbolic constants are defined below.
135 The initial fog mode is
<constant>GL_EXP
</constant>.
140 <term><constant>GL_FOG_DENSITY
</constant></term>
143 <parameter>params
</parameter> is a single integer or floating-point value that specifies
144 <inlineequation><mml:math><mml:mi mathvariant=
"italic">density
</mml:mi></mml:math></inlineequation>,
145 the fog density used in both exponential fog equations.
146 Only nonnegative densities are accepted.
147 The initial fog density is
1.
152 <term><constant>GL_FOG_START
</constant></term>
155 <parameter>params
</parameter> is a single integer or floating-point value that specifies
156 <inlineequation><mml:math><mml:mi mathvariant=
"italic">start
</mml:mi></mml:math></inlineequation>,
157 the near distance used in the linear fog equation.
158 The initial near distance is
0.
163 <term><constant>GL_FOG_END
</constant></term>
166 <parameter>params
</parameter> is a single integer or floating-point value that specifies
167 <inlineequation><mml:math><mml:mi mathvariant=
"italic">end
</mml:mi></mml:math></inlineequation>,
168 the far distance used in the linear fog equation.
169 The initial far distance is
1.
174 <term><constant>GL_FOG_INDEX
</constant></term>
177 <parameter>params
</parameter> is a single integer or floating-point value that specifies
178 <inlineequation><mml:math>
179 <!-- eqn: i sub f:-->
180 <mml:msub><mml:mi mathvariant=
"italic">i
</mml:mi>
181 <mml:mi mathvariant=
"italic">f
</mml:mi>
183 </mml:math></inlineequation>,
185 The initial fog index is
0.
190 <term><constant>GL_FOG_COLOR
</constant></term>
193 <parameter>params
</parameter> contains four integer or floating-point values that specify
194 <inlineequation><mml:math>
195 <!-- eqn: C sub f:-->
196 <mml:msub><mml:mi mathvariant=
"italic">C
</mml:mi>
197 <mml:mi mathvariant=
"italic">f
</mml:mi>
199 </mml:math></inlineequation>,
201 Integer values are mapped linearly such that the most positive representable
203 and the most negative representable value maps to
204 <inlineequation><mml:math>
206 <mml:mn>-
1.0</mml:mn>
207 </mml:math></inlineequation>.
208 Floating-point values are mapped directly.
210 all color components are clamped to the range
211 <inlineequation><mml:math>
213 <mml:mfenced open=
"[" close=
"]">
217 </mml:math></inlineequation>.
218 The initial fog color is (
0,
0,
0,
0).
223 <term><constant>GL_FOG_COORD_SRC
</constant></term>
226 <parameter>params
</parameter> contains either of the following symbolic constants:
227 <constant>GL_FOG_COORD
</constant> or
<constant>GL_FRAGMENT_DEPTH
</constant>.
<constant>GL_FOG_COORD
</constant>
228 specifies that the current fog coordinate should be used as distance value
229 in the fog color computation.
<constant>GL_FRAGMENT_DEPTH
</constant> specifies that the
230 current fragment depth should be used as distance value in the fog
237 Fog blends a fog color with each rasterized pixel fragment's post-texturing
238 color using a blending factor
239 <inlineequation><mml:math><mml:mi mathvariant=
"italic">f
</mml:mi></mml:math></inlineequation>.
241 <inlineequation><mml:math><mml:mi mathvariant=
"italic">f
</mml:mi></mml:math></inlineequation>
242 is computed in one of three ways,
243 depending on the fog mode.
245 <inlineequation><mml:math><mml:mi mathvariant=
"italic">c
</mml:mi></mml:math></inlineequation>
246 be either the distance in eye coordinate from the origin (in the
247 case that the
<constant>GL_FOG_COORD_SRC
</constant> is
<constant>GL_FRAGMENT_DEPTH
</constant>) or
248 the current fog coordinate (in the case that
<constant>GL_FOG_COORD_SRC
</constant>
249 is
<constant>GL_FOG_COORD
</constant>).
250 The equation for
<constant>GL_LINEAR
</constant> fog is
251 <informalequation><mml:math>
252 <!-- eqn: f = {end - c} over {end - start}:-->
254 <mml:mi mathvariant=
"italic">f
</mml:mi>
257 <mml:mfenced open=
"" close=
"">
259 <mml:mi mathvariant=
"italic">end
</mml:mi>
261 <mml:mi mathvariant=
"italic">c
</mml:mi>
264 <mml:mfenced open=
"" close=
"">
266 <mml:mi mathvariant=
"italic">end
</mml:mi>
268 <mml:mi mathvariant=
"italic">start
</mml:mi>
273 </mml:math></informalequation>
276 The equation for
<constant>GL_EXP
</constant> fog is
277 <informalequation><mml:math>
278 <!-- eqn: f = e sup {-(density cdot c)}:-->
280 <mml:mi mathvariant=
"italic">f
</mml:mi>
282 <mml:msup><mml:mi mathvariant=
"italic">e
</mml:mi>
283 <mml:mfenced open=
"" close=
"">
286 <mml:mfenced open=
"(" close=
")">
288 <mml:mi mathvariant=
"italic">density
</mml:mi>
289 <mml:mo>·</mml:mo>
290 <mml:mi mathvariant=
"italic">c
</mml:mi>
297 </mml:math></informalequation>
300 The equation for
<constant>GL_EXP2
</constant> fog is
301 <informalequation><mml:math>
302 <!-- eqn: f = e sup {-(density cdot c)} sup 2:-->
304 <mml:mi mathvariant=
"italic">f
</mml:mi>
306 <mml:msup><mml:mi mathvariant=
"italic">e
</mml:mi>
307 <mml:msup><mml:mfenced open=
"" close=
"">
310 <mml:mfenced open=
"(" close=
")">
312 <mml:mi mathvariant=
"italic">density
</mml:mi>
313 <mml:mo>·</mml:mo>
314 <mml:mi mathvariant=
"italic">c
</mml:mi>
320 </mml:msup></mml:msup>
322 </mml:math></informalequation>
325 Regardless of the fog mode,
326 <inlineequation><mml:math><mml:mi mathvariant=
"italic">f
</mml:mi></mml:math></inlineequation>
327 is clamped to the range
328 <inlineequation><mml:math>
330 <mml:mfenced open=
"[" close=
"]">
334 </mml:math></inlineequation>
335 after it is computed.
337 if the GL is in RGBA color mode,
338 the fragment's red, green, and blue colors, represented by
339 <inlineequation><mml:math>
340 <!-- eqn: C sub r:-->
341 <mml:msub><mml:mi mathvariant=
"italic">C
</mml:mi>
342 <mml:mi mathvariant=
"italic">r
</mml:mi>
344 </mml:math></inlineequation>,
348 <informalequation><mml:math>
349 <!-- eqn: {C sub r} sup prime = f * C sub r + (1 - f) * C sub f:-->
351 <mml:msup><mml:mfenced open=
"" close=
"">
352 <mml:msub><mml:mi mathvariant=
"italic">C
</mml:mi>
353 <mml:mi mathvariant=
"italic">r
</mml:mi>
356 <mml:mo>″</mml:mo>
361 <mml:mi mathvariant=
"italic">f
</mml:mi>
362 <mml:mo>×</mml:mo>
363 <mml:msub><mml:mi mathvariant=
"italic">C
</mml:mi>
364 <mml:mi mathvariant=
"italic">r
</mml:mi>
369 <mml:mfenced open=
"(" close=
")">
373 <mml:mi mathvariant=
"italic">f
</mml:mi>
376 <mml:mo>×</mml:mo>
377 <mml:msub><mml:mi mathvariant=
"italic">C
</mml:mi>
378 <mml:mi mathvariant=
"italic">f
</mml:mi>
383 </mml:math></informalequation>
386 Fog does not affect a fragment's alpha component.
389 In color index mode, the fragment's color index
390 <inlineequation><mml:math>
391 <!-- eqn: i sub r:-->
392 <mml:msub><mml:mi mathvariant=
"italic">i
</mml:mi>
393 <mml:mi mathvariant=
"italic">r
</mml:mi>
395 </mml:math></inlineequation>
399 <informalequation><mml:math>
400 <!-- eqn: {i sub r} sup prime = i sub r + (1 - f) * i sub f:-->
402 <mml:msup><mml:mfenced open=
"" close=
"">
403 <mml:msub><mml:mi mathvariant=
"italic">i
</mml:mi>
404 <mml:mi mathvariant=
"italic">r
</mml:mi>
407 <mml:mo>″</mml:mo>
411 <mml:msub><mml:mi mathvariant=
"italic">i
</mml:mi>
412 <mml:mi mathvariant=
"italic">r
</mml:mi>
416 <mml:mfenced open=
"(" close=
")">
420 <mml:mi mathvariant=
"italic">f
</mml:mi>
423 <mml:mo>×</mml:mo>
424 <mml:msub><mml:mi mathvariant=
"italic">i
</mml:mi>
425 <mml:mi mathvariant=
"italic">f
</mml:mi>
430 </mml:math></informalequation>
435 <refsect1 id=
"notes"><title>Notes
</title>
437 <constant>GL_FOG_COORD_SRC
</constant> is available only if the GL version is
1.4 or
441 <refsect1 id=
"errors"><title>Errors
</title>
443 <constant>GL_INVALID_ENUM
</constant> is generated if
<parameter>pname
</parameter> is not an accepted value,
444 or if
<parameter>pname
</parameter> is
<constant>GL_FOG_MODE
</constant> and
<parameter>params
</parameter> is not an accepted value.
447 <constant>GL_INVALID_VALUE
</constant> is generated if
<parameter>pname
</parameter> is
<constant>GL_FOG_DENSITY
</constant>
448 and
<parameter>params
</parameter> is negative.
451 <constant>GL_INVALID_OPERATION
</constant> is generated if
<function>glFog
</function>
452 is executed between the execution of
<citerefentry><refentrytitle>glBegin
</refentrytitle></citerefentry>
453 and the corresponding execution of
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
456 <refsect1 id=
"associatedgets"><title>Associated Gets
</title>
458 <citerefentry><refentrytitle>glIsEnabled
</refentrytitle></citerefentry> with argument
<constant>GL_FOG
</constant>
461 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_FOG_COLOR
</constant>
464 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_FOG_INDEX
</constant>
467 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_FOG_DENSITY
</constant>
470 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_FOG_START
</constant>
473 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_FOG_END
</constant>
476 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_FOG_MODE
</constant>
479 <refsect1 id=
"seealso"><title>See Also
</title>
481 <citerefentry><refentrytitle>glEnable
</refentrytitle></citerefentry>
484 <refsect1 id=
"Copyright"><title>Copyright
</title>
486 Copyright
<trademark class=
"copyright"></trademark> 1991-
2006
487 Silicon Graphics, Inc. This document is licensed under the SGI
488 Free Software B License. For details, see
489 <ulink url=
"http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/
</ulink>.