forked from BSVino/docs.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glFog.xhtml
143 lines (142 loc) · 11.1 KB
/
glFog.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
<div class="refentry" title="glFog"><a id="glFog"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glFog — specify fog parameters</p></div><div class="refsynopsisdiv" title="C Specification"><h2>C Specification</h2><div class="funcsynopsis"><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glFogf</b>(</code></td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfloat <var class="pdparam">param</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glFogx</b>(</code></td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfixed <var class="pdparam">param</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Parameters"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term">
<em class="parameter"><code>pname</code></em>
</span></dt><dd><p>Specifies a single-valued fog parameter.
<code class="constant">GL_FOG_MODE</code>,
<code class="constant">GL_FOG_DENSITY</code>,
<code class="constant">GL_FOG_START</code>, and
<code class="constant">GL_FOG_END</code> are accepted.</p></dd><dt><span class="term">
<em class="parameter"><code>param</code></em>
</span></dt><dd><p>Specifies the value that
<em class="parameter"><code>pname</code></em>
will be set to.</p></dd></dl></div></div><div class="refsynopsisdiv" title="C Specification"><h2>C Specification</h2><div class="funcsynopsis"><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glFogfv</b>(</code></td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLfloat * <var class="pdparam">params</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glFogxv</b>(</code></td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLfixed * <var class="pdparam">params</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Parameters"><a id="parameters2"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term">
<em class="parameter"><code>pname</code></em>
</span></dt><dd><p>Specifies a fog parameter.
<code class="constant">GL_FOG_MODE</code>,
<code class="constant">GL_FOG_DENSITY</code>,
<code class="constant">GL_FOG_START</code>,
<code class="constant">GL_FOG_END</code>, and
<code class="constant">GL_FOG_COLOR</code> are accepted.</p></dd><dt><span class="term">
<em class="parameter"><code>params</code></em>
</span></dt><dd><p>Specifies the value or values to be assigned to
<em class="parameter"><code>pname</code></em>.
<code class="constant">GL_FOG_COLOR</code>
requires an array of four values. All other parameters
accept an array containing only a single value.</p></dd></dl></div></div><div class="refsect1" title="Description"><a id="description"></a><h2>Description</h2><p>If fog is enabled, fog affects
rasterized geometry, bitmaps, and pixel blocks, but not buffer
clear operations. To enable and disable fog, call
<a class="citerefentry" href="glEnable"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a> and
<a class="citerefentry" href="glDisable"><span class="citerefentry"><span class="refentrytitle">glDisable</span></span></a>
with argument <code class="constant">GL_FOG</code>.
Fog is initially disabled.
</p><p>
<code class="function">glFog</code> assigns the value or values in
<em class="parameter"><code>params</code></em> to the fog parameter specified by
<em class="parameter"><code>pname</code></em>. The following values are accepted for
<em class="parameter"><code>pname</code></em>:</p><div class="variablelist"><dl><dt><span class="term">
<code class="constant">GL_FOG_MODE</code>
</span></dt><dd><p>
<em class="parameter"><code>params</code></em>
is a single fixed-point or floating-point value that
specifies the equation to be used to compute the fog
blend factor <em class="replaceable"><code>f</code></em>.
Three symbolic constants are accepted:
<code class="constant">GL_LINEAR</code>,
<code class="constant">GL_EXP</code>, and
<code class="constant">GL_EXP2</code>.
The equations corresponding to these symbolic constants
are defined below. The initial fog mode is
<code class="constant">GL_EXP</code>.</p></dd><dt><span class="term">
<code class="constant">GL_FOG_DENSITY</code>
</span></dt><dd><p>
<em class="parameter"><code>params</code></em>
is a single fixed-point or floating-point value that
specifies <em class="replaceable"><code>density</code></em>,
the fog density used in both exponential fog equations.
Only nonnegative densities are accepted. The initial fog
density is 1.</p></dd><dt><span class="term">
<code class="constant">GL_FOG_START</code>
</span></dt><dd><p>
<em class="parameter"><code>params</code></em>
is a single fixed-point or floating-point value that
specifies <em class="replaceable"><code>start</code></em>,
the near distance used in the linear fog equation. The
initial near distance is 0.</p></dd><dt><span class="term">
<code class="constant">GL_FOG_END</code>
</span></dt><dd><p>
<em class="parameter"><code>params</code></em>
is a single fixed-point or floating-point value that
specifies <em class="replaceable"><code>end</code></em>,
the far distance used in the linear fog equation. The
initial far distance is 1.</p></dd><dt><span class="term">
<code class="constant">GL_FOG_COLOR</code>
</span></dt><dd><p>
<em class="parameter"><code>params</code></em>
contains four fixed-point or floating-point values that specify
<math overflow="scroll">
<msub><mi>C</mi><mi>f</mi></msub>
</math>,
the fog color. Both fixed-point and floating-point
values are mapped directly. After conversion, all color
components are clamped to the range [0, 1]. The initial
fog color is (0, 0, 0, 0).</p></dd></dl></div><p>Fog blends a fog color with each rasterized pixel
fragment's posttexturing color using a blending factor
<em class="replaceable"><code>f</code></em>. Factor <em class="replaceable"><code>f</code></em>
is computed in one of three ways, depending on the fog mode.
Let <em class="replaceable"><code>z</code></em>
be the distance in eye coordinates from the origin to the
fragment being fogged. The equation for <code class="constant">GL_LINEAR</code>
fog is</p><div class="informalequation"><math overflow="scroll">
<mi>f</mi><mo>=</mo>
<mfrac>
<mrow><mi>end</mi><mo>-</mo><mi>z</mi></mrow>
<mrow><mi>end</mi><mo>-</mo><mi>start</mi></mrow>
</mfrac>
</math></div><p>The equation for <code class="constant">GL_EXP</code> fog is</p><div class="informalequation"><math overflow="scroll">
<mi>f</mi><mo>=</mo>
<msup>
<mi>e</mi>
<mrow><mo>-</mo><mo>(</mo><mi>density</mi><mo>-</mo><mi>z</mi><mo>)</mo></mrow>
</msup>
</math></div><p>The equation for <code class="constant">GL_EXP2</code> fog is</p><div class="informalequation"><math overflow="scroll">
<mi>f</mi><mo>=</mo>
<msup>
<mi>e</mi>
<msup>
<mrow><mo>-</mo><mo>(</mo><mi>density</mi><mo>-</mo><mi>z</mi><mo>)</mo></mrow>
<mn>2</mn>
</msup>
</msup>
</math></div><p>Regardless of the fog mode, <em class="replaceable"><code>f</code></em>
is clamped to the range [0, 1] after it is computed. Then,
the fragment's red, green, and blue colors, represented by
<math overflow="scroll">
<msub><mi>C</mi><mi>r</mi></msub>
</math>,
are replaced by</p><div class="informalequation"><math overflow="scroll">
<msub><mi>C'</mi><mi>r</mi></msub><mo>=</mo>
<mi>f</mi>
<msub>
<mi>C</mi>
<mi>r</mi>
</msub>
<mo>+</mo>
<mfenced><mrow><mn>1</mn><mo>-</mo><mi>f</mi></mrow></mfenced>
<msub>
<mi>C</mi>
<mi>f</mi>
</msub>
</math></div><p>Fog does not affect a fragment's alpha component.</p></div><div class="refsect1" title="Errors"><a id="errors"></a><h2>Errors</h2><p><code class="constant">GL_INVALID_ENUM</code> is generated if
<em class="parameter"><code>pname</code></em> is not an accepted value, or if
<em class="parameter"><code>pname</code></em> is
<code class="constant">GL_FOG_MODE</code> and
<em class="parameter"><code>params</code></em> is not an accepted value.</p><p><code class="constant">GL_INVALID_VALUE</code> is generated if
<em class="parameter"><code>pname</code></em> is
<code class="constant">GL_FOG_DENSITY</code>, and
<em class="parameter"><code>params</code></em> is negative.</p></div><div class="refsect1" title="See Also"><a id="seealso"></a><h2>See Also</h2><p>
<a class="citerefentry" href="glEnable"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a>
</p></div><div class="refsect1" title="Copyright"><a id="copyright"></a><h2>Copyright</h2><p>
Copyright © 2003-2004
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>