<?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>glLight</title><meta name="generator" content="DocBook XSL Stylesheets V1.74.0" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="glLight"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glLight — set light source parameters</p></div><div class="refsynopsisdiv"><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 <b class="fsfunc">glLightf</b>(</code></td><td>GLenum <var class="pdparam">light</var>, </td></tr><tr><td> </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 <b class="fsfunc">glLightx</b>(</code></td><td>GLenum <var class="pdparam">light</var>, </td></tr><tr><td> </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" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term">
                    <em class="parameter"><code>light</code></em>
                </span></dt><dd><p>Specifies a light. The number of lights depends on
                    the implementation, but at least eight lights are
                    supported. They are identified by symbolic names of the
                    form <code class="constant">GL_LIGHT</code><em class="replaceable"><code>i</code></em>
                    where
                    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                        <mml:mn>0</mml:mn>
                        <mml:mo>&lt;=</mml:mo>
                        <mml:mi>i</mml:mi>
                        <mml:mo>&lt;</mml:mo>
                        <mml:mi>GL_MAX_LIGHTS</mml:mi>
                    </mml:math>.
                    </p></dd><dt><span class="term">
                    <em class="parameter"><code>pname</code></em>
                </span></dt><dd><p>Specifies a single-valued light source parameter for
                    <em class="parameter"><code>light</code></em>.
                    <code class="constant">GL_SPOT_EXPONENT</code>,
                    <code class="constant">GL_SPOT_CUTOFF</code>,
                    <code class="constant">GL_CONSTANT_ATTENUATION</code>,
                    <code class="constant">GL_LINEAR_ATTENUATION</code>, and
                    <code class="constant">GL_QUADRATIC_ATTENUATION</code>
                    are accepted.</p></dd><dt><span class="term">
                    <em class="parameter"><code>param</code></em>
                </span></dt><dd><p>Specifies the value that parameter <em class="parameter"><code>pname</code></em>
                    of light source <em class="parameter"><code>light</code></em> will be set to.</p></dd></dl></div></div><div class="refsynopsisdiv"><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 <b class="fsfunc">glLightfv</b>(</code></td><td>GLenum <var class="pdparam">light</var>, </td></tr><tr><td> </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 <b class="fsfunc">glLightxv</b>(</code></td><td>GLenum <var class="pdparam">light</var>, </td></tr><tr><td> </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" lang="en" xml:lang="en"><a id="parameters2"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term">
                    <em class="parameter"><code>light</code></em>
                </span></dt><dd><p>Specifies a light. The number of lights depends on
                    the implementation, but at least eight lights are
                    supported. They are identified by symbolic names of the
                    form
                    <code class="constant">GL_LIGHT</code><em class="replaceable"><code>i</code></em>
                    where
                    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                        <mml:mn>0</mml:mn>
                        <mml:mo>&lt;=</mml:mo>
                        <mml:mi>i</mml:mi>
                        <mml:mo>&lt;</mml:mo>
                        <mml:mi>GL_MAX_LIGHTS</mml:mi>
                    </mml:math>.
                    </p></dd><dt><span class="term">
                    <em class="parameter"><code>pname</code></em>
                </span></dt><dd><p>Specifies a light source parameter for
                    <em class="parameter"><code>light</code></em>.
                    <code class="constant">GL_AMBIENT</code>,
                    <code class="constant">GL_DIFFUSE</code>,
                    <code class="constant">GL_SPECULAR</code>,
                    <code class="constant">GL_POSITION</code>,
                    <code class="constant">GL_SPOT_CUTOFF</code>,
                    <code class="constant">GL_SPOT_DIRECTION</code>,
                    <code class="constant">GL_SPOT_EXPONENT</code>,
                    <code class="constant">GL_CONSTANT_ATTENUATION</code>,
                    <code class="constant">GL_LINEAR_ATTENUATION</code>, and
                    <code class="constant">GL_QUADRATIC_ATTENUATION</code> are accepted.</p></dd><dt><span class="term">
                    <em class="parameter"><code>params</code></em>
                </span></dt><dd><p>Specifies a pointer to the value or values that parameter
                    <em class="parameter"><code>pname</code></em> of light source
                    <em class="parameter"><code>light</code></em> will be set to.</p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p><code class="function">glLight</code>
        sets the values of individual light source parameters.
        <em class="parameter"><code>light</code></em>
        names the light and is a symbolic name of the form
        <code class="constant">GL_LIGHT</code><em class="replaceable"><code>i</code></em>,
        where
        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:mn>0</mml:mn>
            <mml:mo>&lt;=</mml:mo>
            <mml:mi>i</mml:mi>
            <mml:mo>&lt;</mml:mo>
            <mml:mi>GL_MAX_LIGHTS</mml:mi>
        </mml:math>.
        <em class="parameter"><code>pname</code></em>
        specifies one of ten light source parameters, again by symbolic
        name.  <em class="parameter"><code>params</code></em>
        is either a single value or a pointer to an array that contains
        the new values.</p><p>To enable and disable lighting calculation, 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_LIGHTING</code>.
        Lighting is initially disabled. When it is enabled, light
        sources that are enabled contribute to the lighting
        calculation. Light source <em class="replaceable"><code>i</code></em>
        is enabled and disabled using
        <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_LIGHT</code><em class="replaceable"><code>i</code></em>.
        </p><p>The ten light parameters are as follows:</p><div class="variablelist"><dl><dt><span class="term">
                    <code class="constant">GL_AMBIENT</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    contains four fixed-point or floating-point values that
                    specify the ambient RGBA intensity of the light. Both
                    fixed-point and floating-point values are mapped
                    directly. Neither fixed-point nor floating-point values
                    are clamped. The initial ambient light intensity is (0,
                    0, 0, 1).</p></dd><dt><span class="term">
                    <code class="constant">GL_DIFFUSE</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    contains four fixed-point or floating-point values that
                    specify the diffuse RGBA intensity of the light. Both
                    fixed-point and floating-point values are mapped
                    directly. Neither fixed-point nor floating-point values
                    are clamped. The initial value for <code class="constant">GL_LIGHT0</code>
                    is (1, 1, 1, 1). For other lights, the initial value is
                    (0, 0, 0, 0).</p></dd><dt><span class="term">
                    <code class="constant">GL_SPECULAR</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    contains four fixed-point or floating-point values that
                    specify the specular RGBA intensity of the light. Both
                    fixed-point and floating-point values are mapped
                    directly. Neither fixed-point nor floating-point values
                    are clamped. The initial value for <code class="constant">GL_LIGHT0</code>
                    is (1, 1, 1, 1). For other lights, the initial value is
                    (0, 0, 0, 0).</p></dd><dt><span class="term"><code class="constant">GL_POSITION</code></span></dt><dd><p>
                        <em class="parameter"><code>params</code></em> contains four fixed-point or floating-point values that specify
                        the position of the light in homogeneous object coordinates.
                        Both fixed-point and floating-point values are mapped directly.
                        Neither fixed-point nor floating-point values are clamped.
                    </p><p>
                        The position is transformed by the modelview matrix when
                        <code class="function">glLight</code> is called (just as if it were a point),
                        and it is stored in eye coordinates.
                        If the 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">w</mml:mi></mml:math>
                        component of the position is 0,
                        the light is treated as a directional source.
                        Diffuse and specular lighting calculations take the light's direction,
                        but not its actual position,
                        into account,
                        and attenuation is disabled.
                        Otherwise,
                        diffuse and specular lighting calculations are based on the actual location
                        of the light in eye coordinates,
                        and attenuation is enabled.
                        The initial position is (0, 0, 1, 0);
                        thus, the initial light source is directional,
                        parallel to, and in the direction of the 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                            
                            <mml:mrow>
                                <mml:mo>-</mml:mo>
                                <mml:mi mathvariant="italic">z</mml:mi>
                            </mml:mrow>
                        </mml:math>
                        axis.
                    </p></dd><dt><span class="term">
                    <code class="constant">GL_SPOT_DIRECTION</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    contains three fixed-point or floating-point values that
                    specify the direction of the light in homogeneous object
                    coordinates. Both fixed-point and floating-point values
                    are mapped directly. Neither fixed-point nor
                    floating-point values are clamped.</p><p>The spot direction is transformed by the upper 3x3 of the
                    modelview matrix when <code class="function">glLight</code>
                    is called, and it is stored in
                    eye coordinates. It is significant only when
                    <code class="constant">GL_SPOT_CUTOFF</code>
                    is not 180, which it is initially. The initial direction is (0,
                    0, -1).</p></dd><dt><span class="term">
                    <code class="constant">GL_SPOT_EXPONENT</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    is a single fixed-point or floating-point value that
                    specifies the intensity distribution of the light.
                    Fixed-point and floating-point values are mapped
                    directly. Only values in the range [0, 128] are
                    accepted.</p><p>Effective light intensity is attenuated by the cosine of
                    the angle between the direction of the light and the direction
                    from the light to the vertex being lighted, raised to the power
                    of the spot exponent. Thus, higher spot exponents result in a
                    more focused light source, regardless of the spot cutoff angle
                    (see <code class="constant">GL_SPOT_CUTOFF</code>,
                    next paragraph). The initial spot exponent is 0, resulting in
                    uniform light distribution.</p></dd><dt><span class="term">
                    <code class="constant">GL_SPOT_CUTOFF</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    is a single fixed-point or floating-point value that
                    specifies the maximum spread angle of a light source.
                    Fixed-point and floating-point values are mapped
                    directly. Only values in the range [0, 90] and the special
                    value 180 are accepted. If the angle between the
                    direction of the light and the direction from the light
                    to the vertex being lighted is greater than the spot
                    cutoff angle, the light is completely masked.
                    Otherwise, its intensity is controlled by the spot
                    exponent and the attenuation factors. The initial spot
                    cutoff is 180, resulting in uniform light
                    distribution.</p></dd><dt><span class="term">
                    <code class="constant">GL_CONSTANT_ATTENUATION</code>,
                    <code class="constant">GL_LINEAR_ATTENUATION</code>,
                    <code class="constant">GL_QUADRATIC_ATTENUATION</code>
                </span></dt><dd><p><em class="parameter"><code>params</code></em>
                    is a single fixed-point or floating-point value that
                    specifies one of the three light attenuation factors.
                    Fixed-point and floating-point values are mapped
                    directly. Only nonnegative values are accepted. If the
                    light is positional, rather than directional, its
                    intensity is attenuated by the reciprocal of the sum of
                    the constant factor, the linear factor times the distance
                    between the light and the vertex being lighted, and the
                    quadratic factor times the square of the same distance.
                    The initial attenuation factors are (1, 0, 0), resulting
                    in no attenuation.</p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p>It is always the case that
        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
            <mml:mi>GL_LIGHT</mml:mi><mml:mi>i</mml:mi> <mml:mo>=</mml:mo>
            <mml:mi>GL_LIGHT0</mml:mi><mml:mo>+</mml:mo><mml:mi>i</mml:mi>
        </mml:math>.
        </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p><code class="constant">GL_INVALID_ENUM</code> is generated if either
        <em class="parameter"><code>light</code></em> or
        <em class="parameter"><code>pname</code></em> is not an accepted value.</p><p> <code class="constant">GL_INVALID_VALUE</code>
        is generated if a spot exponent value is specified outside the
        range [0, 128], or if spot cutoff is specified outside the range
        [0, 90] (except for the special value 180), or if a negative
        attenuation factor is specified.</p></div><div class="refsect1" lang="en" xml:lang="en"><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>,
        <a class="citerefentry" href="glLightModel.xml"><span class="citerefentry"><span class="refentrytitle">glLightModel</span></span></a>,
        <a class="citerefentry" href="glMaterial.xml"><span class="citerefentry"><span class="refentrytitle">glMaterial</span></span></a>
        </p></div><div class="refsect1" lang="en" xml:lang="en"><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>
