<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd">
<!-- saved from url=(0013)about:internet -->
<?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>glFog</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /></head><body><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 border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <strong>fsfuncglFogf</strong>(</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 border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <strong>fsfuncglFogx</strong>(</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 border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <strong>fsfuncglFogfv</strong>(</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 border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <strong>fsfuncglFogxv</strong>(</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.xml"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a> and
        <a class="citerefentry" href="glDisable.xml"><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
                    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                        <mml:msub><mml:mi>C</mml:mi><mml:mi>f</mml:mi></mml:msub>
                    </mml: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"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:mi>f</mml:mi><mml:mo>=</mml:mo>
            <mml:mfrac>
                <mml:mrow><mml:mi>end</mml:mi><mml:mo>-</mml:mo><mml:mi>z</mml:mi></mml:mrow>
                <mml:mrow><mml:mi>end</mml:mi><mml:mo>-</mml:mo><mml:mi>start</mml:mi></mml:mrow>
            </mml:mfrac>
        </mml:math></div><p>The equation for <code class="constant">GL_EXP</code> fog is</p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:mi>f</mml:mi><mml:mo>=</mml:mo>
            <mml:msup>
                <mml:mi>e</mml:mi>
                <mml:mrow><mml:mo>-</mml:mo><mml:mo>(</mml:mo><mml:mi>density</mml:mi><mml:mo>-</mml:mo><mml:mi>z</mml:mi><mml:mo>)</mml:mo></mml:mrow>
            </mml:msup>
        </mml:math></div><p>The equation for <code class="constant">GL_EXP2</code> fog is</p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:mi>f</mml:mi><mml:mo>=</mml:mo>
            <mml:msup>
                <mml:mi>e</mml:mi>
                <mml:msup>
                    <mml:mrow><mml:mo>-</mml:mo><mml:mo>(</mml:mo><mml:mi>density</mml:mi><mml:mo>-</mml:mo><mml:mi>z</mml:mi><mml:mo>)</mml:mo></mml:mrow>
                    <mml:mn>2</mml:mn>
                </mml:msup>
            </mml:msup>
        </mml: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
        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:msub><mml:mi>C</mml:mi><mml:mi>r</mml:mi></mml:msub>
        </mml:math>,
        are replaced by</p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:msub><mml:mi>C'</mml:mi><mml:mi>r</mml:mi></mml:msub><mml:mo>=</mml:mo>
            <mml:mi>f</mml:mi>
            <mml:msub>
                <mml:mi>C</mml:mi>
                <mml:mi>r</mml:mi>
            </mml:msub>
            <mml:mo>+</mml:mo>
            <mml:mfenced><mml:mrow><mml:mn>1</mml:mn><mml:mo>-</mml:mo><mml:mi>f</mml:mi></mml:mrow></mml:mfenced>
            <mml:msub>
                <mml:mi>C</mml:mi>
                <mml:mi>f</mml:mi>
            </mml:msub>
        </mml: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.xml"><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 <span class="trademark"></span>© 2003-2004
            Silicon Graphics, Inc. This document is licensed under the SGI
            Free Software B License. For details, see
            <a class="ulink" href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>.
        </p></div></div></body></html>
