forked from BSVino/docs.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glLight.xhtml
221 lines (220 loc) · 17.5 KB
/
glLight.xhtml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<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 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 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
<math overflow="scroll">
<mn>0</mn>
<mo><=</mo>
<mi>i</mi>
<mo><</mo>
<mi>GL_MAX_LIGHTS</mi>
</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 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 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
<math overflow="scroll">
<mn>0</mn>
<mo><=</mo>
<mi>i</mi>
<mo><</mo>
<mi>GL_MAX_LIGHTS</mi>
</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
<math overflow="scroll">
<mn>0</mn>
<mo><=</mo>
<mi>i</mi>
<mo><</mo>
<mi>GL_MAX_LIGHTS</mi>
</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"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a> and
<a class="citerefentry" href="glDisable"><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"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a> and
<a class="citerefentry" href="glDisable"><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
<math overflow="scroll"><mi mathvariant="italic">w</mi></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
<math overflow="scroll">
<mrow>
<mo>-</mo>
<mi mathvariant="italic">z</mi>
</mrow>
</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
<math overflow="scroll">
<mi>GL_LIGHT</mi><mi>i</mi> <mo>=</mo>
<mi>GL_LIGHT0</mi><mo>+</mo><mi>i</mi>
</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"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a>,
<a class="citerefentry" href="glLightModel"><span class="citerefentry"><span class="refentrytitle">glLightModel</span></span></a>,
<a class="citerefentry" href="glMaterial"><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 © 2003-2004
Silicon Graphics, Inc. This document is licensed under the SGI
Free Software B License. For details, see
<a class="ulink" href="https://web.archive.org/web/20171022161616/http://oss.sgi.com/projects/FreeB/" target="_top">https://web.archive.org/web/20171022161616/http://oss.sgi.com/projects/FreeB/</a>.
</p></div></div>