<?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.78.1" /></head><body><div class="refentry"><a id="glFog"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glFog — specify fog parameters</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <strong class="fsfunc">glFogf</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></div><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <strong class="fsfunc">glFogi</strong>(</code></td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLint <var class="pdparam">param</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><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>,
                    <code class="constant">GL_FOG_END</code>,
                    <code class="constant">GL_FOG_INDEX</code>, and
                    <code class="constant">GL_FOG_COORD_SRC</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"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <strong class="fsfunc">glFogfv</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></div><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <strong class="fsfunc">glFogiv</strong>(</code></td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLint * <var class="pdparam">params</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a id="parameters2"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><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>,
                    <code class="constant">GL_FOG_INDEX</code>,
                    <code class="constant">GL_FOG_COLOR</code>, and
                    <code class="constant">GL_FOG_COORD_SRC</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"><a id="description"></a><h2>Description</h2><p>
            Fog is initially disabled.
            While 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>.
        </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 class="variablelist"><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 integer or floating-point value that specifies
                        the equation to be used to compute the fog blend factor, 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">f</mml:mi></mml:math>.
                        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 integer or floating-point value that specifies 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">density</mml:mi></mml:math>,
                        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 integer or floating-point value that specifies 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">start</mml:mi></mml:math>,
                        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 integer or floating-point value that specifies 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">end</mml:mi></mml:math>,
                        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_INDEX</code></span></dt><dd><p>
                        <em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                            
                            <mml:msub><mml:mi mathvariant="italic">i</mml:mi>
                            <mml:mi mathvariant="italic">f</mml:mi>
                            </mml:msub>
                        </mml:math>,
                        the fog color index.
                        The initial fog index is 0.
                    </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 integer or floating-point values that specify
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                            
                            <mml:msub><mml:mi mathvariant="italic">C</mml:mi>
                            <mml:mi mathvariant="italic">f</mml:mi>
                            </mml:msub>
                        </mml:math>,
                        the fog color.
                        Integer values are mapped linearly such that the most positive representable
                        value maps to 1.0,
                        and the most negative representable value maps to 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                            
                            <mml:mn>-1.0</mml:mn>
                        </mml:math>.
                        Floating-point values are mapped directly.
                        After conversion,
                        all color components are clamped to the range 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                            
                            <mml:mfenced open="[" close="]">
                                <mml:mn>0</mml:mn>
                                <mml:mn>1</mml:mn>
                            </mml:mfenced>
                        </mml:math>.
                        The initial fog color is (0, 0, 0, 0).
                    </p></dd><dt><span class="term"><code class="constant">GL_FOG_COORD_SRC</code></span></dt><dd><p>
                        <em class="parameter"><code>params</code></em> contains either of the following symbolic constants:
                        <code class="constant">GL_FOG_COORD</code> or <code class="constant">GL_FRAGMENT_DEPTH</code>.  <code class="constant">GL_FOG_COORD</code>
                        specifies that the current fog coordinate should be used as distance value
                        in the fog color computation.  <code class="constant">GL_FRAGMENT_DEPTH</code> specifies that the
                        current fragment depth should be used as distance value in the fog
                        computation.
                    </p></dd></dl></div><p>
            Fog blends a fog color with each rasterized pixel fragment's post-texturing
            color using a blending factor 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">f</mml:mi></mml:math>.
            Factor 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">f</mml:mi></mml:math>
            is computed in one of three ways,
            depending on the fog mode.
            Let 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">c</mml:mi></mml:math>
            be either the distance in eye coordinate from the origin (in the
            case that the <code class="constant">GL_FOG_COORD_SRC</code> is <code class="constant">GL_FRAGMENT_DEPTH</code>) or
            the current fog coordinate (in the case that <code class="constant">GL_FOG_COORD_SRC</code>
            is <code class="constant">GL_FOG_COORD</code>).
            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:mrow>
                    <mml:mi mathvariant="italic">f</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:mfrac>
                        <mml:mfenced open="" close="">
                            <mml:mrow>
                                <mml:mi mathvariant="italic">end</mml:mi>
                                <mml:mo>-</mml:mo>
                                <mml:mi mathvariant="italic">c</mml:mi>
                            </mml:mrow>
                        </mml:mfenced>
                        <mml:mfenced open="" close="">
                            <mml:mrow>
                                <mml:mi mathvariant="italic">end</mml:mi>
                                <mml:mo>-</mml:mo>
                                <mml:mi mathvariant="italic">start</mml:mi>
                            </mml:mrow>
                        </mml:mfenced>
                    </mml:mfrac>
                </mml:mrow>
            </mml:math></div><p>
        </p><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:mrow>
                    <mml:mi mathvariant="italic">f</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:msup><mml:mi mathvariant="italic">e</mml:mi>
                    <mml:mfenced open="" close="">
                        <mml:mrow>
                            <mml:mo>-</mml:mo>
                            <mml:mfenced open="(" close=")">
                                <mml:mrow>
                                    <mml:mi mathvariant="italic">density</mml:mi>
                                    <mml:mo>·</mml:mo>
                                    <mml:mi mathvariant="italic">c</mml:mi>
                                </mml:mrow>
                            </mml:mfenced>
                        </mml:mrow>
                    </mml:mfenced>
                    </mml:msup>
                </mml:mrow>
            </mml:math></div><p>
        </p><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:mrow>
                    <mml:mi mathvariant="italic">f</mml:mi>
                    <mml:mo>=</mml:mo>
                    <mml:msup><mml:mi mathvariant="italic">e</mml:mi>
                    <mml:msup><mml:mfenced open="" close="">
                        <mml:mrow>
                            <mml:mo>-</mml:mo>
                            <mml:mfenced open="(" close=")">
                                <mml:mrow>
                                    <mml:mi mathvariant="italic">density</mml:mi>
                                    <mml:mo>·</mml:mo>
                                    <mml:mi mathvariant="italic">c</mml:mi>
                                </mml:mrow>
                            </mml:mfenced>
                        </mml:mrow>
                    </mml:mfenced>
                    <mml:mn>2</mml:mn>
                    </mml:msup></mml:msup>
                </mml:mrow>
            </mml:math></div><p>
        </p><p>
            Regardless of the fog mode,
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">f</mml:mi></mml:math>
            is clamped to the range 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mfenced open="[" close="]">
                    <mml:mn>0</mml:mn>
                    <mml:mn>1</mml:mn>
                </mml:mfenced>
            </mml:math>
            after it is computed.
            Then,
            if the GL is in RGBA color mode,
            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 mathvariant="italic">C</mml:mi>
                <mml:mi mathvariant="italic">r</mml:mi>
                </mml:msub>
            </mml:math>,
            are replaced by
        </p><p>
            </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mrow>
                    <mml:msup><mml:mfenced open="" close="">
                        <mml:msub><mml:mi mathvariant="italic">C</mml:mi>
                        <mml:mi mathvariant="italic">r</mml:mi>
                        </mml:msub>
                    </mml:mfenced>
                    <mml:mo>″</mml:mo>
                    </mml:msup>
                    <mml:mo>=</mml:mo>
                    <mml:mrow>
                        <mml:mrow>
                            <mml:mi mathvariant="italic">f</mml:mi>
                            <mml:mo>×</mml:mo>
                            <mml:msub><mml:mi mathvariant="italic">C</mml:mi>
                            <mml:mi mathvariant="italic">r</mml:mi>
                            </mml:msub>
                        </mml:mrow>
                        <mml:mo>+</mml:mo>
                        <mml:mrow>
                            <mml:mfenced open="(" close=")">
                                <mml:mrow>
                                    <mml:mn>1</mml:mn>
                                    <mml:mo>-</mml:mo>
                                    <mml:mi mathvariant="italic">f</mml:mi>
                                </mml:mrow>
                            </mml:mfenced>
                            <mml:mo>×</mml:mo>
                            <mml:msub><mml:mi mathvariant="italic">C</mml:mi>
                            <mml:mi mathvariant="italic">f</mml:mi>
                            </mml:msub>
                        </mml:mrow>
                    </mml:mrow>
                </mml:mrow>
            </mml:math></div><p>
        </p><p>
            Fog does not affect a fragment's alpha component.
        </p><p>
            In color index mode, the fragment's color index 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:msub><mml:mi mathvariant="italic">i</mml:mi>
                <mml:mi mathvariant="italic">r</mml:mi>
                </mml:msub>
            </mml:math>
            is replaced by
        </p><p>
            </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mrow>
                    <mml:msup><mml:mfenced open="" close="">
                        <mml:msub><mml:mi mathvariant="italic">i</mml:mi>
                        <mml:mi mathvariant="italic">r</mml:mi>
                        </mml:msub>
                    </mml:mfenced>
                    <mml:mo>″</mml:mo>
                    </mml:msup>
                    <mml:mo>=</mml:mo>
                    <mml:mrow>
                        <mml:msub><mml:mi mathvariant="italic">i</mml:mi>
                        <mml:mi mathvariant="italic">r</mml:mi>
                        </mml:msub>
                        <mml:mo>+</mml:mo>
                        <mml:mrow>
                            <mml:mfenced open="(" close=")">
                                <mml:mrow>
                                    <mml:mn>1</mml:mn>
                                    <mml:mo>-</mml:mo>
                                    <mml:mi mathvariant="italic">f</mml:mi>
                                </mml:mrow>
                            </mml:mfenced>
                            <mml:mo>×</mml:mo>
                            <mml:msub><mml:mi mathvariant="italic">i</mml:mi>
                            <mml:mi mathvariant="italic">f</mml:mi>
                            </mml:msub>
                        </mml:mrow>
                    </mml:mrow>
                </mml:mrow>
            </mml:math></div><p>
        </p><p>
        </p></div><div class="refsect1"><a id="notes"></a><h2>Notes</h2><p>
            <code class="constant">GL_FOG_COORD_SRC</code> is available only if the GL version is 1.4 or
            greater.
        </p></div><div class="refsect1"><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><p>
            <code class="constant">GL_INVALID_OPERATION</code> is generated if <code class="function">glFog</code>
            is executed between the execution of <a class="citerefentry" href="glBegin.xml"><span class="citerefentry"><span class="refentrytitle">glBegin</span></span></a>
            and the corresponding execution of <a class="citerefentry" href="glEnd.xml"><span class="citerefentry"><span class="refentrytitle">glEnd</span></span></a>.
        </p></div><div class="refsect1"><a id="associatedgets"></a><h2>Associated Gets</h2><p>
            <a class="citerefentry" href="glIsEnabled.xml"><span class="citerefentry"><span class="refentrytitle">glIsEnabled</span></span></a> with argument <code class="constant">GL_FOG</code>
        </p><p>
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_COLOR</code>
        </p><p>
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_INDEX</code>
        </p><p>
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_DENSITY</code>
        </p><p>
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_START</code>
        </p><p>
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_END</code>
        </p><p>
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_MODE</code>
        </p></div><div class="refsect1"><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"><a id="Copyright"></a><h2>Copyright</h2><p>
            Copyright <span class="trademark"></span>© 1991-2006
            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>