1GLLIGHT(3G) GLLIGHT(3G)
2
3
4
6 glLightf, glLighti, glLightfv, glLightiv - set light source parameters
7
8
10 void glLightf( GLenum light,
11 GLenum pname,
12 GLfloat param )
13 void glLighti( GLenum light,
14 GLenum pname,
15 GLint param )
16
17
19 light Specifies a light. The number of lights depends on the imple‐
20 mentation, but at least eight lights are supported. They are
21 identified by symbolic names of the form GL_LIGHTi where 0 ≤ i
22 < GL_MAX_LIGHTS.
23
24 pname Specifies a single-valued light source parameter for light.
25 GL_SPOT_EXPONENT, GL_SPOT_CUTOFF, GL_CONSTANT_ATTENUATION,
26 GL_LINEAR_ATTENUATION, and GL_QUADRATIC_ATTENUATION are
27 accepted.
28
29 param Specifies the value that parameter pname of light source light
30 will be set to.
31
33 void glLightfv( GLenum light,
34 GLenum pname,
35 const GLfloat *params )
36 void glLightiv( GLenum light,
37 GLenum pname,
38 const GLint *params )
39
40
42 light Specifies a light. The number of lights depends on the imple‐
43 mentation, but at least eight lights are supported. They are
44 identified by symbolic names of the form GL_LIGHTi where 0 ≤ i <
45 GL_MAX_LIGHTS.
46
47 pname Specifies a light source parameter for light. GL_AMBIENT,
48 GL_DIFFUSE, GL_SPECULAR, GL_POSITION, GL_SPOT_CUTOFF,
49 GL_SPOT_DIRECTION, GL_SPOT_EXPONENT, GL_CONSTANT_ATTENUATION,
50 GL_LINEAR_ATTENUATION, and GL_QUADRATIC_ATTENUATION are
51 accepted.
52
53 params Specifies a pointer to the value or values that parameter pname
54 of light source light will be set to.
55
57 glLight sets the values of individual light source parameters. light
58 names the light and is a symbolic name of the form GL_LIGHTi, where 0 ≤
59 i < GL_MAX_LIGHTS. pname specifies one of ten light source parameters,
60 again by symbolic name. params is either a single value or a pointer
61 to an array that contains the new values.
62
63 To enable and disable lighting calculation, call glEnable and glDisable
64 with argument GL_LIGHTING. Lighting is initially disabled. When it is
65 enabled, light sources that are enabled contribute to the lighting cal‐
66 culation. Light source i is enabled and disabled using glEnable and
67 glDisable with argument GL_LIGHTi.
68
69 The ten light parameters are as follows:
70
71 GL_AMBIENT params contains four integer or floating-point val‐
72 ues that specify the ambient RGBA intensity of the
73 light. Integer values are mapped linearly such
74 that the most positive representable value maps to
75 1.0, and the most negative representable value maps
76 to -1.0. Floating-point values are mapped
77 directly. Neither integer nor floating-point val‐
78 ues are clamped. The initial ambient light inten‐
79 sity is (0, 0, 0, 1).
80
81 GL_DIFFUSE params contains four integer or floating-point val‐
82 ues that specify the diffuse RGBA intensity of the
83 light. Integer values are mapped linearly such
84 that the most positive representable value maps to
85 1.0, and the most negative representable value maps
86 to -1.0. Floating-point values are mapped
87 directly. Neither integer nor floating-point val‐
88 ues are clamped. The initial value for GL_LIGHT0
89 is (1, 1, 1, 1); for other lights, the initial
90 value is (0, 0, 0, 0).
91
92 GL_SPECULAR params contains four integer or floating-point val‐
93 ues that specify the specular RGBA intensity of the
94 light. Integer values are mapped linearly such
95 that the most positive representable value maps to
96 1.0, and the most negative representable value maps
97 to -1.0. Floating-point values are mapped
98 directly. Neither integer nor floating-point val‐
99 ues are clamped. The initial value for GL_LIGHT0
100 is (1, 1, 1, 1); for other lights, the initial
101 value is (0, 0, 0, 0).
102
103 GL_POSITION params contains four integer or floating-point val‐
104 ues that specify the position of the light in homo‐
105 geneous object coordinates. Both integer and
106 floating-point values are mapped directly. Neither
107 integer nor floating-point values are clamped.
108
109 The position is transformed by the modelview matrix
110 when glLight is called (just as if it were a
111 point), and it is stored in eye coordinates. If
112 the w component of the position is 0, the light is
113 treated as a directional source. Diffuse and spec‐
114 ular lighting calculations take the light's direc‐
115 tion, but not its actual position, into account,
116 and attenuation is disabled. Otherwise, diffuse
117 and specular lighting calculations are based on the
118 actual location of the light in eye coordinates,
119 and attenuation is enabled. The initial position
120 is (0, 0, 1, 0); thus, the initial light source is
121 directional, parallel to, and in the direction of
122 the −z axis.
123
124 GL_SPOT_DIRECTION params contains three integer or floating-point
125 values that specify the direction of the light in
126 homogeneous object coordinates. Both integer and
127 floating-point values are mapped directly. Neither
128 integer nor floating-point values are clamped.
129
130 The spot direction is transformed by the inverse of
131 the modelview matrix when glLight is called (just
132 as if it were a normal), and it is stored in eye
133 coordinates. It is significant only when
134 GL_SPOT_CUTOFF is not 180, which it is initially.
135 The initial direction is (0, 0, -1).
136
137 GL_SPOT_EXPONENT params is a single integer or floating-point value
138 that specifies the intensity distribution of the
139 light. Integer and floating-point values are
140 mapped directly. Only values in the range [0,128]
141 are accepted.
142
143 Effective light intensity is attenuated by the
144 cosine of the angle between the direction of the
145 light and the direction from the light to the ver‐
146 tex being lighted, raised to the power of the spot
147 exponent. Thus, higher spot exponents result in a
148 more focused light source, regardless of the spot
149 cutoff angle (see GL_SPOT_CUTOFF, next paragraph).
150 The initial spot exponent is 0, resulting in uni‐
151 form light distribution.
152
153 GL_SPOT_CUTOFF params is a single integer or floating-point value
154 that specifies the maximum spread angle of a light
155 source. Integer and floating-point values are
156 mapped directly. Only values in the range [0,90]
157 and the special value 180 are accepted. If the
158 angle between the direction of the light and the
159 direction from the light to the vertex being
160 lighted is greater than the spot cutoff angle, the
161 light is completely masked. Otherwise, its inten‐
162 sity is controlled by the spot exponent and the
163 attenuation factors. The initial spot cutoff is
164 180, resulting in uniform light distribution.
165
166 GL_CONSTANT_ATTENUATION
167
168 GL_LINEAR_ATTENUATION
169
170 GL_QUADRATIC_ATTENUATION
171 params is a single integer or floating-point value
172 that specifies one of the three light attenuation
173 factors. Integer and floating-point values are
174 mapped directly. Only nonnegative values are
175 accepted. If the light is positional, rather than
176 directional, its intensity is attenuated by the
177 reciprocal of the sum of the constant factor, the
178 linear factor times the distance between the light
179 and the vertex being lighted, and the quadratic
180 factor times the square of the same distance. The
181 initial attenuation factors are (1, 0, 0), result‐
182 ing in no attenuation.
183
185 It is always the case that GL_LIGHTi = GL_LIGHT0 + i.
186
188 GL_INVALID_ENUM is generated if either light or pname is not an
189 accepted value.
190
191 GL_INVALID_VALUE is generated if a spot exponent value is specified
192 outside the range [0,128], or if spot cutoff is specified outside the
193 range [0,90] (except for the special value 180), or if a negative
194 attenuation factor is specified.
195
196 GL_INVALID_OPERATION is generated if glLight is executed between the
197 execution of glBegin and the corresponding execution of glEnd.
198
200 glGetLight
201 glIsEnabled with argument GL_LIGHTING
202
204 glColorMaterial(3G), glLightModel(3G), glMaterial(3G)
205
206
207
208 GLLIGHT(3G)