<!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.73.2" /></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"><tr><td><code class="funcdef">void <b class="fsfunc">glLightf</b>(</code></td><td>GLenum  </td><td><var class="pdparam">light</var>, </td></tr><tr><td> </td><td>GLenum  </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfloat  </td><td><var class="pdparam">param</var><code>)</code>;</td></tr></table></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">glLighti</b>(</code></td><td>GLenum  </td><td><var class="pdparam">light</var>, </td></tr><tr><td> </td><td>GLenum  </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLint  </td><td><var class="pdparam">param</var><code>)</code>;</td></tr></table></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>
                    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">i</mml:mi></mml:math>,
                    where i ranges from 0 to the value of <code class="constant">GL_MAX_LIGHTS</code> - 1.
                </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"><tr><td><code class="funcdef">void <b class="fsfunc">glLightfv</b>(</code></td><td>GLenum  </td><td><var class="pdparam">light</var>, </td></tr><tr><td> </td><td>GLenum  </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLfloat *  </td><td><var class="pdparam">params</var><code>)</code>;</td></tr></table></div><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">glLightiv</b>(</code></td><td>GLenum  </td><td><var class="pdparam">light</var>, </td></tr><tr><td> </td><td>GLenum  </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLint *  </td><td><var class="pdparam">params</var><code>)</code>;</td></tr></table></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>
                    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">i</mml:mi></mml:math>,
                    where i ranges from 0 to the value of <code class="constant">GL_MAX_LIGHTS</code> - 1.
                </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>
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">i</mml:mi></mml:math>,
            where i ranges from 0 to the value of <code class="constant">GL_MAX_LIGHTS</code> - 1.
            <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 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">i</mml:mi></mml:math>
            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>
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">i</mml:mi></mml:math>.
        </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 integer or floating-point values that specify
                        the ambient RGBA intensity of the light.
                        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.
                        Neither integer 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 integer or floating-point values that specify
                        the diffuse RGBA intensity of the light.
                        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.
                        Neither integer 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, 1).
                    </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 integer or floating-point values that specify
                        the specular RGBA intensity of the light.
                        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.
                        Neither integer 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, 1).
                    </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 integer or floating-point values that specify
                        the position of the light in homogeneous object coordinates.
                        Both integer and floating-point values are mapped directly.
                        Neither integer 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 integer or floating-point values that specify
                        the direction of the light in homogeneous object coordinates.
                        Both integer and floating-point values are mapped directly.
                        Neither integer 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 
                        <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                            
                            <mml:mfenced open="(" close=")">
                                <mml:mn>0</mml:mn>
                                <mml:mn>0</mml:mn>
                                <mml:mn>-1</mml:mn>
                            </mml:mfenced>
                        </mml:math>.
                    </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 integer or floating-point value that specifies
                        the intensity distribution of the light.
                        Integer and floating-point values are mapped directly.
                        Only values in 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>128</mml:mn>
                            </mml:mfenced>
                        </mml:math>
                        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 integer or floating-point value that specifies
                        the maximum spread angle of a light source.
                        Integer and floating-point values are mapped directly.
                        Only values in 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>90</mml:mn>
                            </mml:mfenced>
                        </mml:math>
                        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></span></dt><dd></dd><dt><span class="term"><code class="constant">GL_LINEAR_ATTENUATION</code></span></dt><dd></dd><dt><span class="term"><code class="constant">GL_QUADRATIC_ATTENUATION</code></span></dt><dd><p>
                        <em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
                        one of the three light attenuation factors.
                        Integer 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 <code class="constant">GL_LIGHT</code>
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">i</mml:mi></mml:math>
            = <code class="constant">GL_LIGHT0</code> + 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">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 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mfenced open="[" close="]">
                    <mml:mn>0</mml:mn>
                    <mml:mn>128</mml:mn>
                </mml:mfenced>
            </mml:math>,
            or if spot cutoff is specified outside 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>90</mml:mn>
                </mml:mfenced>
            </mml:math>
            (except for the
            special value 180),
            or if a negative attenuation factor is specified.
        </p><p>
            <code class="constant">GL_INVALID_OPERATION</code> is generated if <code class="function">glLight</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" lang="en" xml:lang="en"><a id="associatedgets"></a><h2>Associated Gets</h2><p>
            <a class="citerefentry" href="glGetLight.xml"><span class="citerefentry"><span class="refentrytitle">glGetLight</span></span></a>
        </p><p>
            <a class="citerefentry" href="glIsEnabled.xml"><span class="citerefentry"><span class="refentrytitle">glIsEnabled</span></span></a> with argument <code class="constant">GL_LIGHTING</code>
        </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p>
            <a class="citerefentry" href="glColorMaterial.xml"><span class="citerefentry"><span class="refentrytitle">glColorMaterial</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>© 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>
