2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #include "simple_list.h"
34 #include "math/m_matrix.h"
38 _mesa_ShadeModel( GLenum mode
)
40 GET_CURRENT_CONTEXT(ctx
);
41 ASSERT_OUTSIDE_BEGIN_END(ctx
);
43 if (MESA_VERBOSE
& VERBOSE_API
)
44 _mesa_debug(ctx
, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode
));
46 if (mode
!= GL_FLAT
&& mode
!= GL_SMOOTH
) {
47 _mesa_error( ctx
, GL_INVALID_ENUM
, "glShadeModel" );
51 if (ctx
->Light
.ShadeModel
== mode
)
54 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
55 ctx
->Light
.ShadeModel
= mode
;
56 ctx
->_TriangleCaps
^= DD_FLATSHADE
;
57 if (ctx
->Driver
.ShadeModel
)
58 (*ctx
->Driver
.ShadeModel
)( ctx
, mode
);
63 _mesa_Lightf( GLenum light
, GLenum pname
, GLfloat param
)
65 _mesa_Lightfv( light
, pname
, ¶m
);
70 _mesa_Lightfv( GLenum light
, GLenum pname
, const GLfloat
*params
)
72 GET_CURRENT_CONTEXT(ctx
);
73 GLint i
= (GLint
) (light
- GL_LIGHT0
);
74 struct gl_light
*l
= &ctx
->Light
.Light
[i
];
76 if (i
< 0 || i
>= (GLint
) ctx
->Const
.MaxLights
) {
77 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLight(light=0x%x)", light
);
83 if (TEST_EQ_4V(l
->Ambient
, params
))
85 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
86 COPY_4V( l
->Ambient
, params
);
89 if (TEST_EQ_4V(l
->Diffuse
, params
))
91 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
92 COPY_4V( l
->Diffuse
, params
);
95 if (TEST_EQ_4V(l
->Specular
, params
))
97 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
98 COPY_4V( l
->Specular
, params
);
102 /* transform position by ModelView matrix */
103 TRANSFORM_POINT( tmp
, ctx
->ModelviewMatrixStack
.Top
->m
, params
);
104 if (TEST_EQ_4V(l
->EyePosition
, tmp
))
106 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
107 COPY_4V(l
->EyePosition
, tmp
);
108 if (l
->EyePosition
[3] != 0.0F
)
109 l
->_Flags
|= LIGHT_POSITIONAL
;
111 l
->_Flags
&= ~LIGHT_POSITIONAL
;
114 case GL_SPOT_DIRECTION
: {
116 /* transform direction by inverse modelview */
117 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
118 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
120 TRANSFORM_NORMAL( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
121 if (TEST_EQ_3V(l
->EyeDirection
, tmp
))
123 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
124 COPY_3V(l
->EyeDirection
, tmp
);
127 case GL_SPOT_EXPONENT
:
128 if (params
[0]<0.0 || params
[0]>ctx
->Const
.MaxSpotExponent
) {
129 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
132 if (l
->SpotExponent
== params
[0])
134 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
135 l
->SpotExponent
= params
[0];
136 _mesa_invalidate_spot_exp_table( l
);
139 if ((params
[0]<0.0 || params
[0]>90.0) && params
[0]!=180.0) {
140 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
143 if (l
->SpotCutoff
== params
[0])
145 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
146 l
->SpotCutoff
= params
[0];
147 l
->_CosCutoff
= (GLfloat
) _mesa_cos(params
[0]*DEG2RAD
);
148 if (l
->_CosCutoff
< 0)
150 if (l
->SpotCutoff
!= 180.0F
)
151 l
->_Flags
|= LIGHT_SPOT
;
153 l
->_Flags
&= ~LIGHT_SPOT
;
155 case GL_CONSTANT_ATTENUATION
:
157 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
160 if (l
->ConstantAttenuation
== params
[0])
162 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
163 l
->ConstantAttenuation
= params
[0];
165 case GL_LINEAR_ATTENUATION
:
167 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
170 if (l
->LinearAttenuation
== params
[0])
172 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
173 l
->LinearAttenuation
= params
[0];
175 case GL_QUADRATIC_ATTENUATION
:
177 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
180 if (l
->QuadraticAttenuation
== params
[0])
182 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
183 l
->QuadraticAttenuation
= params
[0];
186 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLight(pname=0x%x)", pname
);
190 if (ctx
->Driver
.Lightfv
)
191 ctx
->Driver
.Lightfv( ctx
, light
, pname
, params
);
196 _mesa_Lighti( GLenum light
, GLenum pname
, GLint param
)
198 _mesa_Lightiv( light
, pname
, ¶m
);
203 _mesa_Lightiv( GLenum light
, GLenum pname
, const GLint
*params
)
211 fparam
[0] = INT_TO_FLOAT( params
[0] );
212 fparam
[1] = INT_TO_FLOAT( params
[1] );
213 fparam
[2] = INT_TO_FLOAT( params
[2] );
214 fparam
[3] = INT_TO_FLOAT( params
[3] );
217 fparam
[0] = (GLfloat
) params
[0];
218 fparam
[1] = (GLfloat
) params
[1];
219 fparam
[2] = (GLfloat
) params
[2];
220 fparam
[3] = (GLfloat
) params
[3];
222 case GL_SPOT_DIRECTION
:
223 fparam
[0] = (GLfloat
) params
[0];
224 fparam
[1] = (GLfloat
) params
[1];
225 fparam
[2] = (GLfloat
) params
[2];
227 case GL_SPOT_EXPONENT
:
229 case GL_CONSTANT_ATTENUATION
:
230 case GL_LINEAR_ATTENUATION
:
231 case GL_QUADRATIC_ATTENUATION
:
232 fparam
[0] = (GLfloat
) params
[0];
235 /* error will be caught later in gl_Lightfv */
239 _mesa_Lightfv( light
, pname
, fparam
);
245 _mesa_GetLightfv( GLenum light
, GLenum pname
, GLfloat
*params
)
247 GET_CURRENT_CONTEXT(ctx
);
248 GLint l
= (GLint
) (light
- GL_LIGHT0
);
249 ASSERT_OUTSIDE_BEGIN_END(ctx
);
251 if (l
< 0 || l
>= (GLint
) ctx
->Const
.MaxLights
) {
252 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightfv" );
258 COPY_4V( params
, ctx
->Light
.Light
[l
].Ambient
);
261 COPY_4V( params
, ctx
->Light
.Light
[l
].Diffuse
);
264 COPY_4V( params
, ctx
->Light
.Light
[l
].Specular
);
267 COPY_4V( params
, ctx
->Light
.Light
[l
].EyePosition
);
269 case GL_SPOT_DIRECTION
:
270 COPY_3V( params
, ctx
->Light
.Light
[l
].EyeDirection
);
272 case GL_SPOT_EXPONENT
:
273 params
[0] = ctx
->Light
.Light
[l
].SpotExponent
;
276 params
[0] = ctx
->Light
.Light
[l
].SpotCutoff
;
278 case GL_CONSTANT_ATTENUATION
:
279 params
[0] = ctx
->Light
.Light
[l
].ConstantAttenuation
;
281 case GL_LINEAR_ATTENUATION
:
282 params
[0] = ctx
->Light
.Light
[l
].LinearAttenuation
;
284 case GL_QUADRATIC_ATTENUATION
:
285 params
[0] = ctx
->Light
.Light
[l
].QuadraticAttenuation
;
288 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightfv" );
295 _mesa_GetLightiv( GLenum light
, GLenum pname
, GLint
*params
)
297 GET_CURRENT_CONTEXT(ctx
);
298 GLint l
= (GLint
) (light
- GL_LIGHT0
);
299 ASSERT_OUTSIDE_BEGIN_END(ctx
);
301 if (l
< 0 || l
>= (GLint
) ctx
->Const
.MaxLights
) {
302 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightiv" );
308 params
[0] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[0]);
309 params
[1] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[1]);
310 params
[2] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[2]);
311 params
[3] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[3]);
314 params
[0] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[0]);
315 params
[1] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[1]);
316 params
[2] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[2]);
317 params
[3] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[3]);
320 params
[0] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[0]);
321 params
[1] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[1]);
322 params
[2] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[2]);
323 params
[3] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[3]);
326 params
[0] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[0];
327 params
[1] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[1];
328 params
[2] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[2];
329 params
[3] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[3];
331 case GL_SPOT_DIRECTION
:
332 params
[0] = (GLint
) ctx
->Light
.Light
[l
].EyeDirection
[0];
333 params
[1] = (GLint
) ctx
->Light
.Light
[l
].EyeDirection
[1];
334 params
[2] = (GLint
) ctx
->Light
.Light
[l
].EyeDirection
[2];
336 case GL_SPOT_EXPONENT
:
337 params
[0] = (GLint
) ctx
->Light
.Light
[l
].SpotExponent
;
340 params
[0] = (GLint
) ctx
->Light
.Light
[l
].SpotCutoff
;
342 case GL_CONSTANT_ATTENUATION
:
343 params
[0] = (GLint
) ctx
->Light
.Light
[l
].ConstantAttenuation
;
345 case GL_LINEAR_ATTENUATION
:
346 params
[0] = (GLint
) ctx
->Light
.Light
[l
].LinearAttenuation
;
348 case GL_QUADRATIC_ATTENUATION
:
349 params
[0] = (GLint
) ctx
->Light
.Light
[l
].QuadraticAttenuation
;
352 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightiv" );
359 /**********************************************************************/
360 /*** Light Model ***/
361 /**********************************************************************/
365 _mesa_LightModelfv( GLenum pname
, const GLfloat
*params
)
369 GET_CURRENT_CONTEXT(ctx
);
370 ASSERT_OUTSIDE_BEGIN_END(ctx
);
373 case GL_LIGHT_MODEL_AMBIENT
:
374 if (TEST_EQ_4V( ctx
->Light
.Model
.Ambient
, params
))
376 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
377 COPY_4V( ctx
->Light
.Model
.Ambient
, params
);
379 case GL_LIGHT_MODEL_LOCAL_VIEWER
:
380 newbool
= (params
[0]!=0.0);
381 if (ctx
->Light
.Model
.LocalViewer
== newbool
)
383 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
384 ctx
->Light
.Model
.LocalViewer
= newbool
;
386 case GL_LIGHT_MODEL_TWO_SIDE
:
387 newbool
= (params
[0]!=0.0);
388 if (ctx
->Light
.Model
.TwoSide
== newbool
)
390 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
391 ctx
->Light
.Model
.TwoSide
= newbool
;
393 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
394 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
396 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
398 case GL_LIGHT_MODEL_COLOR_CONTROL
:
399 if (params
[0] == (GLfloat
) GL_SINGLE_COLOR
)
400 newenum
= GL_SINGLE_COLOR
;
401 else if (params
[0] == (GLfloat
) GL_SEPARATE_SPECULAR_COLOR
)
402 newenum
= GL_SEPARATE_SPECULAR_COLOR
;
404 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLightModel(param=0x0%x)",
408 if (ctx
->Light
.Model
.ColorControl
== newenum
)
410 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
411 ctx
->Light
.Model
.ColorControl
= newenum
;
413 if ((ctx
->Light
.Enabled
&&
414 ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
)
415 || ctx
->Fog
.ColorSumEnabled
)
416 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
418 ctx
->_TriangleCaps
&= ~DD_SEPARATE_SPECULAR
;
422 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLightModel(pname=0x%x)", pname
);
426 if (ctx
->Driver
.LightModelfv
)
427 ctx
->Driver
.LightModelfv( ctx
, pname
, params
);
432 _mesa_LightModeliv( GLenum pname
, const GLint
*params
)
437 case GL_LIGHT_MODEL_AMBIENT
:
438 fparam
[0] = INT_TO_FLOAT( params
[0] );
439 fparam
[1] = INT_TO_FLOAT( params
[1] );
440 fparam
[2] = INT_TO_FLOAT( params
[2] );
441 fparam
[3] = INT_TO_FLOAT( params
[3] );
443 case GL_LIGHT_MODEL_LOCAL_VIEWER
:
444 case GL_LIGHT_MODEL_TWO_SIDE
:
445 case GL_LIGHT_MODEL_COLOR_CONTROL
:
446 fparam
[0] = (GLfloat
) params
[0];
449 /* Error will be caught later in gl_LightModelfv */
452 _mesa_LightModelfv( pname
, fparam
);
457 _mesa_LightModeli( GLenum pname
, GLint param
)
459 _mesa_LightModeliv( pname
, ¶m
);
464 _mesa_LightModelf( GLenum pname
, GLfloat param
)
466 _mesa_LightModelfv( pname
, ¶m
);
471 /********** MATERIAL **********/
475 * Given a face and pname value (ala glColorMaterial), compute a bitmask
476 * of the targeted material values.
479 _mesa_material_bitmask( GLcontext
*ctx
, GLenum face
, GLenum pname
,
480 GLuint legal
, const char *where
)
484 /* Make a bitmask indicating what material attribute(s) we're updating */
487 bitmask
|= MAT_BIT_FRONT_EMISSION
| MAT_BIT_BACK_EMISSION
;
490 bitmask
|= MAT_BIT_FRONT_AMBIENT
| MAT_BIT_BACK_AMBIENT
;
493 bitmask
|= MAT_BIT_FRONT_DIFFUSE
| MAT_BIT_BACK_DIFFUSE
;
496 bitmask
|= MAT_BIT_FRONT_SPECULAR
| MAT_BIT_BACK_SPECULAR
;
499 bitmask
|= MAT_BIT_FRONT_SHININESS
| MAT_BIT_BACK_SHININESS
;
501 case GL_AMBIENT_AND_DIFFUSE
:
502 bitmask
|= MAT_BIT_FRONT_AMBIENT
| MAT_BIT_BACK_AMBIENT
;
503 bitmask
|= MAT_BIT_FRONT_DIFFUSE
| MAT_BIT_BACK_DIFFUSE
;
505 case GL_COLOR_INDEXES
:
506 bitmask
|= MAT_BIT_FRONT_INDEXES
| MAT_BIT_BACK_INDEXES
;
509 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
513 if (face
==GL_FRONT
) {
514 bitmask
&= FRONT_MATERIAL_BITS
;
516 else if (face
==GL_BACK
) {
517 bitmask
&= BACK_MATERIAL_BITS
;
519 else if (face
!= GL_FRONT_AND_BACK
) {
520 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
524 if (bitmask
& ~legal
) {
525 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
534 /* Perform a straight copy between materials.
537 _mesa_copy_materials( struct gl_material
*dst
,
538 const struct gl_material
*src
,
543 for (i
= 0 ; i
< MAT_ATTRIB_MAX
; i
++)
544 if (bitmask
& (1<<i
))
545 COPY_4FV( dst
->Attrib
[i
], src
->Attrib
[i
] );
550 /* Update derived values following a change in ctx->Light.Material
553 _mesa_update_material( GLcontext
*ctx
, GLuint bitmask
)
555 struct gl_light
*light
, *list
= &ctx
->Light
.EnabledList
;
556 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
558 if (MESA_VERBOSE
&VERBOSE_IMMEDIATE
)
559 _mesa_debug(ctx
, "_mesa_update_material, mask 0x%x\n", bitmask
);
564 /* update material ambience */
565 if (bitmask
& MAT_BIT_FRONT_AMBIENT
) {
566 foreach (light
, list
) {
567 SCALE_3V( light
->_MatAmbient
[0], light
->Ambient
,
568 mat
[MAT_ATTRIB_FRONT_AMBIENT
]);
572 if (bitmask
& MAT_BIT_BACK_AMBIENT
) {
573 foreach (light
, list
) {
574 SCALE_3V( light
->_MatAmbient
[1], light
->Ambient
,
575 mat
[MAT_ATTRIB_BACK_AMBIENT
]);
579 /* update BaseColor = emission + scene's ambience * material's ambience */
580 if (bitmask
& (MAT_BIT_FRONT_EMISSION
| MAT_BIT_FRONT_AMBIENT
)) {
581 COPY_3V( ctx
->Light
._BaseColor
[0], mat
[MAT_ATTRIB_FRONT_EMISSION
] );
582 ACC_SCALE_3V( ctx
->Light
._BaseColor
[0], mat
[MAT_ATTRIB_FRONT_AMBIENT
],
583 ctx
->Light
.Model
.Ambient
);
586 if (bitmask
& (MAT_BIT_BACK_EMISSION
| MAT_BIT_BACK_AMBIENT
)) {
587 COPY_3V( ctx
->Light
._BaseColor
[1], mat
[MAT_ATTRIB_BACK_EMISSION
] );
588 ACC_SCALE_3V( ctx
->Light
._BaseColor
[1], mat
[MAT_ATTRIB_BACK_AMBIENT
],
589 ctx
->Light
.Model
.Ambient
);
592 /* update material diffuse values */
593 if (bitmask
& MAT_BIT_FRONT_DIFFUSE
) {
594 foreach (light
, list
) {
595 SCALE_3V( light
->_MatDiffuse
[0], light
->Diffuse
,
596 mat
[MAT_ATTRIB_FRONT_DIFFUSE
] );
600 if (bitmask
& MAT_BIT_BACK_DIFFUSE
) {
601 foreach (light
, list
) {
602 SCALE_3V( light
->_MatDiffuse
[1], light
->Diffuse
,
603 mat
[MAT_ATTRIB_BACK_DIFFUSE
] );
607 /* update material specular values */
608 if (bitmask
& MAT_BIT_FRONT_SPECULAR
) {
609 foreach (light
, list
) {
610 SCALE_3V( light
->_MatSpecular
[0], light
->Specular
,
611 mat
[MAT_ATTRIB_FRONT_SPECULAR
]);
615 if (bitmask
& MAT_BIT_BACK_SPECULAR
) {
616 foreach (light
, list
) {
617 SCALE_3V( light
->_MatSpecular
[1], light
->Specular
,
618 mat
[MAT_ATTRIB_BACK_SPECULAR
]);
622 if (bitmask
& MAT_BIT_FRONT_SHININESS
) {
623 _mesa_invalidate_shine_table( ctx
, 0 );
626 if (bitmask
& MAT_BIT_BACK_SHININESS
) {
627 _mesa_invalidate_shine_table( ctx
, 1 );
633 * Update the current materials from the given rgba color
634 * according to the bitmask in ColorMaterialBitmask, which is
635 * set by glColorMaterial().
638 _mesa_update_color_material( GLcontext
*ctx
, const GLfloat color
[4] )
640 GLuint bitmask
= ctx
->Light
.ColorMaterialBitmask
;
641 struct gl_material
*mat
= &ctx
->Light
.Material
;
644 for (i
= 0 ; i
< MAT_ATTRIB_MAX
; i
++)
645 if (bitmask
& (1<<i
))
646 COPY_4FV( mat
->Attrib
[i
], color
);
648 _mesa_update_material( ctx
, bitmask
);
653 _mesa_ColorMaterial( GLenum face
, GLenum mode
)
655 GET_CURRENT_CONTEXT(ctx
);
657 GLuint legal
= (MAT_BIT_FRONT_EMISSION
| MAT_BIT_BACK_EMISSION
|
658 MAT_BIT_FRONT_SPECULAR
| MAT_BIT_BACK_SPECULAR
|
659 MAT_BIT_FRONT_DIFFUSE
| MAT_BIT_BACK_DIFFUSE
|
660 MAT_BIT_FRONT_AMBIENT
| MAT_BIT_BACK_AMBIENT
);
661 ASSERT_OUTSIDE_BEGIN_END(ctx
);
663 if (MESA_VERBOSE
&VERBOSE_API
)
664 _mesa_debug(ctx
, "glColorMaterial %s %s\n",
665 _mesa_lookup_enum_by_nr(face
),
666 _mesa_lookup_enum_by_nr(mode
));
668 bitmask
= _mesa_material_bitmask(ctx
, face
, mode
, legal
, "glColorMaterial");
670 if (ctx
->Light
.ColorMaterialBitmask
== bitmask
&&
671 ctx
->Light
.ColorMaterialFace
== face
&&
672 ctx
->Light
.ColorMaterialMode
== mode
)
675 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
676 ctx
->Light
.ColorMaterialBitmask
= bitmask
;
677 ctx
->Light
.ColorMaterialFace
= face
;
678 ctx
->Light
.ColorMaterialMode
= mode
;
680 if (ctx
->Light
.ColorMaterialEnabled
) {
681 FLUSH_CURRENT( ctx
, 0 );
682 _mesa_update_color_material(ctx
,ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
685 if (ctx
->Driver
.ColorMaterial
)
686 (*ctx
->Driver
.ColorMaterial
)( ctx
, face
, mode
);
691 _mesa_GetMaterialfv( GLenum face
, GLenum pname
, GLfloat
*params
)
693 GET_CURRENT_CONTEXT(ctx
);
695 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
696 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* update materials */
698 if (face
==GL_FRONT
) {
701 else if (face
==GL_BACK
) {
705 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(face)" );
711 COPY_4FV( params
, mat
[MAT_ATTRIB_AMBIENT(f
)] );
714 COPY_4FV( params
, mat
[MAT_ATTRIB_DIFFUSE(f
)] );
717 COPY_4FV( params
, mat
[MAT_ATTRIB_SPECULAR(f
)] );
720 COPY_4FV( params
, mat
[MAT_ATTRIB_EMISSION(f
)] );
723 *params
= mat
[MAT_ATTRIB_SHININESS(f
)][0];
725 case GL_COLOR_INDEXES
:
726 params
[0] = mat
[MAT_ATTRIB_INDEXES(f
)][0];
727 params
[1] = mat
[MAT_ATTRIB_INDEXES(f
)][1];
728 params
[2] = mat
[MAT_ATTRIB_INDEXES(f
)][2];
731 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(pname)" );
737 _mesa_GetMaterialiv( GLenum face
, GLenum pname
, GLint
*params
)
739 GET_CURRENT_CONTEXT(ctx
);
741 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
742 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* update materials */
744 if (face
==GL_FRONT
) {
747 else if (face
==GL_BACK
) {
751 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialiv(face)" );
756 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][0] );
757 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][1] );
758 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][2] );
759 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][3] );
762 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][0] );
763 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][1] );
764 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][2] );
765 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][3] );
768 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][0] );
769 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][1] );
770 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][2] );
771 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][3] );
774 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][0] );
775 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][1] );
776 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][2] );
777 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][3] );
780 *params
= IROUND( mat
[MAT_ATTRIB_SHININESS(f
)][0] );
782 case GL_COLOR_INDEXES
:
783 params
[0] = IROUND( mat
[MAT_ATTRIB_INDEXES(f
)][0] );
784 params
[1] = IROUND( mat
[MAT_ATTRIB_INDEXES(f
)][1] );
785 params
[2] = IROUND( mat
[MAT_ATTRIB_INDEXES(f
)][2] );
788 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(pname)" );
794 /**********************************************************************/
795 /***** Lighting computation *****/
796 /**********************************************************************/
801 * When two-sided lighting is enabled we compute the color (or index)
802 * for both the front and back side of the primitive. Then, when the
803 * orientation of the facet is later learned, we can determine which
804 * color (or index) to use for rendering.
806 * KW: We now know orientation in advance and only shade for
807 * the side or sides which are actually required.
811 * V = vertex position
812 * P = light source position
817 * // light at infinity
818 * IF local_viewer THEN
819 * _VP_inf_norm = unit vector from V to P // Precompute
822 * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
827 * Normalize( v ) = normalized vector v
828 * Magnitude( v ) = length of vector v
834 * Whenever the spotlight exponent for a light changes we must call
835 * this function to recompute the exponent lookup table.
838 _mesa_invalidate_spot_exp_table( struct gl_light
*l
)
840 l
->_SpotExpTable
[0][0] = -1;
845 validate_spot_exp_table( struct gl_light
*l
)
848 GLdouble exponent
= l
->SpotExponent
;
852 l
->_SpotExpTable
[0][0] = 0.0;
854 for (i
= EXP_TABLE_SIZE
- 1; i
> 0 ;i
--) {
856 tmp
= _mesa_pow(i
/ (GLdouble
) (EXP_TABLE_SIZE
- 1), exponent
);
857 if (tmp
< FLT_MIN
* 100.0) {
862 l
->_SpotExpTable
[i
][0] = (GLfloat
) tmp
;
864 for (i
= 0; i
< EXP_TABLE_SIZE
- 1; i
++) {
865 l
->_SpotExpTable
[i
][1] = (l
->_SpotExpTable
[i
+1][0] -
866 l
->_SpotExpTable
[i
][0]);
868 l
->_SpotExpTable
[EXP_TABLE_SIZE
-1][1] = 0.0;
873 /* Calculate a new shine table. Doing this here saves a branch in
874 * lighting, and the cost of doing it early may be partially offset
875 * by keeping a MRU cache of shine tables for various shine values.
878 _mesa_invalidate_shine_table( GLcontext
*ctx
, GLuint side
)
881 if (ctx
->_ShineTable
[side
])
882 ctx
->_ShineTable
[side
]->refcount
--;
883 ctx
->_ShineTable
[side
] = 0;
888 validate_shine_table( GLcontext
*ctx
, GLuint side
, GLfloat shininess
)
890 struct gl_shine_tab
*list
= ctx
->_ShineTabList
;
891 struct gl_shine_tab
*s
;
896 if ( s
->shininess
== shininess
)
904 if (s
->refcount
== 0)
909 if (shininess
== 0.0) {
910 for (j
= 1 ; j
<= SHINE_TABLE_SIZE
; j
++)
914 for (j
= 1 ; j
< SHINE_TABLE_SIZE
; j
++) {
915 GLdouble t
, x
= j
/ (GLfloat
) (SHINE_TABLE_SIZE
- 1);
916 if (x
< 0.005) /* underflow check */
918 t
= _mesa_pow(x
, shininess
);
924 m
[SHINE_TABLE_SIZE
] = 1.0;
927 s
->shininess
= shininess
;
930 if (ctx
->_ShineTable
[side
])
931 ctx
->_ShineTable
[side
]->refcount
--;
933 ctx
->_ShineTable
[side
] = s
;
934 move_to_tail( list
, s
);
940 _mesa_validate_all_lighting_tables( GLcontext
*ctx
)
945 shininess
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_SHININESS
][0];
946 if (!ctx
->_ShineTable
[0] || ctx
->_ShineTable
[0]->shininess
!= shininess
)
947 validate_shine_table( ctx
, 0, shininess
);
949 shininess
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_BACK_SHININESS
][0];
950 if (!ctx
->_ShineTable
[1] || ctx
->_ShineTable
[1]->shininess
!= shininess
)
951 validate_shine_table( ctx
, 1, shininess
);
953 for (i
= 0 ; i
< MAX_LIGHTS
; i
++)
954 if (ctx
->Light
.Light
[i
]._SpotExpTable
[0][0] == -1)
955 validate_spot_exp_table( &ctx
->Light
.Light
[i
] );
961 * Examine current lighting parameters to determine if the optimized lighting
962 * function can be used.
963 * Also, precompute some lighting values such as the products of light
964 * source and material ambient, diffuse and specular coefficients.
967 _mesa_update_lighting( GLcontext
*ctx
)
969 struct gl_light
*light
;
970 ctx
->Light
._NeedEyeCoords
= 0;
971 ctx
->Light
._Flags
= 0;
973 if (!ctx
->Light
.Enabled
)
976 foreach(light
, &ctx
->Light
.EnabledList
) {
977 ctx
->Light
._Flags
|= light
->_Flags
;
980 ctx
->Light
._NeedVertices
=
981 ((ctx
->Light
._Flags
& (LIGHT_POSITIONAL
|LIGHT_SPOT
)) ||
982 ctx
->Light
.Model
.ColorControl
== GL_SEPARATE_SPECULAR_COLOR
||
983 ctx
->Light
.Model
.LocalViewer
);
985 ctx
->Light
._NeedEyeCoords
= ((ctx
->Light
._Flags
& LIGHT_POSITIONAL
) ||
986 ctx
->Light
.Model
.LocalViewer
);
990 /* XXX: This test is overkill & needs to be fixed both for software and
991 * hardware t&l drivers. The above should be sufficient & should
992 * be tested to verify this.
994 if (ctx
->Light
._NeedVertices
)
995 ctx
->Light
._NeedEyeCoords
= GL_TRUE
;
998 /* Precompute some shading values. Although we reference
999 * Light.Material here, we can get away without flushing
1000 * FLUSH_UPDATE_CURRENT, as when any outstanding material changes
1001 * are flushed, they will update the derived state at that time.
1003 if (ctx
->Visual
.rgbMode
) {
1004 if (ctx
->Light
.Model
.TwoSide
)
1005 _mesa_update_material( ctx
,
1006 MAT_BIT_FRONT_EMISSION
|
1007 MAT_BIT_FRONT_AMBIENT
|
1008 MAT_BIT_FRONT_DIFFUSE
|
1009 MAT_BIT_FRONT_SPECULAR
|
1010 MAT_BIT_BACK_EMISSION
|
1011 MAT_BIT_BACK_AMBIENT
|
1012 MAT_BIT_BACK_DIFFUSE
|
1013 MAT_BIT_BACK_SPECULAR
);
1015 _mesa_update_material( ctx
,
1016 MAT_BIT_FRONT_EMISSION
|
1017 MAT_BIT_FRONT_AMBIENT
|
1018 MAT_BIT_FRONT_DIFFUSE
|
1019 MAT_BIT_FRONT_SPECULAR
);
1022 static const GLfloat ci
[3] = { .30F
, .59F
, .11F
};
1023 foreach(light
, &ctx
->Light
.EnabledList
) {
1024 light
->_dli
= DOT3(ci
, light
->Diffuse
);
1025 light
->_sli
= DOT3(ci
, light
->Specular
);
1033 * _TNL_NEW_NEED_EYE_COORDS
1035 * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled.
1036 * Also update on lighting space changes.
1039 compute_light_positions( GLcontext
*ctx
)
1041 struct gl_light
*light
;
1042 static const GLfloat eye_z
[3] = { 0, 0, 1 };
1044 if (!ctx
->Light
.Enabled
)
1047 if (ctx
->_NeedEyeCoords
) {
1048 COPY_3V( ctx
->_EyeZDir
, eye_z
);
1051 TRANSFORM_NORMAL( ctx
->_EyeZDir
, eye_z
, ctx
->ModelviewMatrixStack
.Top
->m
);
1054 foreach (light
, &ctx
->Light
.EnabledList
) {
1056 if (ctx
->_NeedEyeCoords
) {
1057 COPY_4FV( light
->_Position
, light
->EyePosition
);
1060 TRANSFORM_POINT( light
->_Position
, ctx
->ModelviewMatrixStack
.Top
->inv
,
1061 light
->EyePosition
);
1064 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
1065 /* VP (VP) = Normalize( Position ) */
1066 COPY_3V( light
->_VP_inf_norm
, light
->_Position
);
1067 NORMALIZE_3FV( light
->_VP_inf_norm
);
1069 if (!ctx
->Light
.Model
.LocalViewer
) {
1070 /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
1071 ADD_3V( light
->_h_inf_norm
, light
->_VP_inf_norm
, ctx
->_EyeZDir
);
1072 NORMALIZE_3FV( light
->_h_inf_norm
);
1074 light
->_VP_inf_spot_attenuation
= 1.0;
1077 if (light
->_Flags
& LIGHT_SPOT
) {
1078 if (ctx
->_NeedEyeCoords
) {
1079 COPY_3V( light
->_NormDirection
, light
->EyeDirection
);
1082 TRANSFORM_NORMAL( light
->_NormDirection
,
1083 light
->EyeDirection
,
1084 ctx
->ModelviewMatrixStack
.Top
->m
);
1087 NORMALIZE_3FV( light
->_NormDirection
);
1089 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
1090 GLfloat PV_dot_dir
= - DOT3(light
->_VP_inf_norm
,
1091 light
->_NormDirection
);
1093 if (PV_dot_dir
> light
->_CosCutoff
) {
1094 double x
= PV_dot_dir
* (EXP_TABLE_SIZE
-1);
1096 light
->_VP_inf_spot_attenuation
=
1097 (GLfloat
) (light
->_SpotExpTable
[k
][0] +
1098 (x
-k
)*light
->_SpotExpTable
[k
][1]);
1101 light
->_VP_inf_spot_attenuation
= 0;
1111 update_modelview_scale( GLcontext
*ctx
)
1113 ctx
->_ModelViewInvScale
= 1.0F
;
1114 if (ctx
->ModelviewMatrixStack
.Top
->flags
& (MAT_FLAG_UNIFORM_SCALE
|
1115 MAT_FLAG_GENERAL_SCALE
|
1116 MAT_FLAG_GENERAL_3D
|
1117 MAT_FLAG_GENERAL
) ) {
1118 const GLfloat
*m
= ctx
->ModelviewMatrixStack
.Top
->inv
;
1119 GLfloat f
= m
[2] * m
[2] + m
[6] * m
[6] + m
[10] * m
[10];
1120 if (f
< 1e-12) f
= 1.0;
1121 if (ctx
->_NeedEyeCoords
)
1122 ctx
->_ModelViewInvScale
= (GLfloat
) INV_SQRTF(f
);
1124 ctx
->_ModelViewInvScale
= (GLfloat
) SQRTF(f
);
1129 /* Bring uptodate any state that relies on _NeedEyeCoords.
1132 _mesa_update_tnl_spaces( GLcontext
*ctx
, GLuint new_state
)
1134 const GLuint oldneedeyecoords
= ctx
->_NeedEyeCoords
;
1136 ctx
->_NeedEyeCoords
= 0;
1138 if (ctx
->_ForceEyeCoords
||
1139 (ctx
->Texture
._GenFlags
& TEXGEN_NEED_EYE_COORD
) ||
1140 ctx
->Point
._Attenuated
||
1141 ctx
->Light
._NeedEyeCoords
)
1142 ctx
->_NeedEyeCoords
= 1;
1144 if (ctx
->Light
.Enabled
&&
1145 !TEST_MAT_FLAGS( ctx
->ModelviewMatrixStack
.Top
,
1146 MAT_FLAGS_LENGTH_PRESERVING
))
1147 ctx
->_NeedEyeCoords
= 1;
1150 /* Check if the truth-value interpretations of the bitfields have
1153 if (oldneedeyecoords
!= ctx
->_NeedEyeCoords
) {
1154 /* Recalculate all state that depends on _NeedEyeCoords.
1156 update_modelview_scale(ctx
);
1157 compute_light_positions( ctx
);
1159 if (ctx
->Driver
.LightingSpaceChange
)
1160 ctx
->Driver
.LightingSpaceChange( ctx
);
1163 GLuint new_state
= ctx
->NewState
;
1165 /* Recalculate that same state only if it has been invalidated
1166 * by other statechanges.
1168 if (new_state
& _NEW_MODELVIEW
)
1169 update_modelview_scale(ctx
);
1171 if (new_state
& (_NEW_LIGHT
|_NEW_MODELVIEW
))
1172 compute_light_positions( ctx
);
1177 /* Drivers may need this if the hardware tnl unit doesn't support the
1178 * light-in-modelspace optimization. It's also useful for debugging.
1181 _mesa_allow_light_in_model( GLcontext
*ctx
, GLboolean flag
)
1183 ctx
->_ForceEyeCoords
= flag
;
1184 ctx
->NewState
|= _NEW_POINT
; /* one of the bits from
1185 * _MESA_NEW_NEED_EYE_COORDS.
1191 /**********************************************************************/
1192 /***** Initialization *****/
1193 /**********************************************************************/
1196 * Initialize the n-th light data structure.
1198 * \param l pointer to the gl_light structure to be initialized.
1199 * \param n number of the light.
1200 * \note The defaults for light 0 are different than the other lights.
1203 init_light( struct gl_light
*l
, GLuint n
)
1205 make_empty_list( l
);
1207 ASSIGN_4V( l
->Ambient
, 0.0, 0.0, 0.0, 1.0 );
1209 ASSIGN_4V( l
->Diffuse
, 1.0, 1.0, 1.0, 1.0 );
1210 ASSIGN_4V( l
->Specular
, 1.0, 1.0, 1.0, 1.0 );
1213 ASSIGN_4V( l
->Diffuse
, 0.0, 0.0, 0.0, 1.0 );
1214 ASSIGN_4V( l
->Specular
, 0.0, 0.0, 0.0, 1.0 );
1216 ASSIGN_4V( l
->EyePosition
, 0.0, 0.0, 1.0, 0.0 );
1217 ASSIGN_3V( l
->EyeDirection
, 0.0, 0.0, -1.0 );
1218 l
->SpotExponent
= 0.0;
1219 _mesa_invalidate_spot_exp_table( l
);
1220 l
->SpotCutoff
= 180.0;
1221 l
->_CosCutoff
= 0.0; /* KW: -ve values not admitted */
1222 l
->ConstantAttenuation
= 1.0;
1223 l
->LinearAttenuation
= 0.0;
1224 l
->QuadraticAttenuation
= 0.0;
1225 l
->Enabled
= GL_FALSE
;
1230 * Initialize the light model data structure.
1232 * \param lm pointer to the gl_lightmodel structure to be initialized.
1235 init_lightmodel( struct gl_lightmodel
*lm
)
1237 ASSIGN_4V( lm
->Ambient
, 0.2F
, 0.2F
, 0.2F
, 1.0F
);
1238 lm
->LocalViewer
= GL_FALSE
;
1239 lm
->TwoSide
= GL_FALSE
;
1240 lm
->ColorControl
= GL_SINGLE_COLOR
;
1245 * Initialize the material data structure.
1247 * \param m pointer to the gl_material structure to be initialized.
1250 init_material( struct gl_material
*m
)
1252 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_AMBIENT
], 0.2F
, 0.2F
, 0.2F
, 1.0F
);
1253 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_DIFFUSE
], 0.8F
, 0.8F
, 0.8F
, 1.0F
);
1254 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_SPECULAR
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1255 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_EMISSION
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1256 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_SHININESS
], 0.0F
, 0.0F
, 0.0F
, 0.0F
);
1257 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_INDEXES
], 0.0F
, 1.0F
, 1.0F
, 0.0F
);
1259 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_AMBIENT
], 0.2F
, 0.2F
, 0.2F
, 1.0F
);
1260 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_DIFFUSE
], 0.8F
, 0.8F
, 0.8F
, 1.0F
);
1261 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_SPECULAR
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1262 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_EMISSION
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1263 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_SHININESS
], 0.0F
, 0.0F
, 0.0F
, 0.0F
);
1264 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_INDEXES
], 0.0F
, 1.0F
, 1.0F
, 0.0F
);
1269 _mesa_init_lighting( GLcontext
*ctx
)
1273 /* Lighting group */
1274 for (i
= 0; i
< MAX_LIGHTS
; i
++) {
1275 init_light( &ctx
->Light
.Light
[i
], i
);
1277 make_empty_list( &ctx
->Light
.EnabledList
);
1279 init_lightmodel( &ctx
->Light
.Model
);
1280 init_material( &ctx
->Light
.Material
);
1281 ctx
->Light
.ShadeModel
= GL_SMOOTH
;
1282 ctx
->Light
.Enabled
= GL_FALSE
;
1283 ctx
->Light
.ColorMaterialFace
= GL_FRONT_AND_BACK
;
1284 ctx
->Light
.ColorMaterialMode
= GL_AMBIENT_AND_DIFFUSE
;
1285 ctx
->Light
.ColorMaterialBitmask
= _mesa_material_bitmask( ctx
,
1287 GL_AMBIENT_AND_DIFFUSE
, ~0, 0 );
1289 ctx
->Light
.ColorMaterialEnabled
= GL_FALSE
;
1291 /* Lighting miscellaneous */
1292 ctx
->_ShineTabList
= MALLOC_STRUCT( gl_shine_tab
);
1293 make_empty_list( ctx
->_ShineTabList
);
1294 /* Allocate 10 (arbitrary) shininess lookup tables */
1295 for (i
= 0 ; i
< 10 ; i
++) {
1296 struct gl_shine_tab
*s
= MALLOC_STRUCT( gl_shine_tab
);
1299 insert_at_tail( ctx
->_ShineTabList
, s
);
1303 ctx
->Light
._NeedEyeCoords
= 0;
1304 ctx
->_NeedEyeCoords
= 0;
1305 ctx
->_ModelViewInvScale
= 1.0;
1310 _mesa_free_lighting_data( GLcontext
*ctx
)
1312 struct gl_shine_tab
*s
, *tmps
;
1314 /* Free lighting shininess exponentiation table */
1315 foreach_s( s
, tmps
, ctx
->_ShineTabList
) {
1318 FREE( ctx
->_ShineTabList
);