1 /* $Id: light.c,v 1.52 2002/09/16 17:56:02 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
9 * 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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * 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.
39 #include "simple_list.h"
42 #include "math/m_xform.h"
43 #include "math/m_matrix.h"
47 /* XXX this is a bit of a hack needed for compilation within XFree86 */
54 _mesa_ShadeModel( GLenum mode
)
56 GET_CURRENT_CONTEXT(ctx
);
57 ASSERT_OUTSIDE_BEGIN_END(ctx
);
59 if (MESA_VERBOSE
& VERBOSE_API
)
60 _mesa_debug(ctx
, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode
));
62 if (mode
!= GL_FLAT
&& mode
!= GL_SMOOTH
) {
63 _mesa_error( ctx
, GL_INVALID_ENUM
, "glShadeModel" );
67 if (ctx
->Light
.ShadeModel
== mode
)
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
);
80 _mesa_Lightf( GLenum light
, GLenum pname
, GLfloat param
)
82 _mesa_Lightfv( light
, pname
, ¶m
);
87 _mesa_Lightfv( GLenum light
, GLenum pname
, const GLfloat
*params
)
89 GET_CURRENT_CONTEXT(ctx
);
90 GLint i
= (GLint
) (light
- GL_LIGHT0
);
91 struct gl_light
*l
= &ctx
->Light
.Light
[i
];
93 if (i
< 0 || i
>= (GLint
) ctx
->Const
.MaxLights
) {
94 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLight(light=0x%x)", light
);
100 if (TEST_EQ_4V(l
->Ambient
, params
))
102 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
103 COPY_4V( l
->Ambient
, params
);
106 if (TEST_EQ_4V(l
->Diffuse
, params
))
108 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
109 COPY_4V( l
->Diffuse
, params
);
112 if (TEST_EQ_4V(l
->Specular
, params
))
114 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
115 COPY_4V( l
->Specular
, params
);
119 /* transform position by ModelView matrix */
120 TRANSFORM_POINT( tmp
, ctx
->ModelviewMatrixStack
.Top
->m
, params
);
121 if (TEST_EQ_4V(l
->EyePosition
, tmp
))
123 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
124 COPY_4V(l
->EyePosition
, tmp
);
125 if (l
->EyePosition
[3] != 0.0F
)
126 l
->_Flags
|= LIGHT_POSITIONAL
;
128 l
->_Flags
&= ~LIGHT_POSITIONAL
;
131 case GL_SPOT_DIRECTION
: {
133 /* transform direction by inverse modelview */
134 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
135 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
137 TRANSFORM_NORMAL( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
138 if (TEST_EQ_3V(l
->EyeDirection
, tmp
))
140 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
141 COPY_3V(l
->EyeDirection
, tmp
);
144 case GL_SPOT_EXPONENT
:
145 if (params
[0]<0.0 || params
[0]>128.0) {
146 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
149 if (l
->SpotExponent
== params
[0])
151 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
152 l
->SpotExponent
= params
[0];
153 _mesa_invalidate_spot_exp_table( l
);
156 if ((params
[0]<0.0 || params
[0]>90.0) && params
[0]!=180.0) {
157 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
160 if (l
->SpotCutoff
== params
[0])
162 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
163 l
->SpotCutoff
= params
[0];
164 l
->_CosCutoff
= (GLfloat
) cos(params
[0]*DEG2RAD
);
165 if (l
->_CosCutoff
< 0)
167 if (l
->SpotCutoff
!= 180.0F
)
168 l
->_Flags
|= LIGHT_SPOT
;
170 l
->_Flags
&= ~LIGHT_SPOT
;
172 case GL_CONSTANT_ATTENUATION
:
174 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
177 if (l
->ConstantAttenuation
== params
[0])
179 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
180 l
->ConstantAttenuation
= params
[0];
182 case GL_LINEAR_ATTENUATION
:
184 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
187 if (l
->LinearAttenuation
== params
[0])
189 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
190 l
->LinearAttenuation
= params
[0];
192 case GL_QUADRATIC_ATTENUATION
:
194 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
197 if (l
->QuadraticAttenuation
== params
[0])
199 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
200 l
->QuadraticAttenuation
= params
[0];
203 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLight(pname=0x%x)", pname
);
207 if (ctx
->Driver
.Lightfv
)
208 ctx
->Driver
.Lightfv( ctx
, light
, pname
, params
);
213 _mesa_Lighti( GLenum light
, GLenum pname
, GLint param
)
215 _mesa_Lightiv( light
, pname
, ¶m
);
220 _mesa_Lightiv( GLenum light
, GLenum pname
, const GLint
*params
)
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] );
234 fparam
[0] = (GLfloat
) params
[0];
235 fparam
[1] = (GLfloat
) params
[1];
236 fparam
[2] = (GLfloat
) params
[2];
237 fparam
[3] = (GLfloat
) params
[3];
239 case GL_SPOT_DIRECTION
:
240 fparam
[0] = (GLfloat
) params
[0];
241 fparam
[1] = (GLfloat
) params
[1];
242 fparam
[2] = (GLfloat
) params
[2];
244 case GL_SPOT_EXPONENT
:
246 case GL_CONSTANT_ATTENUATION
:
247 case GL_LINEAR_ATTENUATION
:
248 case GL_QUADRATIC_ATTENUATION
:
249 fparam
[0] = (GLfloat
) params
[0];
252 /* error will be caught later in gl_Lightfv */
256 _mesa_Lightfv( light
, pname
, fparam
);
262 _mesa_GetLightfv( GLenum light
, GLenum pname
, GLfloat
*params
)
264 GET_CURRENT_CONTEXT(ctx
);
265 GLint l
= (GLint
) (light
- GL_LIGHT0
);
266 ASSERT_OUTSIDE_BEGIN_END(ctx
);
268 if (l
< 0 || l
>= (GLint
) ctx
->Const
.MaxLights
) {
269 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightfv" );
275 COPY_4V( params
, ctx
->Light
.Light
[l
].Ambient
);
278 COPY_4V( params
, ctx
->Light
.Light
[l
].Diffuse
);
281 COPY_4V( params
, ctx
->Light
.Light
[l
].Specular
);
284 COPY_4V( params
, ctx
->Light
.Light
[l
].EyePosition
);
286 case GL_SPOT_DIRECTION
:
287 COPY_3V( params
, ctx
->Light
.Light
[l
].EyeDirection
);
289 case GL_SPOT_EXPONENT
:
290 params
[0] = ctx
->Light
.Light
[l
].SpotExponent
;
293 params
[0] = ctx
->Light
.Light
[l
].SpotCutoff
;
295 case GL_CONSTANT_ATTENUATION
:
296 params
[0] = ctx
->Light
.Light
[l
].ConstantAttenuation
;
298 case GL_LINEAR_ATTENUATION
:
299 params
[0] = ctx
->Light
.Light
[l
].LinearAttenuation
;
301 case GL_QUADRATIC_ATTENUATION
:
302 params
[0] = ctx
->Light
.Light
[l
].QuadraticAttenuation
;
305 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightfv" );
313 _mesa_GetLightiv( GLenum light
, GLenum pname
, GLint
*params
)
315 GET_CURRENT_CONTEXT(ctx
);
316 GLint l
= (GLint
) (light
- GL_LIGHT0
);
317 ASSERT_OUTSIDE_BEGIN_END(ctx
);
319 if (l
< 0 || l
>= (GLint
) ctx
->Const
.MaxLights
) {
320 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightiv" );
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]);
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]);
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]);
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];
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];
354 case GL_SPOT_EXPONENT
:
355 params
[0] = (GLint
) ctx
->Light
.Light
[l
].SpotExponent
;
358 params
[0] = (GLint
) ctx
->Light
.Light
[l
].SpotCutoff
;
360 case GL_CONSTANT_ATTENUATION
:
361 params
[0] = (GLint
) ctx
->Light
.Light
[l
].ConstantAttenuation
;
363 case GL_LINEAR_ATTENUATION
:
364 params
[0] = (GLint
) ctx
->Light
.Light
[l
].LinearAttenuation
;
366 case GL_QUADRATIC_ATTENUATION
:
367 params
[0] = (GLint
) ctx
->Light
.Light
[l
].QuadraticAttenuation
;
370 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightiv" );
377 /**********************************************************************/
378 /*** Light Model ***/
379 /**********************************************************************/
383 _mesa_LightModelfv( GLenum pname
, const GLfloat
*params
)
387 GET_CURRENT_CONTEXT(ctx
);
388 ASSERT_OUTSIDE_BEGIN_END(ctx
);
391 case GL_LIGHT_MODEL_AMBIENT
:
392 if (TEST_EQ_4V( ctx
->Light
.Model
.Ambient
, params
))
394 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
395 COPY_4V( ctx
->Light
.Model
.Ambient
, params
);
397 case GL_LIGHT_MODEL_LOCAL_VIEWER
:
398 newbool
= (params
[0]!=0.0);
399 if (ctx
->Light
.Model
.LocalViewer
== newbool
)
401 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
402 ctx
->Light
.Model
.LocalViewer
= newbool
;
404 case GL_LIGHT_MODEL_TWO_SIDE
:
405 newbool
= (params
[0]!=0.0);
406 if (ctx
->Light
.Model
.TwoSide
== newbool
)
408 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
409 ctx
->Light
.Model
.TwoSide
= newbool
;
411 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
412 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
414 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
416 case GL_LIGHT_MODEL_COLOR_CONTROL
:
417 if (params
[0] == (GLfloat
) GL_SINGLE_COLOR
)
418 newenum
= GL_SINGLE_COLOR
;
419 else if (params
[0] == (GLfloat
) GL_SEPARATE_SPECULAR_COLOR
)
420 newenum
= GL_SEPARATE_SPECULAR_COLOR
;
422 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLightModel(param=0x0%x)",
426 if (ctx
->Light
.Model
.ColorControl
== newenum
)
428 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
429 ctx
->Light
.Model
.ColorControl
= newenum
;
431 if ((ctx
->Light
.Enabled
&&
432 ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
)
433 || ctx
->Fog
.ColorSumEnabled
)
434 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
436 ctx
->_TriangleCaps
&= ~DD_SEPARATE_SPECULAR
;
440 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLightModel(pname=0x%x)", pname
);
444 if (ctx
->Driver
.LightModelfv
)
445 ctx
->Driver
.LightModelfv( ctx
, pname
, params
);
450 _mesa_LightModeliv( GLenum pname
, const GLint
*params
)
455 case GL_LIGHT_MODEL_AMBIENT
:
456 fparam
[0] = INT_TO_FLOAT( params
[0] );
457 fparam
[1] = INT_TO_FLOAT( params
[1] );
458 fparam
[2] = INT_TO_FLOAT( params
[2] );
459 fparam
[3] = INT_TO_FLOAT( params
[3] );
461 case GL_LIGHT_MODEL_LOCAL_VIEWER
:
462 case GL_LIGHT_MODEL_TWO_SIDE
:
463 case GL_LIGHT_MODEL_COLOR_CONTROL
:
464 fparam
[0] = (GLfloat
) params
[0];
467 /* Error will be caught later in gl_LightModelfv */
470 _mesa_LightModelfv( pname
, fparam
);
475 _mesa_LightModeli( GLenum pname
, GLint param
)
477 _mesa_LightModeliv( pname
, ¶m
);
482 _mesa_LightModelf( GLenum pname
, GLfloat param
)
484 _mesa_LightModelfv( pname
, ¶m
);
489 /********** MATERIAL **********/
493 * Given a face and pname value (ala glColorMaterial), compute a bitmask
494 * of the targeted material values.
497 _mesa_material_bitmask( GLcontext
*ctx
, GLenum face
, GLenum pname
,
498 GLuint legal
, const char *where
)
502 /* Make a bitmask indicating what material attribute(s) we're updating */
505 bitmask
|= FRONT_EMISSION_BIT
| BACK_EMISSION_BIT
;
508 bitmask
|= FRONT_AMBIENT_BIT
| BACK_AMBIENT_BIT
;
511 bitmask
|= FRONT_DIFFUSE_BIT
| BACK_DIFFUSE_BIT
;
514 bitmask
|= FRONT_SPECULAR_BIT
| BACK_SPECULAR_BIT
;
517 bitmask
|= FRONT_SHININESS_BIT
| BACK_SHININESS_BIT
;
519 case GL_AMBIENT_AND_DIFFUSE
:
520 bitmask
|= FRONT_AMBIENT_BIT
| BACK_AMBIENT_BIT
;
521 bitmask
|= FRONT_DIFFUSE_BIT
| BACK_DIFFUSE_BIT
;
523 case GL_COLOR_INDEXES
:
524 bitmask
|= FRONT_INDEXES_BIT
| BACK_INDEXES_BIT
;
527 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
531 if (face
==GL_FRONT
) {
532 bitmask
&= FRONT_MATERIAL_BITS
;
534 else if (face
==GL_BACK
) {
535 bitmask
&= BACK_MATERIAL_BITS
;
537 else if (face
!= GL_FRONT_AND_BACK
) {
538 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
542 if (bitmask
& ~legal
) {
543 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
551 /* Perform a straight copy between pairs of materials.
553 void _mesa_copy_material_pairs( struct gl_material dst
[2],
554 const struct gl_material src
[2],
557 if (bitmask
& FRONT_EMISSION_BIT
) {
558 COPY_4FV( dst
[0].Emission
, src
[0].Emission
);
560 if (bitmask
& BACK_EMISSION_BIT
) {
561 COPY_4FV( dst
[1].Emission
, src
[1].Emission
);
563 if (bitmask
& FRONT_AMBIENT_BIT
) {
564 COPY_4FV( dst
[0].Ambient
, src
[0].Ambient
);
566 if (bitmask
& BACK_AMBIENT_BIT
) {
567 COPY_4FV( dst
[1].Ambient
, src
[1].Ambient
);
569 if (bitmask
& FRONT_DIFFUSE_BIT
) {
570 COPY_4FV( dst
[0].Diffuse
, src
[0].Diffuse
);
572 if (bitmask
& BACK_DIFFUSE_BIT
) {
573 COPY_4FV( dst
[1].Diffuse
, src
[1].Diffuse
);
575 if (bitmask
& FRONT_SPECULAR_BIT
) {
576 COPY_4FV( dst
[0].Specular
, src
[0].Specular
);
578 if (bitmask
& BACK_SPECULAR_BIT
) {
579 COPY_4FV( dst
[1].Specular
, src
[1].Specular
);
581 if (bitmask
& FRONT_SHININESS_BIT
) {
582 dst
[0].Shininess
= src
[0].Shininess
;
584 if (bitmask
& BACK_SHININESS_BIT
) {
585 dst
[1].Shininess
= src
[1].Shininess
;
587 if (bitmask
& FRONT_INDEXES_BIT
) {
588 dst
[0].AmbientIndex
= src
[0].AmbientIndex
;
589 dst
[0].DiffuseIndex
= src
[0].DiffuseIndex
;
590 dst
[0].SpecularIndex
= src
[0].SpecularIndex
;
592 if (bitmask
& BACK_INDEXES_BIT
) {
593 dst
[1].AmbientIndex
= src
[1].AmbientIndex
;
594 dst
[1].DiffuseIndex
= src
[1].DiffuseIndex
;
595 dst
[1].SpecularIndex
= src
[1].SpecularIndex
;
601 * Check if the global material has to be updated with info that was
602 * associated with a vertex via glMaterial.
603 * This function is used when any material values get changed between
604 * glBegin/glEnd either by calling glMaterial() or by calling glColor()
605 * when GL_COLOR_MATERIAL is enabled.
607 * src[0] is front material, src[1] is back material
609 * Additionally keeps the precomputed lighting state uptodate.
611 void _mesa_update_material( GLcontext
*ctx
,
612 const struct gl_material src
[2],
615 struct gl_light
*light
, *list
= &ctx
->Light
.EnabledList
;
617 if (ctx
->Light
.ColorMaterialEnabled
)
618 bitmask
&= ~ctx
->Light
.ColorMaterialBitmask
;
620 if (MESA_VERBOSE
&VERBOSE_IMMEDIATE
)
621 _mesa_debug(ctx
, "_mesa_update_material, mask 0x%x\n", bitmask
);
626 /* update material emission */
627 if (bitmask
& FRONT_EMISSION_BIT
) {
628 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
629 COPY_4FV( mat
->Emission
, src
[0].Emission
);
631 if (bitmask
& BACK_EMISSION_BIT
) {
632 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
633 COPY_4FV( mat
->Emission
, src
[1].Emission
);
636 /* update material ambience */
637 if (bitmask
& FRONT_AMBIENT_BIT
) {
638 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
639 COPY_4FV( mat
->Ambient
, src
[0].Ambient
);
640 foreach (light
, list
) {
641 SCALE_3V( light
->_MatAmbient
[0], light
->Ambient
, src
[0].Ambient
);
644 if (bitmask
& BACK_AMBIENT_BIT
) {
645 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
646 COPY_4FV( mat
->Ambient
, src
[1].Ambient
);
647 foreach (light
, list
) {
648 SCALE_3V( light
->_MatAmbient
[1], light
->Ambient
, src
[1].Ambient
);
652 /* update BaseColor = emission + scene's ambience * material's ambience */
653 if (bitmask
& (FRONT_EMISSION_BIT
| FRONT_AMBIENT_BIT
)) {
654 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
655 COPY_3V( ctx
->Light
._BaseColor
[0], mat
->Emission
);
656 ACC_SCALE_3V( ctx
->Light
._BaseColor
[0], mat
->Ambient
,
657 ctx
->Light
.Model
.Ambient
);
659 if (bitmask
& (BACK_EMISSION_BIT
| BACK_AMBIENT_BIT
)) {
660 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
661 COPY_3V( ctx
->Light
._BaseColor
[1], mat
->Emission
);
662 ACC_SCALE_3V( ctx
->Light
._BaseColor
[1], mat
->Ambient
,
663 ctx
->Light
.Model
.Ambient
);
666 /* update material diffuse values */
667 if (bitmask
& FRONT_DIFFUSE_BIT
) {
668 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
669 COPY_4FV( mat
->Diffuse
, src
[0].Diffuse
);
670 foreach (light
, list
) {
671 SCALE_3V( light
->_MatDiffuse
[0], light
->Diffuse
, mat
->Diffuse
);
674 if (bitmask
& BACK_DIFFUSE_BIT
) {
675 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
676 COPY_4FV( mat
->Diffuse
, src
[1].Diffuse
);
677 foreach (light
, list
) {
678 SCALE_3V( light
->_MatDiffuse
[1], light
->Diffuse
, mat
->Diffuse
);
682 /* update material specular values */
683 if (bitmask
& FRONT_SPECULAR_BIT
) {
684 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
685 COPY_4FV( mat
->Specular
, src
[0].Specular
);
686 foreach (light
, list
) {
687 SCALE_3V( light
->_MatSpecular
[0], light
->Specular
, mat
->Specular
);
690 if (bitmask
& BACK_SPECULAR_BIT
) {
691 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
692 COPY_4FV( mat
->Specular
, src
[1].Specular
);
693 foreach (light
, list
) {
694 SCALE_3V( light
->_MatSpecular
[1], light
->Specular
, mat
->Specular
);
698 if (bitmask
& FRONT_SHININESS_BIT
) {
699 ctx
->Light
.Material
[0].Shininess
= src
[0].Shininess
;
700 _mesa_invalidate_shine_table( ctx
, 0 );
702 if (bitmask
& BACK_SHININESS_BIT
) {
703 ctx
->Light
.Material
[1].Shininess
= src
[1].Shininess
;
704 _mesa_invalidate_shine_table( ctx
, 1 );
707 if (bitmask
& FRONT_INDEXES_BIT
) {
708 ctx
->Light
.Material
[0].AmbientIndex
= src
[0].AmbientIndex
;
709 ctx
->Light
.Material
[0].DiffuseIndex
= src
[0].DiffuseIndex
;
710 ctx
->Light
.Material
[0].SpecularIndex
= src
[0].SpecularIndex
;
712 if (bitmask
& BACK_INDEXES_BIT
) {
713 ctx
->Light
.Material
[1].AmbientIndex
= src
[1].AmbientIndex
;
714 ctx
->Light
.Material
[1].DiffuseIndex
= src
[1].DiffuseIndex
;
715 ctx
->Light
.Material
[1].SpecularIndex
= src
[1].SpecularIndex
;
719 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
720 _mesa_debug(ctx
, "update_mat emission : %f %f %f\n",
721 mat
->Emission
[0], mat
->Emission
[1], mat
->Emission
[2]);
722 _mesa_debug(ctx
, "update_mat specular : %f %f %f\n",
723 mat
->Specular
[0], mat
->Specular
[1], mat
->Specular
[2]);
724 _mesa_debug(ctx
, "update_mat diffuse : %f %f %f\n",
725 mat
->Diffuse
[0], mat
->Diffuse
[1], mat
->Diffuse
[2]);
726 _mesa_debug(ctx
, "update_mat ambient : %f %f %f\n",
727 mat
->Ambient
[0], mat
->Ambient
[1], mat
->Ambient
[2]);
738 * Update the current materials from the given rgba color
739 * according to the bitmask in ColorMaterialBitmask, which is
740 * set by glColorMaterial().
742 void _mesa_update_color_material( GLcontext
*ctx
,
743 const GLfloat color
[4] )
745 struct gl_light
*light
, *list
= &ctx
->Light
.EnabledList
;
746 GLuint bitmask
= ctx
->Light
.ColorMaterialBitmask
;
748 if (MESA_VERBOSE
&VERBOSE_IMMEDIATE
)
749 _mesa_debug(ctx
, "_mesa_update_color_material, mask 0x%x\n", bitmask
);
751 /* update emissive colors */
752 if (bitmask
& FRONT_EMISSION_BIT
) {
753 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
754 COPY_4FV( mat
->Emission
, color
);
757 if (bitmask
& BACK_EMISSION_BIT
) {
758 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
759 COPY_4FV( mat
->Emission
, color
);
762 /* update light->_MatAmbient = light's ambient * material's ambient */
763 if (bitmask
& FRONT_AMBIENT_BIT
) {
764 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
765 foreach (light
, list
) {
766 SCALE_3V( light
->_MatAmbient
[0], light
->Ambient
, color
);
768 COPY_4FV( mat
->Ambient
, color
);
771 if (bitmask
& BACK_AMBIENT_BIT
) {
772 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
773 foreach (light
, list
) {
774 SCALE_3V( light
->_MatAmbient
[1], light
->Ambient
, color
);
776 COPY_4FV( mat
->Ambient
, color
);
779 /* update BaseColor = emission + scene's ambience * material's ambience */
780 if (bitmask
& (FRONT_EMISSION_BIT
| FRONT_AMBIENT_BIT
)) {
781 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
782 COPY_3V( ctx
->Light
._BaseColor
[0], mat
->Emission
);
783 ACC_SCALE_3V( ctx
->Light
._BaseColor
[0], mat
->Ambient
, ctx
->Light
.Model
.Ambient
);
786 if (bitmask
& (BACK_EMISSION_BIT
| BACK_AMBIENT_BIT
)) {
787 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
788 COPY_3V( ctx
->Light
._BaseColor
[1], mat
->Emission
);
789 ACC_SCALE_3V( ctx
->Light
._BaseColor
[1], mat
->Ambient
, ctx
->Light
.Model
.Ambient
);
792 /* update light->_MatDiffuse = light's diffuse * material's diffuse */
793 if (bitmask
& FRONT_DIFFUSE_BIT
) {
794 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
795 COPY_4FV( mat
->Diffuse
, color
);
796 foreach (light
, list
) {
797 SCALE_3V( light
->_MatDiffuse
[0], light
->Diffuse
, mat
->Diffuse
);
801 if (bitmask
& BACK_DIFFUSE_BIT
) {
802 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
803 COPY_4FV( mat
->Diffuse
, color
);
804 foreach (light
, list
) {
805 SCALE_3V( light
->_MatDiffuse
[1], light
->Diffuse
, mat
->Diffuse
);
809 /* update light->_MatSpecular = light's specular * material's specular */
810 if (bitmask
& FRONT_SPECULAR_BIT
) {
811 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
812 COPY_4FV( mat
->Specular
, color
);
813 foreach (light
, list
) {
814 ACC_SCALE_3V( light
->_MatSpecular
[0], light
->Specular
, mat
->Specular
);
818 if (bitmask
& BACK_SPECULAR_BIT
) {
819 struct gl_material
*mat
= &ctx
->Light
.Material
[1];
820 COPY_4FV( mat
->Specular
, color
);
821 foreach (light
, list
) {
822 ACC_SCALE_3V( light
->_MatSpecular
[1], light
->Specular
, mat
->Specular
);
827 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
828 _mesa_debug(ctx
, "update_color_mat emission : %f %f %f\n",
829 mat
->Emission
[0], mat
->Emission
[1], mat
->Emission
[2]);
830 _mesa_debug(ctx
, "update_color_mat specular : %f %f %f\n",
831 mat
->Specular
[0], mat
->Specular
[1], mat
->Specular
[2]);
832 _mesa_debug(ctx
, "update_color_mat diffuse : %f %f %f\n",
833 mat
->Diffuse
[0], mat
->Diffuse
[1], mat
->Diffuse
[2]);
834 _mesa_debug(ctx
, "update_color_mat ambient : %f %f %f\n",
835 mat
->Ambient
[0], mat
->Ambient
[1], mat
->Ambient
[2]);
843 _mesa_ColorMaterial( GLenum face
, GLenum mode
)
845 GET_CURRENT_CONTEXT(ctx
);
847 GLuint legal
= (FRONT_EMISSION_BIT
| BACK_EMISSION_BIT
|
848 FRONT_SPECULAR_BIT
| BACK_SPECULAR_BIT
|
849 FRONT_DIFFUSE_BIT
| BACK_DIFFUSE_BIT
|
850 FRONT_AMBIENT_BIT
| BACK_AMBIENT_BIT
);
851 ASSERT_OUTSIDE_BEGIN_END(ctx
);
853 if (MESA_VERBOSE
&VERBOSE_API
)
854 _mesa_debug(ctx
, "glColorMaterial %s %s\n",
855 _mesa_lookup_enum_by_nr(face
),
856 _mesa_lookup_enum_by_nr(mode
));
858 bitmask
= _mesa_material_bitmask(ctx
, face
, mode
, legal
, "glColorMaterial");
860 if (ctx
->Light
.ColorMaterialBitmask
== bitmask
&&
861 ctx
->Light
.ColorMaterialFace
== face
&&
862 ctx
->Light
.ColorMaterialMode
== mode
)
865 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
866 ctx
->Light
.ColorMaterialBitmask
= bitmask
;
867 ctx
->Light
.ColorMaterialFace
= face
;
868 ctx
->Light
.ColorMaterialMode
= mode
;
870 if (ctx
->Light
.ColorMaterialEnabled
) {
871 FLUSH_CURRENT( ctx
, 0 );
872 _mesa_update_color_material(ctx
,ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
875 if (ctx
->Driver
.ColorMaterial
)
876 (*ctx
->Driver
.ColorMaterial
)( ctx
, face
, mode
);
884 _mesa_GetMaterialfv( GLenum face
, GLenum pname
, GLfloat
*params
)
886 GET_CURRENT_CONTEXT(ctx
);
888 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* update materials */
890 if (face
==GL_FRONT
) {
893 else if (face
==GL_BACK
) {
897 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(face)" );
902 COPY_4FV( params
, ctx
->Light
.Material
[f
].Ambient
);
905 COPY_4FV( params
, ctx
->Light
.Material
[f
].Diffuse
);
908 COPY_4FV( params
, ctx
->Light
.Material
[f
].Specular
);
911 COPY_4FV( params
, ctx
->Light
.Material
[f
].Emission
);
914 *params
= ctx
->Light
.Material
[f
].Shininess
;
916 case GL_COLOR_INDEXES
:
917 params
[0] = ctx
->Light
.Material
[f
].AmbientIndex
;
918 params
[1] = ctx
->Light
.Material
[f
].DiffuseIndex
;
919 params
[2] = ctx
->Light
.Material
[f
].SpecularIndex
;
922 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(pname)" );
929 _mesa_GetMaterialiv( GLenum face
, GLenum pname
, GLint
*params
)
931 GET_CURRENT_CONTEXT(ctx
);
933 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* update materials */
935 if (face
==GL_FRONT
) {
938 else if (face
==GL_BACK
) {
942 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialiv(face)" );
947 params
[0] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Ambient
[0] );
948 params
[1] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Ambient
[1] );
949 params
[2] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Ambient
[2] );
950 params
[3] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Ambient
[3] );
953 params
[0] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Diffuse
[0] );
954 params
[1] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Diffuse
[1] );
955 params
[2] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Diffuse
[2] );
956 params
[3] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Diffuse
[3] );
959 params
[0] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Specular
[0] );
960 params
[1] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Specular
[1] );
961 params
[2] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Specular
[2] );
962 params
[3] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Specular
[3] );
965 params
[0] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Emission
[0] );
966 params
[1] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Emission
[1] );
967 params
[2] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Emission
[2] );
968 params
[3] = FLOAT_TO_INT( ctx
->Light
.Material
[f
].Emission
[3] );
971 *params
= ROUNDF( ctx
->Light
.Material
[f
].Shininess
);
973 case GL_COLOR_INDEXES
:
974 params
[0] = ROUNDF( ctx
->Light
.Material
[f
].AmbientIndex
);
975 params
[1] = ROUNDF( ctx
->Light
.Material
[f
].DiffuseIndex
);
976 params
[2] = ROUNDF( ctx
->Light
.Material
[f
].SpecularIndex
);
979 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(pname)" );
986 /**********************************************************************/
987 /***** Lighting computation *****/
988 /**********************************************************************/
993 * When two-sided lighting is enabled we compute the color (or index)
994 * for both the front and back side of the primitive. Then, when the
995 * orientation of the facet is later learned, we can determine which
996 * color (or index) to use for rendering.
998 * KW: We now know orientation in advance and only shade for
999 * the side or sides which are actually required.
1003 * V = vertex position
1004 * P = light source position
1009 * // light at infinity
1010 * IF local_viewer THEN
1011 * _VP_inf_norm = unit vector from V to P // Precompute
1013 * // eye at infinity
1014 * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
1019 * Normalize( v ) = normalized vector v
1020 * Magnitude( v ) = length of vector v
1026 * Whenever the spotlight exponent for a light changes we must call
1027 * this function to recompute the exponent lookup table.
1030 _mesa_invalidate_spot_exp_table( struct gl_light
*l
)
1032 l
->_SpotExpTable
[0][0] = -1;
1035 static void validate_spot_exp_table( struct gl_light
*l
)
1038 GLdouble exponent
= l
->SpotExponent
;
1042 l
->_SpotExpTable
[0][0] = 0.0;
1044 for (i
= EXP_TABLE_SIZE
- 1; i
> 0 ;i
--) {
1046 tmp
= pow(i
/ (GLdouble
) (EXP_TABLE_SIZE
- 1), exponent
);
1047 if (tmp
< FLT_MIN
* 100.0) {
1052 l
->_SpotExpTable
[i
][0] = (GLfloat
) tmp
;
1054 for (i
= 0; i
< EXP_TABLE_SIZE
- 1; i
++) {
1055 l
->_SpotExpTable
[i
][1] = (l
->_SpotExpTable
[i
+1][0] -
1056 l
->_SpotExpTable
[i
][0]);
1058 l
->_SpotExpTable
[EXP_TABLE_SIZE
-1][1] = 0.0;
1064 /* Calculate a new shine table. Doing this here saves a branch in
1065 * lighting, and the cost of doing it early may be partially offset
1066 * by keeping a MRU cache of shine tables for various shine values.
1069 _mesa_invalidate_shine_table( GLcontext
*ctx
, GLuint i
)
1071 if (ctx
->_ShineTable
[i
])
1072 ctx
->_ShineTable
[i
]->refcount
--;
1073 ctx
->_ShineTable
[i
] = 0;
1076 static void validate_shine_table( GLcontext
*ctx
, GLuint i
, GLfloat shininess
)
1078 struct gl_shine_tab
*list
= ctx
->_ShineTabList
;
1079 struct gl_shine_tab
*s
;
1082 if ( s
->shininess
== shininess
)
1090 if (s
->refcount
== 0)
1095 if (shininess
== 0.0) {
1096 for (j
= 1 ; j
<= SHINE_TABLE_SIZE
; j
++)
1100 for (j
= 1 ; j
< SHINE_TABLE_SIZE
; j
++) {
1101 GLdouble t
, x
= j
/ (GLfloat
) (SHINE_TABLE_SIZE
- 1);
1102 if (x
< 0.005) /* underflow check */
1104 t
= pow(x
, shininess
);
1110 m
[SHINE_TABLE_SIZE
] = 1.0;
1113 s
->shininess
= shininess
;
1116 if (ctx
->_ShineTable
[i
])
1117 ctx
->_ShineTable
[i
]->refcount
--;
1119 ctx
->_ShineTable
[i
] = s
;
1120 move_to_tail( list
, s
);
1125 _mesa_validate_all_lighting_tables( GLcontext
*ctx
)
1130 shininess
= ctx
->Light
.Material
[0].Shininess
;
1131 if (!ctx
->_ShineTable
[0] || ctx
->_ShineTable
[0]->shininess
!= shininess
)
1132 validate_shine_table( ctx
, 0, shininess
);
1134 shininess
= ctx
->Light
.Material
[1].Shininess
;
1135 if (!ctx
->_ShineTable
[1] || ctx
->_ShineTable
[1]->shininess
!= shininess
)
1136 validate_shine_table( ctx
, 1, shininess
);
1138 for (i
= 0 ; i
< MAX_LIGHTS
; i
++)
1139 if (ctx
->Light
.Light
[i
]._SpotExpTable
[0][0] == -1)
1140 validate_spot_exp_table( &ctx
->Light
.Light
[i
] );
1147 * Examine current lighting parameters to determine if the optimized lighting
1148 * function can be used.
1149 * Also, precompute some lighting values such as the products of light
1150 * source and material ambient, diffuse and specular coefficients.
1153 _mesa_update_lighting( GLcontext
*ctx
)
1155 struct gl_light
*light
;
1156 ctx
->_NeedEyeCoords
&= ~NEED_EYE_LIGHT
;
1157 ctx
->_NeedNormals
&= ~NEED_NORMALS_LIGHT
;
1158 ctx
->Light
._Flags
= 0;
1160 if (!ctx
->Light
.Enabled
)
1163 ctx
->_NeedNormals
|= NEED_NORMALS_LIGHT
;
1165 foreach(light
, &ctx
->Light
.EnabledList
) {
1166 ctx
->Light
._Flags
|= light
->_Flags
;
1169 ctx
->Light
._NeedVertices
=
1170 ((ctx
->Light
._Flags
& (LIGHT_POSITIONAL
|LIGHT_SPOT
)) ||
1171 ctx
->Light
.Model
.ColorControl
== GL_SEPARATE_SPECULAR_COLOR
||
1172 ctx
->Light
.Model
.LocalViewer
);
1174 if ((ctx
->Light
._Flags
& LIGHT_POSITIONAL
) ||
1175 ctx
->Light
.Model
.LocalViewer
)
1176 ctx
->_NeedEyeCoords
|= NEED_EYE_LIGHT
;
1179 /* XXX: This test is overkill & needs to be fixed both for software and
1180 * hardware t&l drivers. The above should be sufficient & should
1181 * be tested to verify this.
1183 if (ctx
->Light
._NeedVertices
)
1184 ctx
->_NeedEyeCoords
|= NEED_EYE_LIGHT
;
1187 /* Precompute some shading values. Although we reference
1188 * Light.Material here, we can get away without flushing
1189 * FLUSH_UPDATE_CURRENT, as when any outstanding material changes
1190 * are flushed, they will update the derived state at that time.
1192 if (ctx
->Visual
.rgbMode
) {
1193 GLuint sides
= ctx
->Light
.Model
.TwoSide
? 2 : 1;
1195 for (side
=0; side
< sides
; side
++) {
1196 struct gl_material
*mat
= &ctx
->Light
.Material
[side
];
1198 COPY_3V(ctx
->Light
._BaseColor
[side
], mat
->Emission
);
1199 ACC_SCALE_3V(ctx
->Light
._BaseColor
[side
],
1200 ctx
->Light
.Model
.Ambient
,
1204 foreach (light
, &ctx
->Light
.EnabledList
) {
1205 for (side
=0; side
< sides
; side
++) {
1206 const struct gl_material
*mat
= &ctx
->Light
.Material
[side
];
1207 SCALE_3V( light
->_MatDiffuse
[side
], light
->Diffuse
, mat
->Diffuse
);
1208 SCALE_3V( light
->_MatAmbient
[side
], light
->Ambient
, mat
->Ambient
);
1209 SCALE_3V( light
->_MatSpecular
[side
], light
->Specular
,
1215 static const GLfloat ci
[3] = { .30F
, .59F
, .11F
};
1216 foreach(light
, &ctx
->Light
.EnabledList
) {
1217 light
->_dli
= DOT3(ci
, light
->Diffuse
);
1218 light
->_sli
= DOT3(ci
, light
->Specular
);
1226 * _TNL_NEW_NEED_EYE_COORDS
1228 * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled.
1229 * Also update on lighting space changes.
1232 _mesa_compute_light_positions( GLcontext
*ctx
)
1234 struct gl_light
*light
;
1235 static const GLfloat eye_z
[3] = { 0, 0, 1 };
1237 if (!ctx
->Light
.Enabled
)
1240 if (ctx
->_NeedEyeCoords
) {
1241 COPY_3V( ctx
->_EyeZDir
, eye_z
);
1244 TRANSFORM_NORMAL( ctx
->_EyeZDir
, eye_z
, ctx
->ModelviewMatrixStack
.Top
->m
);
1247 foreach (light
, &ctx
->Light
.EnabledList
) {
1249 if (ctx
->_NeedEyeCoords
) {
1250 COPY_4FV( light
->_Position
, light
->EyePosition
);
1253 TRANSFORM_POINT( light
->_Position
, ctx
->ModelviewMatrixStack
.Top
->inv
,
1254 light
->EyePosition
);
1257 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
1258 /* VP (VP) = Normalize( Position ) */
1259 COPY_3V( light
->_VP_inf_norm
, light
->_Position
);
1260 NORMALIZE_3FV( light
->_VP_inf_norm
);
1262 if (!ctx
->Light
.Model
.LocalViewer
) {
1263 /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
1264 ADD_3V( light
->_h_inf_norm
, light
->_VP_inf_norm
, ctx
->_EyeZDir
);
1265 NORMALIZE_3FV( light
->_h_inf_norm
);
1267 light
->_VP_inf_spot_attenuation
= 1.0;
1270 if (light
->_Flags
& LIGHT_SPOT
) {
1271 if (ctx
->_NeedEyeCoords
) {
1272 COPY_3V( light
->_NormDirection
, light
->EyeDirection
);
1275 TRANSFORM_NORMAL( light
->_NormDirection
,
1276 light
->EyeDirection
,
1277 ctx
->ModelviewMatrixStack
.Top
->m
);
1280 NORMALIZE_3FV( light
->_NormDirection
);
1282 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
1283 GLfloat PV_dot_dir
= - DOT3(light
->_VP_inf_norm
,
1284 light
->_NormDirection
);
1286 if (PV_dot_dir
> light
->_CosCutoff
) {
1287 double x
= PV_dot_dir
* (EXP_TABLE_SIZE
-1);
1289 light
->_VP_inf_spot_attenuation
=
1290 (GLfloat
) (light
->_SpotExpTable
[k
][0] +
1291 (x
-k
)*light
->_SpotExpTable
[k
][1]);
1294 light
->_VP_inf_spot_attenuation
= 0;