<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:mml="http://www.w3.org/1998/Math/MathML"
><head><title>glLight</title><link rel="stylesheet" href="style.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"/><link rel="home" href="index.xml" title="PyOpenGL 2.0.1.07 Man Pages"/><link rel="up" href="reference-GL.xml" title="GL"/><link rel="previous" href="glIsTexture.3G.xml" title="glIsTexture"/><link rel="next" href="glLightModel.3G.xml" title="glLightModel"/></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">glLight</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="glIsTexture.3G.xml">Prev</a> </td><th width="60%" align="center">GL</th><td width="20%" align="right"> <a accesskey="n" href="glLightModel.3G.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="glLight.3G"/><div class="titlepage"/><div class="refnamediv"><a name="glLight.3G-name"/><h2>Name</h2><p>glLightf, glLighti, glLightfv, glLightiv &#8212; set light source parameters</p></div><div class="refsynopsisdiv"><a name="glLight.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>void <tt>glLightf</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLenum <i><tt>light</tt></i>, GLenum <i><tt>pname</tt></i>, GLfloat <i><tt>param</tt></i>);</code></td></tr><tr><td valign="top"><code>void <tt>glLighti</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLenum <i><tt>light</tt></i>, GLenum <i><tt>pname</tt></i>, GLint <i><tt>param</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="glLight.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>glLightf</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>light</tt></i>, <i><tt>pname</tt></i>, <i><tt>param</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>glLighti</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>light</tt></i>, <i><tt>pname</tt></i>, <i><tt>param</tt></i>) &#8594; <tt>None</tt></code></td></tr></table></div><div class="refsect1" lang="en"><a name="glLight.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>light</tt></i></span></dt><dd>
						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 <tt>GL_LIGHT</tt><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>i</mml:mi>
							</mml:math> where 0 &#8804; <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>i</mml:mi>
							</mml:math> &lt; <tt>GL_MAX_LIGHTS</tt>.
					</dd><dt><span class="term"><i><tt>pname</tt></i></span></dt><dd>
						Specifies a single-valued light source parameter for <i><tt>light</tt></i>.
						<tt>GL_SPOT_EXPONENT</tt>, <tt>GL_SPOT_CUTOFF</tt>,
						<tt>GL_CONSTANT_ATTENUATION</tt>, <tt>GL_LINEAR_ATTENUATION</tt>, and
						<tt>GL_QUADRATIC_ATTENUATION</tt> are accepted.
					</dd><dt><span class="term"><i><tt>param</tt></i></span></dt><dd>
						Specifies the value that parameter <i><tt>pname</tt></i> of light source
						<i><tt>light</tt></i> will be set to.
					</dd></dl></div></div><div class="refsynopsisdiv"><a name="glLight.3G-c_spec-v"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>void <tt>glLightfv</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLenum <i><tt>light</tt></i>, GLenum <i><tt>pname</tt></i>, const GLfloat *<i><tt>params</tt></i>);</code></td></tr><tr><td valign="top"><code>void <tt>glLightiv</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLenum <i><tt>light</tt></i>, GLenum <i><tt>pname</tt></i>, const GLint *<i><tt>params</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="glLight.3G-python_spec-v"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>glLightfv</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>light</tt></i>, <i><tt>pname</tt></i>, <i><tt>params</tt></i>) &#8594; <tt>None</tt></code></td></tr><tr><td valign="top"><code><tt>glLightiv</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>light</tt></i>, <i><tt>pname</tt></i>, <i><tt>params</tt></i>) &#8594; <tt>None</tt></code></td></tr></table></div><div class="refsect1" lang="en"><a name="glLight.3G-parameters-v"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>light</tt></i></span></dt><dd>
						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 <tt>GL_LIGHT</tt><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>i</mml:mi>
							</mml:math> where 0 &#8804; <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>i</mml:mi>
							</mml:math> &lt; <tt>GL_MAX_LIGHTS</tt>.
					</dd><dt><span class="term"><i><tt>pname</tt></i></span></dt><dd>
						Specifies a light source parameter for <i><tt>light</tt></i>. <tt>GL_AMBIENT</tt>,
						<tt>GL_DIFFUSE</tt>, <tt>GL_SPECULAR</tt>, <tt>GL_POSITION</tt>,
						<tt>GL_SPOT_CUTOFF</tt>, <tt>GL_SPOT_DIRECTION</tt>,
						<tt>GL_SPOT_EXPONENT</tt>, <tt>GL_CONSTANT_ATTENUATION</tt>,
						<tt>GL_LINEAR_ATTENUATION</tt>, and <tt>GL_QUADRATIC_ATTENUATION</tt> are accepted.
					</dd><dt><span class="term"><i><tt>params</tt></i></span></dt><dd>
						Specifies a pointer to the value or values that parameter <i><tt>pname</tt></i> of light source
						<i><tt>light</tt></i> will be set to.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="glLight.3G-description"/><h2>Description</h2><p>
			<tt>glLight</tt> sets the values of individual light source parameters.
			<i><tt>light</tt></i> names the light and is a symbolic name of the form
			<tt>GL_LIGHT</tt><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math>, where 0 &#8804; i &lt; <tt>GL_MAX_LIGHTS</tt>. <i><tt>pname</tt></i> specifies one
			of ten light source parameters, again by symbolic name. <i><tt>params</tt></i> 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 href="glEnable.3G.xml"><tt>glEnable</tt></a> and <a href="glEnable.3G.xml"><tt>glDisable</tt></a> with argument <tt>GL_LIGHTING</tt>. 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>i</mml:mi>
				</mml:math> is enabled and disabled using <a href="glEnable.3G.xml"><tt>glEnable</tt></a> and <a href="glEnable.3G.xml"><tt>glDisable</tt></a> with argument <tt>GL_LIGHT</tt><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math>.
		</p><p>
			The ten light parameters are as follows:
		</p><div class="variablelist"><dl><dt><span class="term"><tt>GL_AMBIENT</tt></span></dt><dd>
						<i><tt>params</tt></i> 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 -1.0. Floating-point values are mapped
						directly. Neither integer nor floating-point values are clamped. The initial ambient light intensity is (0,
						0, 0, 1).
					</dd><dt><span class="term"><tt>GL_DIFFUSE</tt></span></dt><dd>
						<i><tt>params</tt></i> 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 -1.0. Floating-point values are mapped
						directly. Neither integer nor floating-point values are clamped. The initial value for
						<tt>GL_LIGHT0</tt> is (1, 1, 1, 1); for other lights, the initial value is (0, 0, 0, 0).
					</dd><dt><span class="term"><tt>GL_SPECULAR</tt></span></dt><dd>
						<i><tt>params</tt></i> 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 -1.0. Floating-point values are mapped
						directly. Neither integer nor floating-point values are clamped. The initial value for
						<tt>GL_LIGHT0</tt> is (1, 1, 1, 1); for other lights, the initial value is (0, 0, 0, 0).
					</dd><dt><span class="term"><tt>GL_POSITION</tt></span></dt><dd><p>
						<i><tt>params</tt></i> 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 <tt>glLight</tt>
						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>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:mo>-z</mml:mo>
							</mml:math> axis.
					</p></dd><dt><span class="term"><tt>GL_SPOT_DIRECTION</tt></span></dt><dd><p>
						<i><tt>params</tt></i> 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 inverse of the modelview matrix when <tt>glLight</tt> is called (just as if it were a normal), and it is stored in eye
						coordinates. It is significant only when <tt>GL_SPOT_CUTOFF</tt> is not 180, which it is
						initially. The initial direction is (0, 0, -1).
					</p></dd><dt><span class="term"><tt>GL_SPOT_EXPONENT</tt></span></dt><dd><p>
						<i><tt>params</tt></i> 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
						[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
						<tt>GL_SPOT_CUTOFF</tt>, next paragraph). The initial spot exponent is 0, resulting in uniform
						light distribution.
					</p></dd><dt><span class="term"><tt>GL_SPOT_CUTOFF</tt></span></dt><dd>
						<i><tt>params</tt></i> 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
						[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.
					</dd><dt><span class="term"><tt>GL_LINEAR_ATTENUATION</tt>, </span><span class="term"><tt>GL_QUADRATIC_ATTENUATION</tt>, </span><span class="term"><tt>GL_CONSTANT_ATTENUATION</tt></span></dt><dd>
						<i><tt>params</tt></i> 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.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="glLight.3G-notes"/><h2>Notes</h2><p>
			It is always the case that <tt>GL_LIGHT</tt><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math> = <tt>GL_LIGHT0</tt> + <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math>.
		</p></div><div class="refsect1" lang="en"><a name="glLight.3G-errors"/><h2>Errors</h2><p>
			<tt>GL_INVALID_ENUM</tt> is generated if either <i><tt>light</tt></i> or
			<i><tt>pname</tt></i> is not an accepted value.
		</p><p>
			<tt>GL_INVALID_VALUE</tt> 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><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <tt>glLight</tt> is executed
			between the execution of <a href="glBegin.3G.xml"><tt>glBegin</tt></a> and the corresponding execution of <a href="glBegin.3G.xml"><tt>glEnd</tt></a>.
		</p></div><div class="refsect1" lang="en"><a name="glLight.3G-associated_gets"/><h2>Associated Gets</h2><p>
			<tt>glGetLight</tt>
		</p><p>
			<a href="glIsEnabled.3G.xml"><tt>glIsEnabled</tt></a> with argument <tt>GL_LIGHTING</tt>
		</p></div><div class="refsect1" lang="en"><a name="glLight.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glColorMaterial.3G.xml">glColorMaterial</a>, <a href="glLightModel.3G.xml">glLightModel</a>, <a href="glMaterial.3G.xml">glMaterial</a></span>
		</p></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="glIsTexture.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GL.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="glLightModel.3G.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">glIsTexture </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> glLightModel</td></tr></table></div></body></html>
