blob: 1eed79bc2a7df41923c64b8f30772070ea19a7d8 [file] [log] [blame]
Brian Paulf22c04c2001-01-04 16:22:18 +00001/* $Id: light.c,v 1.33 2001/01/04 16:22:18 brianp Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paulba643a22000-10-28 18:34:48 +00005 * Version: 3.5
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00006 *
Brian Paul16a9efe2000-01-13 00:29:02 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00008 *
jtgafb833d1999-08-19 00:55:39 +00009 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000015 *
jtgafb833d1999-08-19 00:55:39 +000016 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000018 *
jtgafb833d1999-08-19 00:55:39 +000019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
jtgafb833d1999-08-19 00:55:39 +000028#ifdef PC_HEADER
29#include "all.h"
30#else
Brian Paulfbd8f211999-11-11 01:22:25 +000031#include "glheader.h"
Brian Paulc893a012000-10-28 20:41:13 +000032#include "colormac.h"
jtgafb833d1999-08-19 00:55:39 +000033#include "context.h"
34#include "enums.h"
35#include "light.h"
36#include "macros.h"
Brian Paulfbd8f211999-11-11 01:22:25 +000037#include "mem.h"
jtgafb833d1999-08-19 00:55:39 +000038#include "mmath.h"
39#include "simple_list.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000040#include "mtypes.h"
Keith Whitwell23caf202000-11-16 21:05:34 +000041
42#include "math/m_xform.h"
43#include "math/m_matrix.h"
jtgafb833d1999-08-19 00:55:39 +000044#endif
45
46
Brian Paul075398b2000-01-31 23:33:53 +000047/* XXX this is a bit of a hack needed for compilation within XFree86 */
48#ifndef FLT_MIN
49#define FLT_MIN 1e-37
50#endif
51
jtgafb833d1999-08-19 00:55:39 +000052
Brian Paulfbd8f211999-11-11 01:22:25 +000053void
54_mesa_ShadeModel( GLenum mode )
jtgafb833d1999-08-19 00:55:39 +000055{
Brian Paulfbd8f211999-11-11 01:22:25 +000056 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +000057 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +000058
59 if (MESA_VERBOSE & VERBOSE_API)
60 fprintf(stderr, "glShadeModel %s\n", gl_lookup_enum_by_nr(mode));
61
Keith Whitwellcab974c2000-12-26 05:09:27 +000062 if (mode != GL_FLAT && mode != GL_SMOOTH) {
Keith Whitwell1bf9dfa1999-09-18 20:41:22 +000063 gl_error( ctx, GL_INVALID_ENUM, "glShadeModel" );
Keith Whitwellcab974c2000-12-26 05:09:27 +000064 return;
jtgafb833d1999-08-19 00:55:39 +000065 }
Keith Whitwellcab974c2000-12-26 05:09:27 +000066
67 if (ctx->Light.ShadeModel == mode)
68 return;
69
70 FLUSH_VERTICES(ctx, _NEW_LIGHT);
71 ctx->Light.ShadeModel = mode;
72 ctx->_TriangleCaps ^= DD_FLATSHADE;
73 if (ctx->Driver.ShadeModel)
74 (*ctx->Driver.ShadeModel)( ctx, mode );
jtgafb833d1999-08-19 00:55:39 +000075}
76
77
78
Brian Paulfbd8f211999-11-11 01:22:25 +000079void
80_mesa_Lightf( GLenum light, GLenum pname, GLfloat param )
jtgafb833d1999-08-19 00:55:39 +000081{
Brian Paulfbd8f211999-11-11 01:22:25 +000082 _mesa_Lightfv( light, pname, &param );
83}
jtgafb833d1999-08-19 00:55:39 +000084
Brian Paulfbd8f211999-11-11 01:22:25 +000085
86void
87_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
88{
89 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell1e1aac02000-11-13 20:02:56 +000090 GLint i = (GLint) (light - GL_LIGHT0);
91 struct gl_light *l = &ctx->Light.Light[i];
jtgafb833d1999-08-19 00:55:39 +000092
Brian Paula8644322000-11-27 18:22:13 +000093 if (i < 0 || i >= ctx->Const.MaxLights) {
jtgafb833d1999-08-19 00:55:39 +000094 gl_error( ctx, GL_INVALID_ENUM, "glLight" );
95 return;
96 }
97
98 switch (pname) {
Keith Whitwellcab974c2000-12-26 05:09:27 +000099 case GL_AMBIENT:
100 if (TEST_EQ_4V(l->Ambient, params))
101 return;
102 FLUSH_VERTICES(ctx, _NEW_LIGHT);
103 COPY_4V( l->Ambient, params );
104 break;
105 case GL_DIFFUSE:
106 if (TEST_EQ_4V(l->Diffuse, params))
107 return;
108 FLUSH_VERTICES(ctx, _NEW_LIGHT);
109 COPY_4V( l->Diffuse, params );
110 break;
111 case GL_SPECULAR:
112 if (TEST_EQ_4V(l->Specular, params))
113 return;
114 FLUSH_VERTICES(ctx, _NEW_LIGHT);
115 COPY_4V( l->Specular, params );
116 break;
117 case GL_POSITION: {
118 GLfloat tmp[4];
119 /* transform position by ModelView matrix */
120 TRANSFORM_POINT( tmp, ctx->ModelView.m, params );
121 if (TEST_EQ_4V(l->EyePosition, tmp))
122 return;
123 FLUSH_VERTICES(ctx, _NEW_LIGHT);
124 COPY_4V(l->EyePosition, tmp);
125 if (l->EyePosition[3] != 0.0F)
126 l->_Flags |= LIGHT_POSITIONAL;
127 else
128 l->_Flags &= ~LIGHT_POSITIONAL;
129 break;
130 }
131 case GL_SPOT_DIRECTION: {
132 GLfloat tmp[4];
133 /* transform direction by inverse modelview */
134 if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
135 _math_matrix_analyse( &ctx->ModelView );
136 }
137 TRANSFORM_NORMAL( tmp, params, ctx->ModelView.inv );
138 if (TEST_EQ_3V(l->EyeDirection, tmp))
139 return;
140 FLUSH_VERTICES(ctx, _NEW_LIGHT);
141 COPY_3V(l->EyeDirection, tmp);
142 break;
143 }
144 case GL_SPOT_EXPONENT:
145 if (params[0]<0.0 || params[0]>128.0) {
146 gl_error( ctx, GL_INVALID_VALUE, "glLight" );
147 return;
148 }
149 if (l->SpotExponent == params[0])
150 return;
151 FLUSH_VERTICES(ctx, _NEW_LIGHT);
152 l->SpotExponent = params[0];
153 gl_invalidate_spot_exp_table( l );
154 break;
155 case GL_SPOT_CUTOFF:
156 if ((params[0]<0.0 || params[0]>90.0) && params[0]!=180.0) {
157 gl_error( ctx, GL_INVALID_VALUE, "glLight" );
158 return;
159 }
160 if (l->SpotCutoff == params[0])
161 return;
162 FLUSH_VERTICES(ctx, _NEW_LIGHT);
163 l->SpotCutoff = params[0];
164 l->_CosCutoff = cos(params[0]*DEG2RAD);
165 if (l->_CosCutoff < 0)
166 l->_CosCutoff = 0;
167 if (l->SpotCutoff != 180.0F)
168 l->_Flags |= LIGHT_SPOT;
169 else
170 l->_Flags &= ~LIGHT_SPOT;
171 break;
172 case GL_CONSTANT_ATTENUATION:
173 if (params[0]<0.0) {
174 gl_error( ctx, GL_INVALID_VALUE, "glLight" );
175 return;
176 }
177 if (l->ConstantAttenuation == params[0])
178 return;
179 FLUSH_VERTICES(ctx, _NEW_LIGHT);
180 l->ConstantAttenuation = params[0];
181 break;
182 case GL_LINEAR_ATTENUATION:
183 if (params[0]<0.0) {
184 gl_error( ctx, GL_INVALID_VALUE, "glLight" );
185 return;
186 }
187 if (l->LinearAttenuation == params[0])
188 return;
189 FLUSH_VERTICES(ctx, _NEW_LIGHT);
190 l->LinearAttenuation = params[0];
191 break;
192 case GL_QUADRATIC_ATTENUATION:
193 if (params[0]<0.0) {
194 gl_error( ctx, GL_INVALID_VALUE, "glLight" );
195 return;
196 }
197 if (l->QuadraticAttenuation == params[0])
198 return;
199 FLUSH_VERTICES(ctx, _NEW_LIGHT);
200 l->QuadraticAttenuation = params[0];
201 break;
202 default:
203 gl_error( ctx, GL_INVALID_ENUM, "glLight" );
204 return;
jtgafb833d1999-08-19 00:55:39 +0000205 }
206
Keith Whitwell69cfdb21999-09-30 11:18:21 +0000207 if (ctx->Driver.Lightfv)
Keith Whitwell1e1aac02000-11-13 20:02:56 +0000208 ctx->Driver.Lightfv( ctx, light, pname, params );
jtgafb833d1999-08-19 00:55:39 +0000209}
210
211
Brian Paulfbd8f211999-11-11 01:22:25 +0000212void
213_mesa_Lighti( GLenum light, GLenum pname, GLint param )
jtgafb833d1999-08-19 00:55:39 +0000214{
Brian Paulfbd8f211999-11-11 01:22:25 +0000215 _mesa_Lightiv( light, pname, &param );
216}
217
218
219void
220_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params )
221{
222 GLfloat fparam[4];
223
224 switch (pname) {
225 case GL_AMBIENT:
226 case GL_DIFFUSE:
227 case GL_SPECULAR:
228 fparam[0] = INT_TO_FLOAT( params[0] );
229 fparam[1] = INT_TO_FLOAT( params[1] );
230 fparam[2] = INT_TO_FLOAT( params[2] );
231 fparam[3] = INT_TO_FLOAT( params[3] );
232 break;
233 case GL_POSITION:
234 fparam[0] = (GLfloat) params[0];
235 fparam[1] = (GLfloat) params[1];
236 fparam[2] = (GLfloat) params[2];
237 fparam[3] = (GLfloat) params[3];
238 break;
239 case GL_SPOT_DIRECTION:
240 fparam[0] = (GLfloat) params[0];
241 fparam[1] = (GLfloat) params[1];
242 fparam[2] = (GLfloat) params[2];
243 break;
244 case GL_SPOT_EXPONENT:
245 case GL_SPOT_CUTOFF:
246 case GL_CONSTANT_ATTENUATION:
247 case GL_LINEAR_ATTENUATION:
248 case GL_QUADRATIC_ATTENUATION:
249 fparam[0] = (GLfloat) params[0];
250 break;
251 default:
252 /* error will be caught later in gl_Lightfv */
253 ;
254 }
255
256 _mesa_Lightfv( light, pname, fparam );
257}
258
259
260
261void
262_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
263{
264 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000265 GLint l = (GLint) (light - GL_LIGHT0);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000266 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +0000267
Brian Paula8644322000-11-27 18:22:13 +0000268 if (l < 0 || l >= ctx->Const.MaxLights) {
jtgafb833d1999-08-19 00:55:39 +0000269 gl_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
270 return;
271 }
272
273 switch (pname) {
274 case GL_AMBIENT:
275 COPY_4V( params, ctx->Light.Light[l].Ambient );
276 break;
277 case GL_DIFFUSE:
278 COPY_4V( params, ctx->Light.Light[l].Diffuse );
279 break;
280 case GL_SPECULAR:
281 COPY_4V( params, ctx->Light.Light[l].Specular );
282 break;
283 case GL_POSITION:
284 COPY_4V( params, ctx->Light.Light[l].EyePosition );
285 break;
286 case GL_SPOT_DIRECTION:
287 COPY_3V( params, ctx->Light.Light[l].EyeDirection );
288 break;
289 case GL_SPOT_EXPONENT:
290 params[0] = ctx->Light.Light[l].SpotExponent;
291 break;
292 case GL_SPOT_CUTOFF:
293 params[0] = ctx->Light.Light[l].SpotCutoff;
294 break;
295 case GL_CONSTANT_ATTENUATION:
296 params[0] = ctx->Light.Light[l].ConstantAttenuation;
297 break;
298 case GL_LINEAR_ATTENUATION:
299 params[0] = ctx->Light.Light[l].LinearAttenuation;
300 break;
301 case GL_QUADRATIC_ATTENUATION:
302 params[0] = ctx->Light.Light[l].QuadraticAttenuation;
303 break;
304 default:
305 gl_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
306 break;
307 }
308}
309
310
311
Brian Paulfbd8f211999-11-11 01:22:25 +0000312void
313_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params )
jtgafb833d1999-08-19 00:55:39 +0000314{
Brian Paulfbd8f211999-11-11 01:22:25 +0000315 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000316 GLint l = (GLint) (light - GL_LIGHT0);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000317 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +0000318
Brian Paula8644322000-11-27 18:22:13 +0000319 if (l < 0 || l >= ctx->Const.MaxLights) {
jtgafb833d1999-08-19 00:55:39 +0000320 gl_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
321 return;
322 }
323
324 switch (pname) {
325 case GL_AMBIENT:
326 params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]);
327 params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]);
328 params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]);
329 params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]);
330 break;
331 case GL_DIFFUSE:
332 params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]);
333 params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]);
334 params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]);
335 params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]);
336 break;
337 case GL_SPECULAR:
338 params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]);
339 params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]);
340 params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]);
341 params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]);
342 break;
343 case GL_POSITION:
344 params[0] = (GLint) ctx->Light.Light[l].EyePosition[0];
345 params[1] = (GLint) ctx->Light.Light[l].EyePosition[1];
346 params[2] = (GLint) ctx->Light.Light[l].EyePosition[2];
347 params[3] = (GLint) ctx->Light.Light[l].EyePosition[3];
348 break;
349 case GL_SPOT_DIRECTION:
350 params[0] = (GLint) ctx->Light.Light[l].EyeDirection[0];
351 params[1] = (GLint) ctx->Light.Light[l].EyeDirection[1];
352 params[2] = (GLint) ctx->Light.Light[l].EyeDirection[2];
353 break;
354 case GL_SPOT_EXPONENT:
355 params[0] = (GLint) ctx->Light.Light[l].SpotExponent;
356 break;
357 case GL_SPOT_CUTOFF:
358 params[0] = (GLint) ctx->Light.Light[l].SpotCutoff;
359 break;
360 case GL_CONSTANT_ATTENUATION:
361 params[0] = (GLint) ctx->Light.Light[l].ConstantAttenuation;
362 break;
363 case GL_LINEAR_ATTENUATION:
364 params[0] = (GLint) ctx->Light.Light[l].LinearAttenuation;
365 break;
366 case GL_QUADRATIC_ATTENUATION:
367 params[0] = (GLint) ctx->Light.Light[l].QuadraticAttenuation;
368 break;
369 default:
370 gl_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
371 break;
372 }
373}
374
375
376
377/**********************************************************************/
378/*** Light Model ***/
379/**********************************************************************/
380
381
Brian Paulfbd8f211999-11-11 01:22:25 +0000382void
383_mesa_LightModelfv( GLenum pname, const GLfloat *params )
jtgafb833d1999-08-19 00:55:39 +0000384{
Keith Whitwellcab974c2000-12-26 05:09:27 +0000385 GLenum newenum;
386 GLboolean newbool;
Brian Paulfbd8f211999-11-11 01:22:25 +0000387 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000388 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +0000389
390 switch (pname) {
391 case GL_LIGHT_MODEL_AMBIENT:
Keith Whitwellcab974c2000-12-26 05:09:27 +0000392 if (TEST_EQ_4V( ctx->Light.Model.Ambient, params ))
393 return;
394 FLUSH_VERTICES(ctx, _NEW_LIGHT);
jtgafb833d1999-08-19 00:55:39 +0000395 COPY_4V( ctx->Light.Model.Ambient, params );
396 break;
397 case GL_LIGHT_MODEL_LOCAL_VIEWER:
Keith Whitwellcab974c2000-12-26 05:09:27 +0000398 newbool = (params[0]!=0.0);
399 if (ctx->Light.Model.LocalViewer == newbool)
400 return;
401 FLUSH_VERTICES(ctx, _NEW_LIGHT);
402 ctx->Light.Model.LocalViewer = newbool;
jtgafb833d1999-08-19 00:55:39 +0000403 break;
404 case GL_LIGHT_MODEL_TWO_SIDE:
Keith Whitwellcab974c2000-12-26 05:09:27 +0000405 newbool = (params[0]!=0.0);
406 if (ctx->Light.Model.TwoSide == newbool)
407 return;
408 FLUSH_VERTICES(ctx, _NEW_LIGHT);
409 ctx->Light.Model.TwoSide = newbool;
jtgafb833d1999-08-19 00:55:39 +0000410 break;
411 case GL_LIGHT_MODEL_COLOR_CONTROL:
Keith Whitwellcab974c2000-12-26 05:09:27 +0000412 if (params[0] == (GLfloat) GL_SINGLE_COLOR)
413 newenum = GL_SINGLE_COLOR;
414 else if (params[0] == (GLfloat) GL_SEPARATE_SPECULAR_COLOR)
415 newenum = GL_SEPARATE_SPECULAR_COLOR;
416 else {
jtgafb833d1999-08-19 00:55:39 +0000417 gl_error( ctx, GL_INVALID_ENUM, "glLightModel(param)" );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000418 return;
Brian Paulf3f9b771999-10-19 20:32:40 +0000419 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000420 if (ctx->Light.Model.ColorControl == newenum)
421 return;
422 FLUSH_VERTICES(ctx, _NEW_LIGHT);
423 ctx->Light.Model.ColorControl = newenum;
424 ctx->_TriangleCaps ^= DD_SEPERATE_SPECULAR;
jtgafb833d1999-08-19 00:55:39 +0000425 break;
426 default:
427 gl_error( ctx, GL_INVALID_ENUM, "glLightModel" );
428 break;
429 }
Keith Whitwell69cfdb21999-09-30 11:18:21 +0000430
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000431 if (ctx->Driver.LightModelfv)
Keith Whitwell69cfdb21999-09-30 11:18:21 +0000432 ctx->Driver.LightModelfv( ctx, pname, params );
jtgafb833d1999-08-19 00:55:39 +0000433}
434
435
Brian Paulfbd8f211999-11-11 01:22:25 +0000436void
437_mesa_LightModeliv( GLenum pname, const GLint *params )
438{
439 GLfloat fparam[4];
Brian Paulfbd8f211999-11-11 01:22:25 +0000440
441 switch (pname) {
442 case GL_LIGHT_MODEL_AMBIENT:
443 fparam[0] = INT_TO_FLOAT( params[0] );
444 fparam[1] = INT_TO_FLOAT( params[1] );
445 fparam[2] = INT_TO_FLOAT( params[2] );
446 fparam[3] = INT_TO_FLOAT( params[3] );
447 break;
448 case GL_LIGHT_MODEL_LOCAL_VIEWER:
449 case GL_LIGHT_MODEL_TWO_SIDE:
450 case GL_LIGHT_MODEL_COLOR_CONTROL:
451 fparam[0] = (GLfloat) params[0];
452 break;
453 default:
454 /* Error will be caught later in gl_LightModelfv */
455 ;
456 }
457 _mesa_LightModelfv( pname, fparam );
458}
459
460
461void
462_mesa_LightModeli( GLenum pname, GLint param )
463{
464 _mesa_LightModeliv( pname, &param );
465}
466
467
468void
469_mesa_LightModelf( GLenum pname, GLfloat param )
470{
471 _mesa_LightModelfv( pname, &param );
472}
473
jtgafb833d1999-08-19 00:55:39 +0000474
475
476/********** MATERIAL **********/
477
478
479/*
480 * Given a face and pname value (ala glColorMaterial), compute a bitmask
481 * of the targeted material values.
482 */
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000483GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname,
jtgafb833d1999-08-19 00:55:39 +0000484 GLuint legal,
485 const char *where )
486{
487 GLuint bitmask = 0;
488
489 /* Make a bitmask indicating what material attribute(s) we're updating */
490 switch (pname) {
491 case GL_EMISSION:
492 bitmask |= FRONT_EMISSION_BIT | BACK_EMISSION_BIT;
493 break;
494 case GL_AMBIENT:
495 bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT;
496 break;
497 case GL_DIFFUSE:
498 bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT;
499 break;
500 case GL_SPECULAR:
501 bitmask |= FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT;
502 break;
503 case GL_SHININESS:
504 bitmask |= FRONT_SHININESS_BIT | BACK_SHININESS_BIT;
505 break;
506 case GL_AMBIENT_AND_DIFFUSE:
507 bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT;
508 bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT;
509 break;
510 case GL_COLOR_INDEXES:
511 bitmask |= FRONT_INDEXES_BIT | BACK_INDEXES_BIT;
512 break;
513 default:
514 gl_error( ctx, GL_INVALID_ENUM, where );
515 return 0;
516 }
517
518 if (face==GL_FRONT) {
519 bitmask &= FRONT_MATERIAL_BITS;
520 }
521 else if (face==GL_BACK) {
522 bitmask &= BACK_MATERIAL_BITS;
523 }
524 else if (face != GL_FRONT_AND_BACK) {
525 gl_error( ctx, GL_INVALID_ENUM, where );
526 return 0;
527 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000528
jtgafb833d1999-08-19 00:55:39 +0000529 if (bitmask & ~legal) {
530 gl_error( ctx, GL_INVALID_ENUM, where );
531 return 0;
532 }
533
534 return bitmask;
535}
536
537
538
jtgafb833d1999-08-19 00:55:39 +0000539/*
540 * Check if the global material has to be updated with info that was
541 * associated with a vertex via glMaterial.
542 * This function is used when any material values get changed between
543 * glBegin/glEnd either by calling glMaterial() or by calling glColor()
544 * when GL_COLOR_MATERIAL is enabled.
545 *
Brian Paulde82d062000-06-26 23:37:46 +0000546 * src[0] is front material, src[1] is back material
547 *
jtgafb833d1999-08-19 00:55:39 +0000548 * KW: Added code here to keep the precomputed variables uptodate.
549 * This means we can use the faster shade functions when using
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000550 * GL_COLOR_MATERIAL, and we can also now use the precomputed
jtgafb833d1999-08-19 00:55:39 +0000551 * values in the slower shading functions, which further offsets
552 * the cost of doing this here.
553 */
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000554void gl_update_material( GLcontext *ctx,
555 const struct gl_material src[2],
jtgafb833d1999-08-19 00:55:39 +0000556 GLuint bitmask )
557{
558 struct gl_light *light, *list = &ctx->Light.EnabledList;
jtgafb833d1999-08-19 00:55:39 +0000559
560 if (ctx->Light.ColorMaterialEnabled)
561 bitmask &= ~ctx->Light.ColorMaterialBitmask;
562
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000563 if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
Brian Paulde82d062000-06-26 23:37:46 +0000564 fprintf(stderr, "gl_update_material, mask 0x%x\n", bitmask);
Keith Whitwell06ac5921999-11-10 06:29:44 +0000565
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000566 if (!bitmask)
jtgafb833d1999-08-19 00:55:39 +0000567 return;
568
Brian Paulde82d062000-06-26 23:37:46 +0000569 /* update material emission */
570 if (bitmask & FRONT_EMISSION_BIT) {
571 struct gl_material *mat = &ctx->Light.Material[0];
572 COPY_4FV( mat->Emission, src[0].Emission );
573 }
574 if (bitmask & BACK_EMISSION_BIT) {
575 struct gl_material *mat = &ctx->Light.Material[1];
576 COPY_4FV( mat->Emission, src[1].Emission );
577 }
578
579 /* update material ambience */
jtgafb833d1999-08-19 00:55:39 +0000580 if (bitmask & FRONT_AMBIENT_BIT) {
581 struct gl_material *mat = &ctx->Light.Material[0];
jtgafb833d1999-08-19 00:55:39 +0000582 COPY_4FV( mat->Ambient, src[0].Ambient );
Brian Paulde82d062000-06-26 23:37:46 +0000583 foreach (light, list) {
Keith Whitwell14940c42000-11-05 18:40:57 +0000584 SCALE_3V( light->_MatAmbient[0], light->Ambient, src[0].Ambient);
Brian Paulde82d062000-06-26 23:37:46 +0000585 }
jtgafb833d1999-08-19 00:55:39 +0000586 }
587 if (bitmask & BACK_AMBIENT_BIT) {
588 struct gl_material *mat = &ctx->Light.Material[1];
jtgafb833d1999-08-19 00:55:39 +0000589 COPY_4FV( mat->Ambient, src[1].Ambient );
Brian Paulde82d062000-06-26 23:37:46 +0000590 foreach (light, list) {
Keith Whitwell14940c42000-11-05 18:40:57 +0000591 SCALE_3V( light->_MatAmbient[1], light->Ambient, src[1].Ambient);
Brian Paulde82d062000-06-26 23:37:46 +0000592 }
jtgafb833d1999-08-19 00:55:39 +0000593 }
Brian Paulde82d062000-06-26 23:37:46 +0000594
595 /* update BaseColor = emission + scene's ambience * material's ambience */
596 if (bitmask & (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT)) {
597 struct gl_material *mat = &ctx->Light.Material[0];
Keith Whitwell14940c42000-11-05 18:40:57 +0000598 COPY_3V( ctx->Light._BaseColor[0], mat->Emission );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000599 ACC_SCALE_3V( ctx->Light._BaseColor[0], mat->Ambient,
600 ctx->Light.Model.Ambient );
Brian Paulde82d062000-06-26 23:37:46 +0000601 }
602 if (bitmask & (BACK_EMISSION_BIT | BACK_AMBIENT_BIT)) {
603 struct gl_material *mat = &ctx->Light.Material[1];
Keith Whitwell14940c42000-11-05 18:40:57 +0000604 COPY_3V( ctx->Light._BaseColor[1], mat->Emission );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000605 ACC_SCALE_3V( ctx->Light._BaseColor[1], mat->Ambient,
606 ctx->Light.Model.Ambient );
Brian Paulde82d062000-06-26 23:37:46 +0000607 }
608
609 /* update material diffuse values */
jtgafb833d1999-08-19 00:55:39 +0000610 if (bitmask & FRONT_DIFFUSE_BIT) {
611 struct gl_material *mat = &ctx->Light.Material[0];
jtgafb833d1999-08-19 00:55:39 +0000612 COPY_4FV( mat->Diffuse, src[0].Diffuse );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000613/* fprintf(stderr, "FRONT_DIFFUSE %f %f %f %f\n", */
614/* mat->Diffuse[0], mat->Diffuse[1], */
615/* mat->Diffuse[2], mat->Diffuse[3]); */
Keith Whitwellad2ac212000-11-24 10:25:05 +0000616 foreach (light, list) {
617 SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse );
618 }
Brian Paul3041d052001-01-02 22:02:51 +0000619 UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]);
jtgafb833d1999-08-19 00:55:39 +0000620 }
621 if (bitmask & BACK_DIFFUSE_BIT) {
622 struct gl_material *mat = &ctx->Light.Material[1];
jtgafb833d1999-08-19 00:55:39 +0000623 COPY_4FV( mat->Diffuse, src[1].Diffuse );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000624/* fprintf(stderr, "BACK_DIFFUSE %f %f %f %f\n", */
625/* mat->Diffuse[0], mat->Diffuse[1], */
626/* mat->Diffuse[2], mat->Diffuse[3]); */
Keith Whitwellad2ac212000-11-24 10:25:05 +0000627 foreach (light, list) {
628 SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse );
629 }
Brian Paul3041d052001-01-02 22:02:51 +0000630 UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]);
jtgafb833d1999-08-19 00:55:39 +0000631 }
Brian Paulde82d062000-06-26 23:37:46 +0000632
633 /* update material specular values */
jtgafb833d1999-08-19 00:55:39 +0000634 if (bitmask & FRONT_SPECULAR_BIT) {
635 struct gl_material *mat = &ctx->Light.Material[0];
jtgafb833d1999-08-19 00:55:39 +0000636 COPY_4FV( mat->Specular, src[0].Specular );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000637 foreach (light, list) {
Keith Whitwell9aff6cf2000-11-24 15:21:59 +0000638 SCALE_3V( light->_MatSpecular[0], light->Specular, mat->Specular);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000639 }
jtgafb833d1999-08-19 00:55:39 +0000640 }
641 if (bitmask & BACK_SPECULAR_BIT) {
642 struct gl_material *mat = &ctx->Light.Material[1];
jtgafb833d1999-08-19 00:55:39 +0000643 COPY_4FV( mat->Specular, src[1].Specular );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000644 foreach (light, list) {
Keith Whitwell9aff6cf2000-11-24 15:21:59 +0000645 SCALE_3V( light->_MatSpecular[1], light->Specular, mat->Specular);
Keith Whitwellad2ac212000-11-24 10:25:05 +0000646 }
jtgafb833d1999-08-19 00:55:39 +0000647 }
Brian Paulde82d062000-06-26 23:37:46 +0000648
jtgafb833d1999-08-19 00:55:39 +0000649 if (bitmask & FRONT_SHININESS_BIT) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000650/* fprintf(stderr, "FRONT_SHININESS_BIT %f\n", src[0].Shininess); */
651 ctx->Light.Material[0].Shininess = src[0].Shininess;
652 gl_invalidate_shine_table( ctx, 0 );
jtgafb833d1999-08-19 00:55:39 +0000653 }
654 if (bitmask & BACK_SHININESS_BIT) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000655 ctx->Light.Material[1].Shininess = src[1].Shininess;
656 gl_invalidate_shine_table( ctx, 1 );
jtgafb833d1999-08-19 00:55:39 +0000657 }
Brian Paulde82d062000-06-26 23:37:46 +0000658
jtgafb833d1999-08-19 00:55:39 +0000659 if (bitmask & FRONT_INDEXES_BIT) {
660 ctx->Light.Material[0].AmbientIndex = src[0].AmbientIndex;
661 ctx->Light.Material[0].DiffuseIndex = src[0].DiffuseIndex;
662 ctx->Light.Material[0].SpecularIndex = src[0].SpecularIndex;
663 }
664 if (bitmask & BACK_INDEXES_BIT) {
665 ctx->Light.Material[1].AmbientIndex = src[1].AmbientIndex;
666 ctx->Light.Material[1].DiffuseIndex = src[1].DiffuseIndex;
667 ctx->Light.Material[1].SpecularIndex = src[1].SpecularIndex;
668 }
669
Keith Whitwell06ac5921999-11-10 06:29:44 +0000670 if (0)
671 {
672 struct gl_material *mat = &ctx->Light.Material[0];
673 fprintf(stderr, "update_mat emission : %f %f %f\n",
674 mat->Emission[0],
675 mat->Emission[1],
676 mat->Emission[2]);
677 fprintf(stderr, "update_mat specular : %f %f %f\n",
678 mat->Specular[0],
679 mat->Specular[1],
680 mat->Specular[2]);
681 fprintf(stderr, "update_mat diffuse : %f %f %f\n",
682 mat->Diffuse[0],
683 mat->Diffuse[1],
684 mat->Diffuse[2]);
685 fprintf(stderr, "update_mat ambient : %f %f %f\n",
686 mat->Ambient[0],
687 mat->Ambient[1],
688 mat->Ambient[2]);
689 }
jtgafb833d1999-08-19 00:55:39 +0000690}
691
692
693
694
Brian Paulde82d062000-06-26 23:37:46 +0000695/*
696 * Update the current materials from the given rgba color
697 * according to the bitmask in ColorMaterialBitmask, which is
698 * set by glColorMaterial().
699 */
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000700void gl_update_color_material( GLcontext *ctx,
Brian Paulba643a22000-10-28 18:34:48 +0000701 const GLchan rgba[4] )
jtgafb833d1999-08-19 00:55:39 +0000702{
703 struct gl_light *light, *list = &ctx->Light.EnabledList;
704 GLuint bitmask = ctx->Light.ColorMaterialBitmask;
Brian Paulde82d062000-06-26 23:37:46 +0000705 GLfloat color[4];
jtgafb833d1999-08-19 00:55:39 +0000706
Brian Paulc893a012000-10-28 20:41:13 +0000707 color[0] = CHAN_TO_FLOAT(rgba[0]);
708 color[1] = CHAN_TO_FLOAT(rgba[1]);
709 color[2] = CHAN_TO_FLOAT(rgba[2]);
710 color[3] = CHAN_TO_FLOAT(rgba[3]);
711
Keith Whitwell06ac5921999-11-10 06:29:44 +0000712 if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
Brian Paulde82d062000-06-26 23:37:46 +0000713 fprintf(stderr, "gl_update_color_material, mask 0x%x\n", bitmask);
Keith Whitwell06ac5921999-11-10 06:29:44 +0000714
Brian Paulde82d062000-06-26 23:37:46 +0000715 /* update emissive colors */
716 if (bitmask & FRONT_EMISSION_BIT) {
717 struct gl_material *mat = &ctx->Light.Material[0];
718 COPY_4FV( mat->Emission, color );
719 }
Brian Paulfbd8f211999-11-11 01:22:25 +0000720
Brian Paulde82d062000-06-26 23:37:46 +0000721 if (bitmask & BACK_EMISSION_BIT) {
722 struct gl_material *mat = &ctx->Light.Material[1];
723 COPY_4FV( mat->Emission, color );
724 }
725
Keith Whitwell14940c42000-11-05 18:40:57 +0000726 /* update light->_MatAmbient = light's ambient * material's ambient */
jtgafb833d1999-08-19 00:55:39 +0000727 if (bitmask & FRONT_AMBIENT_BIT) {
728 struct gl_material *mat = &ctx->Light.Material[0];
jtgafb833d1999-08-19 00:55:39 +0000729 foreach (light, list) {
Keith Whitwell14940c42000-11-05 18:40:57 +0000730 SCALE_3V( light->_MatAmbient[0], light->Ambient, color);
jtgafb833d1999-08-19 00:55:39 +0000731 }
732 COPY_4FV( mat->Ambient, color );
733 }
734
735 if (bitmask & BACK_AMBIENT_BIT) {
736 struct gl_material *mat = &ctx->Light.Material[1];
jtgafb833d1999-08-19 00:55:39 +0000737 foreach (light, list) {
Keith Whitwell14940c42000-11-05 18:40:57 +0000738 SCALE_3V( light->_MatAmbient[1], light->Ambient, color);
jtgafb833d1999-08-19 00:55:39 +0000739 }
740 COPY_4FV( mat->Ambient, color );
741 }
742
Brian Paulde82d062000-06-26 23:37:46 +0000743 /* update BaseColor = emission + scene's ambience * material's ambience */
744 if (bitmask & (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT)) {
745 struct gl_material *mat = &ctx->Light.Material[0];
Keith Whitwell14940c42000-11-05 18:40:57 +0000746 COPY_3V( ctx->Light._BaseColor[0], mat->Emission );
747 ACC_SCALE_3V( ctx->Light._BaseColor[0], mat->Ambient, ctx->Light.Model.Ambient );
Brian Paulde82d062000-06-26 23:37:46 +0000748 }
749
750 if (bitmask & (BACK_EMISSION_BIT | BACK_AMBIENT_BIT)) {
751 struct gl_material *mat = &ctx->Light.Material[1];
Keith Whitwell14940c42000-11-05 18:40:57 +0000752 COPY_3V( ctx->Light._BaseColor[1], mat->Emission );
753 ACC_SCALE_3V( ctx->Light._BaseColor[1], mat->Ambient, ctx->Light.Model.Ambient );
Brian Paulde82d062000-06-26 23:37:46 +0000754 }
755
Keith Whitwell14940c42000-11-05 18:40:57 +0000756 /* update light->_MatDiffuse = light's diffuse * material's diffuse */
jtgafb833d1999-08-19 00:55:39 +0000757 if (bitmask & FRONT_DIFFUSE_BIT) {
758 struct gl_material *mat = &ctx->Light.Material[0];
jtgafb833d1999-08-19 00:55:39 +0000759 COPY_4FV( mat->Diffuse, color );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000760 foreach (light, list) {
761 SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse );
762 }
Brian Paul3041d052001-01-02 22:02:51 +0000763 UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]);
jtgafb833d1999-08-19 00:55:39 +0000764 }
765
766 if (bitmask & BACK_DIFFUSE_BIT) {
767 struct gl_material *mat = &ctx->Light.Material[1];
jtgafb833d1999-08-19 00:55:39 +0000768 COPY_4FV( mat->Diffuse, color );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000769 foreach (light, list) {
770 SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse );
771 }
Brian Paul3041d052001-01-02 22:02:51 +0000772 UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]);
jtgafb833d1999-08-19 00:55:39 +0000773 }
774
Keith Whitwell14940c42000-11-05 18:40:57 +0000775 /* update light->_MatSpecular = light's specular * material's specular */
jtgafb833d1999-08-19 00:55:39 +0000776 if (bitmask & FRONT_SPECULAR_BIT) {
777 struct gl_material *mat = &ctx->Light.Material[0];
jtgafb833d1999-08-19 00:55:39 +0000778 COPY_4FV( mat->Specular, color );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000779 foreach (light, list) {
780 ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, mat->Specular);
781 }
jtgafb833d1999-08-19 00:55:39 +0000782 }
Brian Paulde82d062000-06-26 23:37:46 +0000783
jtgafb833d1999-08-19 00:55:39 +0000784 if (bitmask & BACK_SPECULAR_BIT) {
785 struct gl_material *mat = &ctx->Light.Material[1];
jtgafb833d1999-08-19 00:55:39 +0000786 COPY_4FV( mat->Specular, color );
Keith Whitwellad2ac212000-11-24 10:25:05 +0000787 foreach (light, list) {
788 ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, mat->Specular);
789 }
jtgafb833d1999-08-19 00:55:39 +0000790 }
Keith Whitwell06ac5921999-11-10 06:29:44 +0000791
792 if (0)
793 {
794 struct gl_material *mat = &ctx->Light.Material[0];
795 fprintf(stderr, "update_color_mat emission : %f %f %f\n",
796 mat->Emission[0],
797 mat->Emission[1],
798 mat->Emission[2]);
799 fprintf(stderr, "update_color_mat specular : %f %f %f\n",
800 mat->Specular[0],
801 mat->Specular[1],
802 mat->Specular[2]);
803 fprintf(stderr, "update_color_mat diffuse : %f %f %f\n",
804 mat->Diffuse[0],
805 mat->Diffuse[1],
806 mat->Diffuse[2]);
807 fprintf(stderr, "update_color_mat ambient : %f %f %f\n",
808 mat->Ambient[0],
809 mat->Ambient[1],
810 mat->Ambient[2]);
811 }
jtgafb833d1999-08-19 00:55:39 +0000812}
813
814
815
816
Brian Paulfbd8f211999-11-11 01:22:25 +0000817void
818_mesa_ColorMaterial( GLenum face, GLenum mode )
jtgafb833d1999-08-19 00:55:39 +0000819{
Brian Paulfbd8f211999-11-11 01:22:25 +0000820 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000821 GLuint bitmask;
822 GLuint legal = (FRONT_EMISSION_BIT | BACK_EMISSION_BIT |
823 FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT |
824 FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT |
825 FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000826 ASSERT_OUTSIDE_BEGIN_END(ctx);
jtgafb833d1999-08-19 00:55:39 +0000827
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000828 if (MESA_VERBOSE&VERBOSE_API)
829 fprintf(stderr, "glColorMaterial %s %s\n",
Keith Whitwell06ac5921999-11-10 06:29:44 +0000830 gl_lookup_enum_by_nr(face),
831 gl_lookup_enum_by_nr(mode));
832
jtgafb833d1999-08-19 00:55:39 +0000833 bitmask = gl_material_bitmask( ctx, face, mode, legal, "glColorMaterial" );
834
Keith Whitwellcab974c2000-12-26 05:09:27 +0000835 if (ctx->Light.ColorMaterialBitmask == bitmask &&
836 ctx->Light.ColorMaterialFace == face &&
837 ctx->Light.ColorMaterialMode == mode)
838 return;
839
840 FLUSH_VERTICES(ctx, _NEW_LIGHT);
841 ctx->Light.ColorMaterialBitmask = bitmask;
842 ctx->Light.ColorMaterialFace = face;
843 ctx->Light.ColorMaterialMode = mode;
Keith Whitwell06ac5921999-11-10 06:29:44 +0000844
Keith Whitwell23caf202000-11-16 21:05:34 +0000845 if (ctx->Light.ColorMaterialEnabled) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000846 FLUSH_CURRENT( ctx, 0 );
Brian Paul19300532000-10-29 19:02:23 +0000847 gl_update_color_material( ctx, ctx->Current.Color );
Keith Whitwell23caf202000-11-16 21:05:34 +0000848 }
jtgafb833d1999-08-19 00:55:39 +0000849}
850
851
852
Brian Paulfbd8f211999-11-11 01:22:25 +0000853
Brian Paulfbd8f211999-11-11 01:22:25 +0000854
855void
856_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
857{
858 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000859 GLuint f;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000860 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
jtgafb833d1999-08-19 00:55:39 +0000861
862 if (face==GL_FRONT) {
863 f = 0;
864 }
865 else if (face==GL_BACK) {
866 f = 1;
867 }
868 else {
869 gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" );
870 return;
871 }
872 switch (pname) {
873 case GL_AMBIENT:
874 COPY_4FV( params, ctx->Light.Material[f].Ambient );
875 break;
876 case GL_DIFFUSE:
877 COPY_4FV( params, ctx->Light.Material[f].Diffuse );
878 break;
879 case GL_SPECULAR:
880 COPY_4FV( params, ctx->Light.Material[f].Specular );
881 break;
882 case GL_EMISSION:
883 COPY_4FV( params, ctx->Light.Material[f].Emission );
884 break;
885 case GL_SHININESS:
886 *params = ctx->Light.Material[f].Shininess;
887 break;
888 case GL_COLOR_INDEXES:
889 params[0] = ctx->Light.Material[f].AmbientIndex;
890 params[1] = ctx->Light.Material[f].DiffuseIndex;
891 params[2] = ctx->Light.Material[f].SpecularIndex;
892 break;
893 default:
894 gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
895 }
896}
897
898
899
Brian Paulfbd8f211999-11-11 01:22:25 +0000900void
901_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
jtgafb833d1999-08-19 00:55:39 +0000902{
Brian Paulfbd8f211999-11-11 01:22:25 +0000903 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000904 GLuint f;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000905 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
jtgafb833d1999-08-19 00:55:39 +0000906
907 if (face==GL_FRONT) {
908 f = 0;
909 }
910 else if (face==GL_BACK) {
911 f = 1;
912 }
913 else {
914 gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" );
915 return;
916 }
917 switch (pname) {
918 case GL_AMBIENT:
919 params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[0] );
920 params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[1] );
921 params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[2] );
922 params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[3] );
923 break;
924 case GL_DIFFUSE:
925 params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[0] );
926 params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[1] );
927 params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[2] );
928 params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[3] );
929 break;
930 case GL_SPECULAR:
931 params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[0] );
932 params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[1] );
933 params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[2] );
934 params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[3] );
935 break;
936 case GL_EMISSION:
937 params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[0] );
938 params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[1] );
939 params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[2] );
940 params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[3] );
941 break;
942 case GL_SHININESS:
943 *params = ROUNDF( ctx->Light.Material[f].Shininess );
944 break;
945 case GL_COLOR_INDEXES:
946 params[0] = ROUNDF( ctx->Light.Material[f].AmbientIndex );
947 params[1] = ROUNDF( ctx->Light.Material[f].DiffuseIndex );
948 params[2] = ROUNDF( ctx->Light.Material[f].SpecularIndex );
949 break;
950 default:
951 gl_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
952 }
953}
954
955
956
957
958/**********************************************************************/
959/***** Lighting computation *****/
960/**********************************************************************/
961
962
963/*
964 * Notes:
965 * When two-sided lighting is enabled we compute the color (or index)
966 * for both the front and back side of the primitive. Then, when the
967 * orientation of the facet is later learned, we can determine which
968 * color (or index) to use for rendering.
969 *
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000970 * KW: We now know orientation in advance and only shade for
jtgafb833d1999-08-19 00:55:39 +0000971 * the side or sides which are actually required.
972 *
973 * Variables:
974 * n = normal vector
975 * V = vertex position
976 * P = light source position
977 * Pe = (0,0,0,1)
978 *
979 * Precomputed:
980 * IF P[3]==0 THEN
981 * // light at infinity
982 * IF local_viewer THEN
Keith Whitwell14940c42000-11-05 18:40:57 +0000983 * _VP_inf_norm = unit vector from V to P // Precompute
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000984 * ELSE
jtgafb833d1999-08-19 00:55:39 +0000985 * // eye at infinity
Keith Whitwell14940c42000-11-05 18:40:57 +0000986 * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
jtgafb833d1999-08-19 00:55:39 +0000987 * ENDIF
988 * ENDIF
989 *
990 * Functions:
991 * Normalize( v ) = normalized vector v
992 * Magnitude( v ) = length of vector v
993 */
994
995
996
997/*
998 * Whenever the spotlight exponent for a light changes we must call
999 * this function to recompute the exponent lookup table.
1000 */
Brian Paula0faa7f2000-07-18 16:55:56 +00001001void
Keith Whitwellcab974c2000-12-26 05:09:27 +00001002gl_invalidate_spot_exp_table( struct gl_light *l )
1003{
1004 l->_SpotExpTable[0][0] = -1;
1005}
1006
1007static void validate_spot_exp_table( struct gl_light *l )
jtgafb833d1999-08-19 00:55:39 +00001008{
Brian Paula0faa7f2000-07-18 16:55:56 +00001009 GLint i;
1010 GLdouble exponent = l->SpotExponent;
1011 GLdouble tmp = 0;
1012 GLint clamp = 0;
jtgafb833d1999-08-19 00:55:39 +00001013
Keith Whitwell14940c42000-11-05 18:40:57 +00001014 l->_SpotExpTable[0][0] = 0.0;
jtgafb833d1999-08-19 00:55:39 +00001015
Brian Paula0faa7f2000-07-18 16:55:56 +00001016 for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) {
jtgafb833d1999-08-19 00:55:39 +00001017 if (clamp == 0) {
Keith Whitwellcab974c2000-12-26 05:09:27 +00001018 tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent);
1019 if (tmp < FLT_MIN * 100.0) {
1020 tmp = 0.0;
1021 clamp = 1;
1022 }
jtgafb833d1999-08-19 00:55:39 +00001023 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001024 l->_SpotExpTable[i][0] = tmp;
jtgafb833d1999-08-19 00:55:39 +00001025 }
Brian Paula0faa7f2000-07-18 16:55:56 +00001026 for (i = 0; i < EXP_TABLE_SIZE - 1; i++) {
Keith Whitwellcab974c2000-12-26 05:09:27 +00001027 l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] -
1028 l->_SpotExpTable[i][0]);
jtgafb833d1999-08-19 00:55:39 +00001029 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001030 l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0;
jtgafb833d1999-08-19 00:55:39 +00001031}
1032
1033
1034
1035
1036/* Calculate a new shine table. Doing this here saves a branch in
1037 * lighting, and the cost of doing it early may be partially offset
1038 * by keeping a MRU cache of shine tables for various shine values.
1039 */
Keith Whitwellcab974c2000-12-26 05:09:27 +00001040void
1041gl_invalidate_shine_table( GLcontext *ctx, GLuint i )
jtgafb833d1999-08-19 00:55:39 +00001042{
Keith Whitwellcab974c2000-12-26 05:09:27 +00001043 if (ctx->_ShineTable[i])
1044 ctx->_ShineTable[i]->refcount--;
1045 ctx->_ShineTable[i] = 0;
jtgafb833d1999-08-19 00:55:39 +00001046}
1047
Keith Whitwellcab974c2000-12-26 05:09:27 +00001048static void validate_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess )
jtgafb833d1999-08-19 00:55:39 +00001049{
Keith Whitwell14940c42000-11-05 18:40:57 +00001050 struct gl_shine_tab *list = ctx->_ShineTabList;
jtgafb833d1999-08-19 00:55:39 +00001051 struct gl_shine_tab *s;
1052
Keith Whitwellcab974c2000-12-26 05:09:27 +00001053/* fprintf(stderr, "validate_shine_table %d, shininess %f\n", i, shininess); */
1054
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001055 foreach(s, list)
Keith Whitwellcab974c2000-12-26 05:09:27 +00001056 if ( s->shininess == shininess )
jtgafb833d1999-08-19 00:55:39 +00001057 break;
1058
Brian Paula0faa7f2000-07-18 16:55:56 +00001059 if (s == list) {
Keith Whitwellcab974c2000-12-26 05:09:27 +00001060 GLint i;
1061 GLfloat *m;
1062
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001063 foreach(s, list)
Brian Paula0faa7f2000-07-18 16:55:56 +00001064 if (s->refcount == 0)
Keith Whitwellcab974c2000-12-26 05:09:27 +00001065 break;
jtgafb833d1999-08-19 00:55:39 +00001066
Keith Whitwellcab974c2000-12-26 05:09:27 +00001067 m = s->tab;
1068 m[0] = 0.0;
1069 if (shininess == 0.0) {
1070 for (i = 1 ; i <= SHINE_TABLE_SIZE ; i++)
1071 m[i] = 1.0;
1072 }
1073 else {
1074 for (i = 1 ; i < SHINE_TABLE_SIZE ; i++) {
Brian Paulf22c04c2001-01-04 16:22:18 +00001075 GLdouble t, x = i / (GLfloat) (SHINE_TABLE_SIZE - 1);
1076 if (x < 0.005) /* underflow check */
1077 x = 0.005;
1078 t = pow(x, shininess);
Keith Whitwellcab974c2000-12-26 05:09:27 +00001079 if (t > 1e-20)
1080 m[i] = t;
1081 else
1082 m[i] = 0.0;
1083 }
1084 m[SHINE_TABLE_SIZE] = 1.0;
1085 }
1086
1087 s->shininess = shininess;
jtgafb833d1999-08-19 00:55:39 +00001088 }
1089
Keith Whitwellcab974c2000-12-26 05:09:27 +00001090 if (ctx->_ShineTable[i])
1091 ctx->_ShineTable[i]->refcount--;
1092
Keith Whitwell14940c42000-11-05 18:40:57 +00001093 ctx->_ShineTable[i] = s;
jtgafb833d1999-08-19 00:55:39 +00001094 move_to_tail( list, s );
1095 s->refcount++;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001096}
1097
1098void
1099gl_validate_all_lighting_tables( GLcontext *ctx )
1100{
1101 GLint i;
1102 GLfloat shininess;
1103
1104 shininess = ctx->Light.Material[0].Shininess;
1105 if (!ctx->_ShineTable[0]) validate_shine_table( ctx, 0, shininess );
1106
1107 shininess = ctx->Light.Material[1].Shininess;
1108 if (!ctx->_ShineTable[1]) validate_shine_table( ctx, 1, shininess );
1109
1110 for (i = 0 ; i < MAX_LIGHTS ; i++)
1111 if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1)
1112 validate_spot_exp_table( &ctx->Light.Light[i] );
jtgafb833d1999-08-19 00:55:39 +00001113}
1114
1115
1116
jtgafb833d1999-08-19 00:55:39 +00001117
1118/*
1119 * Examine current lighting parameters to determine if the optimized lighting
1120 * function can be used.
1121 * Also, precompute some lighting values such as the products of light
1122 * source and material ambient, diffuse and specular coefficients.
1123 */
Brian Paula0faa7f2000-07-18 16:55:56 +00001124void
1125gl_update_lighting( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001126{
1127 struct gl_light *light;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001128 ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001129 ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT;
1130 ctx->_NeedNormals &= ~NEED_NORMALS_LIGHT;
Keith Whitwell14940c42000-11-05 18:40:57 +00001131 ctx->Light._Flags = 0;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001132
1133 if (!ctx->Light.Enabled)
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001134 return;
1135
1136 ctx->_NeedNormals |= NEED_NORMALS_LIGHT;
1137
1138 if (ctx->Light.Model.TwoSide)
Keith Whitwellcab974c2000-12-26 05:09:27 +00001139 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
jtgafb833d1999-08-19 00:55:39 +00001140
1141 foreach(light, &ctx->Light.EnabledList) {
Keith Whitwell14940c42000-11-05 18:40:57 +00001142 ctx->Light._Flags |= light->_Flags;
jtgafb833d1999-08-19 00:55:39 +00001143 }
1144
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001145 ctx->Light._NeedVertices =
Keith Whitwell14940c42000-11-05 18:40:57 +00001146 ((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) ||
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001147 ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
1148 ctx->Light.Model.LocalViewer);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001149
1150 if ((ctx->Light._Flags & LIGHT_POSITIONAL) ||
1151 ctx->Light.Model.LocalViewer)
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001152 ctx->_NeedEyeCoords |= NEED_EYE_LIGHT;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001153
1154
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001155 /* XXX: This test is overkill & needs to be fixed both for software and
1156 * hardware t&l drivers. The above should be sufficient & should
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001157 * be tested to verify this.
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001158 */
1159 if (ctx->Light._NeedVertices)
1160 ctx->_NeedEyeCoords |= NEED_EYE_LIGHT;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001161
jtgafb833d1999-08-19 00:55:39 +00001162
Keith Whitwellcab974c2000-12-26 05:09:27 +00001163 /* Precompute some shading values. Although we reference
1164 * Light.Material here, we can get away without flushing
1165 * FLUSH_UPDATE_CURRENT, as when any outstanding material changes
1166 * are flushed, they will update the derived state at that time.
jtgafb833d1999-08-19 00:55:39 +00001167 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001168 if (ctx->Visual.RGBAflag) {
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001169 GLuint sides = ctx->Light.Model.TwoSide ? 2 : 1;
jtgafb833d1999-08-19 00:55:39 +00001170 GLuint side;
1171 for (side=0; side < sides; side++) {
1172 struct gl_material *mat = &ctx->Light.Material[side];
Brian Paulc535ba52000-06-29 04:56:30 +00001173
Keith Whitwell14940c42000-11-05 18:40:57 +00001174 COPY_3V(ctx->Light._BaseColor[side], mat->Emission);
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001175 ACC_SCALE_3V(ctx->Light._BaseColor[side],
jtgafb833d1999-08-19 00:55:39 +00001176 ctx->Light.Model.Ambient,
1177 mat->Ambient);
1178
Brian Paul3041d052001-01-02 22:02:51 +00001179 UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[side],
1180 ctx->Light.Material[side].Diffuse[3] );
jtgafb833d1999-08-19 00:55:39 +00001181 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001182
1183 foreach (light, &ctx->Light.EnabledList) {
jtgafb833d1999-08-19 00:55:39 +00001184 for (side=0; side< sides; side++) {
Brian Paulc535ba52000-06-29 04:56:30 +00001185 const struct gl_material *mat = &ctx->Light.Material[side];
Keith Whitwell14940c42000-11-05 18:40:57 +00001186 SCALE_3V( light->_MatDiffuse[side], light->Diffuse, mat->Diffuse );
1187 SCALE_3V( light->_MatAmbient[side], light->Ambient, mat->Ambient );
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001188 SCALE_3V( light->_MatSpecular[side], light->Specular,
1189 mat->Specular);
jtgafb833d1999-08-19 00:55:39 +00001190 }
1191 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001192 }
Brian Paulc535ba52000-06-29 04:56:30 +00001193 else {
1194 static const GLfloat ci[3] = { .30, .59, .11 };
jtgafb833d1999-08-19 00:55:39 +00001195 foreach(light, &ctx->Light.EnabledList) {
Keith Whitwell14940c42000-11-05 18:40:57 +00001196 light->_dli = DOT3(ci, light->Diffuse);
1197 light->_sli = DOT3(ci, light->Specular);
jtgafb833d1999-08-19 00:55:39 +00001198 }
1199 }
1200}
1201
Brian Paulc535ba52000-06-29 04:56:30 +00001202
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001203/* _NEW_MODELVIEW
1204 * _NEW_LIGHT
1205 * _TNL_NEW_NEED_EYE_COORDS
1206 *
1207 * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled.
1208 * Also update on lighting space changes.
jtgafb833d1999-08-19 00:55:39 +00001209 */
Brian Paula0faa7f2000-07-18 16:55:56 +00001210void
1211gl_compute_light_positions( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001212{
1213 struct gl_light *light;
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001214 static const GLfloat eye_z[3] = { 0, 0, 1 };
jtgafb833d1999-08-19 00:55:39 +00001215
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001216 if (!ctx->Light.Enabled)
1217 return;
1218
1219 if (ctx->_NeedEyeCoords) {
1220 COPY_3V( ctx->_EyeZDir, eye_z );
1221 }
1222 else {
1223 TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelView.m );
1224 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001225
jtgafb833d1999-08-19 00:55:39 +00001226 foreach (light, &ctx->Light.EnabledList) {
1227
Keith Whitwell14940c42000-11-05 18:40:57 +00001228 if (ctx->_NeedEyeCoords) {
1229 COPY_4FV( light->_Position, light->EyePosition );
jtgafb833d1999-08-19 00:55:39 +00001230 }
Brian Paulde82d062000-06-26 23:37:46 +00001231 else {
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001232 TRANSFORM_POINT( light->_Position, ctx->ModelView.inv,
Brian Paulde82d062000-06-26 23:37:46 +00001233 light->EyePosition );
1234 }
jtgafb833d1999-08-19 00:55:39 +00001235
Keith Whitwell14940c42000-11-05 18:40:57 +00001236 if (!(light->_Flags & LIGHT_POSITIONAL)) {
jtgafb833d1999-08-19 00:55:39 +00001237 /* VP (VP) = Normalize( Position ) */
Keith Whitwell14940c42000-11-05 18:40:57 +00001238 COPY_3V( light->_VP_inf_norm, light->_Position );
1239 NORMALIZE_3FV( light->_VP_inf_norm );
jtgafb833d1999-08-19 00:55:39 +00001240
Brian Paulde82d062000-06-26 23:37:46 +00001241 if (!ctx->Light.Model.LocalViewer) {
Keith Whitwell14940c42000-11-05 18:40:57 +00001242 /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
1243 ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir);
1244 NORMALIZE_3FV( light->_h_inf_norm );
jtgafb833d1999-08-19 00:55:39 +00001245 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001246 light->_VP_inf_spot_attenuation = 1.0;
jtgafb833d1999-08-19 00:55:39 +00001247 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001248
Keith Whitwell14940c42000-11-05 18:40:57 +00001249 if (light->_Flags & LIGHT_SPOT) {
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001250 if (ctx->_NeedEyeCoords) {
Keith Whitwell14940c42000-11-05 18:40:57 +00001251 COPY_3V( light->_NormDirection, light->EyeDirection );
Brian Paulde82d062000-06-26 23:37:46 +00001252 }
1253 else {
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001254 TRANSFORM_NORMAL( light->_NormDirection,
jtgafb833d1999-08-19 00:55:39 +00001255 light->EyeDirection,
1256 ctx->ModelView.m);
1257 }
1258
Keith Whitwell14940c42000-11-05 18:40:57 +00001259 NORMALIZE_3FV( light->_NormDirection );
jtgafb833d1999-08-19 00:55:39 +00001260
Keith Whitwell14940c42000-11-05 18:40:57 +00001261 if (!(light->_Flags & LIGHT_POSITIONAL)) {
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001262 GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm,
Keith Whitwell14940c42000-11-05 18:40:57 +00001263 light->_NormDirection);
jtgafb833d1999-08-19 00:55:39 +00001264
Keith Whitwell14940c42000-11-05 18:40:57 +00001265 if (PV_dot_dir > light->_CosCutoff) {
jtgafb833d1999-08-19 00:55:39 +00001266 double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
1267 int k = (int) x;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001268 light->_VP_inf_spot_attenuation =
1269 (light->_SpotExpTable[k][0] +
Keith Whitwell14940c42000-11-05 18:40:57 +00001270 (x-k)*light->_SpotExpTable[k][1]);
jtgafb833d1999-08-19 00:55:39 +00001271 }
Brian Paulde82d062000-06-26 23:37:46 +00001272 else {
Keith Whitwell14940c42000-11-05 18:40:57 +00001273 light->_VP_inf_spot_attenuation = 0;
Brian Paulde82d062000-06-26 23:37:46 +00001274 }
jtgafb833d1999-08-19 00:55:39 +00001275 }
1276 }
1277 }
1278}
1279
1280