1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
<?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 — 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>) →<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>) →<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 ≤ <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
<mml:mi>i</mml:mi>
</mml:math> < <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>, constGLfloat*<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>, constGLint*<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>) →<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>) →<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 ≤ <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
<mml:mi>i</mml:mi>
</mml:math> < <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 ≤ i < <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>
|