3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 #include "simple_list.h"
36 #include "math/m_xform.h"
37 #include "math/m_matrix.h"
40 /* XXX this is a bit of a hack needed for compilation within XFree86 */
47 _mesa_ShadeModel( GLenum mode
)
49 GET_CURRENT_CONTEXT(ctx
);
50 ASSERT_OUTSIDE_BEGIN_END(ctx
);
52 if (MESA_VERBOSE
& VERBOSE_API
)
53 _mesa_debug(ctx
, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode
));
55 if (mode
!= GL_FLAT
&& mode
!= GL_SMOOTH
) {
56 _mesa_error( ctx
, GL_INVALID_ENUM
, "glShadeModel" );
60 if (ctx
->Light
.ShadeModel
== mode
)
63 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
64 ctx
->Light
.ShadeModel
= mode
;
65 ctx
->_TriangleCaps
^= DD_FLATSHADE
;
66 if (ctx
->Driver
.ShadeModel
)
67 (*ctx
->Driver
.ShadeModel
)( ctx
, mode
);
73 _mesa_Lightf( GLenum light
, GLenum pname
, GLfloat param
)
75 _mesa_Lightfv( light
, pname
, ¶m
);
80 _mesa_Lightfv( GLenum light
, GLenum pname
, const GLfloat
*params
)
82 GET_CURRENT_CONTEXT(ctx
);
83 GLint i
= (GLint
) (light
- GL_LIGHT0
);
84 struct gl_light
*l
= &ctx
->Light
.Light
[i
];
86 if (i
< 0 || i
>= (GLint
) ctx
->Const
.MaxLights
) {
87 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLight(light=0x%x)", light
);
93 if (TEST_EQ_4V(l
->Ambient
, params
))
95 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
96 COPY_4V( l
->Ambient
, params
);
99 if (TEST_EQ_4V(l
->Diffuse
, params
))
101 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
102 COPY_4V( l
->Diffuse
, params
);
105 if (TEST_EQ_4V(l
->Specular
, params
))
107 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
108 COPY_4V( l
->Specular
, params
);
112 /* transform position by ModelView matrix */
113 TRANSFORM_POINT( tmp
, ctx
->ModelviewMatrixStack
.Top
->m
, params
);
114 if (TEST_EQ_4V(l
->EyePosition
, tmp
))
116 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
117 COPY_4V(l
->EyePosition
, tmp
);
118 if (l
->EyePosition
[3] != 0.0F
)
119 l
->_Flags
|= LIGHT_POSITIONAL
;
121 l
->_Flags
&= ~LIGHT_POSITIONAL
;
124 case GL_SPOT_DIRECTION
: {
126 /* transform direction by inverse modelview */
127 if (ctx
->ModelviewMatrixStack
.Top
->flags
& MAT_DIRTY_INVERSE
) {
128 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
130 TRANSFORM_NORMAL( tmp
, params
, ctx
->ModelviewMatrixStack
.Top
->inv
);
131 if (TEST_EQ_3V(l
->EyeDirection
, tmp
))
133 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
134 COPY_3V(l
->EyeDirection
, tmp
);
137 case GL_SPOT_EXPONENT
:
138 if (params
[0]<0.0 || params
[0]>ctx
->Const
.MaxSpotExponent
) {
139 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
142 if (l
->SpotExponent
== params
[0])
144 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
145 l
->SpotExponent
= params
[0];
146 _mesa_invalidate_spot_exp_table( l
);
149 if ((params
[0]<0.0 || params
[0]>90.0) && params
[0]!=180.0) {
150 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
153 if (l
->SpotCutoff
== params
[0])
155 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
156 l
->SpotCutoff
= params
[0];
157 l
->_CosCutoff
= (GLfloat
) _mesa_cos(params
[0]*DEG2RAD
);
158 if (l
->_CosCutoff
< 0)
160 if (l
->SpotCutoff
!= 180.0F
)
161 l
->_Flags
|= LIGHT_SPOT
;
163 l
->_Flags
&= ~LIGHT_SPOT
;
165 case GL_CONSTANT_ATTENUATION
:
167 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
170 if (l
->ConstantAttenuation
== params
[0])
172 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
173 l
->ConstantAttenuation
= params
[0];
175 case GL_LINEAR_ATTENUATION
:
177 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
180 if (l
->LinearAttenuation
== params
[0])
182 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
183 l
->LinearAttenuation
= params
[0];
185 case GL_QUADRATIC_ATTENUATION
:
187 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLight" );
190 if (l
->QuadraticAttenuation
== params
[0])
192 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
193 l
->QuadraticAttenuation
= params
[0];
196 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLight(pname=0x%x)", pname
);
200 if (ctx
->Driver
.Lightfv
)
201 ctx
->Driver
.Lightfv( ctx
, light
, pname
, params
);
206 _mesa_Lighti( GLenum light
, GLenum pname
, GLint param
)
208 _mesa_Lightiv( light
, pname
, ¶m
);
213 _mesa_Lightiv( GLenum light
, GLenum pname
, const GLint
*params
)
221 fparam
[0] = INT_TO_FLOAT( params
[0] );
222 fparam
[1] = INT_TO_FLOAT( params
[1] );
223 fparam
[2] = INT_TO_FLOAT( params
[2] );
224 fparam
[3] = INT_TO_FLOAT( params
[3] );
227 fparam
[0] = (GLfloat
) params
[0];
228 fparam
[1] = (GLfloat
) params
[1];
229 fparam
[2] = (GLfloat
) params
[2];
230 fparam
[3] = (GLfloat
) params
[3];
232 case GL_SPOT_DIRECTION
:
233 fparam
[0] = (GLfloat
) params
[0];
234 fparam
[1] = (GLfloat
) params
[1];
235 fparam
[2] = (GLfloat
) params
[2];
237 case GL_SPOT_EXPONENT
:
239 case GL_CONSTANT_ATTENUATION
:
240 case GL_LINEAR_ATTENUATION
:
241 case GL_QUADRATIC_ATTENUATION
:
242 fparam
[0] = (GLfloat
) params
[0];
245 /* error will be caught later in gl_Lightfv */
249 _mesa_Lightfv( light
, pname
, fparam
);
255 _mesa_GetLightfv( GLenum light
, GLenum pname
, GLfloat
*params
)
257 GET_CURRENT_CONTEXT(ctx
);
258 GLint l
= (GLint
) (light
- GL_LIGHT0
);
259 ASSERT_OUTSIDE_BEGIN_END(ctx
);
261 if (l
< 0 || l
>= (GLint
) ctx
->Const
.MaxLights
) {
262 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightfv" );
268 COPY_4V( params
, ctx
->Light
.Light
[l
].Ambient
);
271 COPY_4V( params
, ctx
->Light
.Light
[l
].Diffuse
);
274 COPY_4V( params
, ctx
->Light
.Light
[l
].Specular
);
277 COPY_4V( params
, ctx
->Light
.Light
[l
].EyePosition
);
279 case GL_SPOT_DIRECTION
:
280 COPY_3V( params
, ctx
->Light
.Light
[l
].EyeDirection
);
282 case GL_SPOT_EXPONENT
:
283 params
[0] = ctx
->Light
.Light
[l
].SpotExponent
;
286 params
[0] = ctx
->Light
.Light
[l
].SpotCutoff
;
288 case GL_CONSTANT_ATTENUATION
:
289 params
[0] = ctx
->Light
.Light
[l
].ConstantAttenuation
;
291 case GL_LINEAR_ATTENUATION
:
292 params
[0] = ctx
->Light
.Light
[l
].LinearAttenuation
;
294 case GL_QUADRATIC_ATTENUATION
:
295 params
[0] = ctx
->Light
.Light
[l
].QuadraticAttenuation
;
298 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightfv" );
306 _mesa_GetLightiv( GLenum light
, GLenum pname
, GLint
*params
)
308 GET_CURRENT_CONTEXT(ctx
);
309 GLint l
= (GLint
) (light
- GL_LIGHT0
);
310 ASSERT_OUTSIDE_BEGIN_END(ctx
);
312 if (l
< 0 || l
>= (GLint
) ctx
->Const
.MaxLights
) {
313 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightiv" );
319 params
[0] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[0]);
320 params
[1] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[1]);
321 params
[2] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[2]);
322 params
[3] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Ambient
[3]);
325 params
[0] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[0]);
326 params
[1] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[1]);
327 params
[2] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[2]);
328 params
[3] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Diffuse
[3]);
331 params
[0] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[0]);
332 params
[1] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[1]);
333 params
[2] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[2]);
334 params
[3] = FLOAT_TO_INT(ctx
->Light
.Light
[l
].Specular
[3]);
337 params
[0] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[0];
338 params
[1] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[1];
339 params
[2] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[2];
340 params
[3] = (GLint
) ctx
->Light
.Light
[l
].EyePosition
[3];
342 case GL_SPOT_DIRECTION
:
343 params
[0] = (GLint
) ctx
->Light
.Light
[l
].EyeDirection
[0];
344 params
[1] = (GLint
) ctx
->Light
.Light
[l
].EyeDirection
[1];
345 params
[2] = (GLint
) ctx
->Light
.Light
[l
].EyeDirection
[2];
347 case GL_SPOT_EXPONENT
:
348 params
[0] = (GLint
) ctx
->Light
.Light
[l
].SpotExponent
;
351 params
[0] = (GLint
) ctx
->Light
.Light
[l
].SpotCutoff
;
353 case GL_CONSTANT_ATTENUATION
:
354 params
[0] = (GLint
) ctx
->Light
.Light
[l
].ConstantAttenuation
;
356 case GL_LINEAR_ATTENUATION
:
357 params
[0] = (GLint
) ctx
->Light
.Light
[l
].LinearAttenuation
;
359 case GL_QUADRATIC_ATTENUATION
:
360 params
[0] = (GLint
) ctx
->Light
.Light
[l
].QuadraticAttenuation
;
363 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetLightiv" );
370 /**********************************************************************/
371 /*** Light Model ***/
372 /**********************************************************************/
376 _mesa_LightModelfv( GLenum pname
, const GLfloat
*params
)
380 GET_CURRENT_CONTEXT(ctx
);
381 ASSERT_OUTSIDE_BEGIN_END(ctx
);
384 case GL_LIGHT_MODEL_AMBIENT
:
385 if (TEST_EQ_4V( ctx
->Light
.Model
.Ambient
, params
))
387 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
388 COPY_4V( ctx
->Light
.Model
.Ambient
, params
);
390 case GL_LIGHT_MODEL_LOCAL_VIEWER
:
391 newbool
= (params
[0]!=0.0);
392 if (ctx
->Light
.Model
.LocalViewer
== newbool
)
394 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
395 ctx
->Light
.Model
.LocalViewer
= newbool
;
397 case GL_LIGHT_MODEL_TWO_SIDE
:
398 newbool
= (params
[0]!=0.0);
399 if (ctx
->Light
.Model
.TwoSide
== newbool
)
401 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
402 ctx
->Light
.Model
.TwoSide
= newbool
;
404 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
405 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
407 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
409 case GL_LIGHT_MODEL_COLOR_CONTROL
:
410 if (params
[0] == (GLfloat
) GL_SINGLE_COLOR
)
411 newenum
= GL_SINGLE_COLOR
;
412 else if (params
[0] == (GLfloat
) GL_SEPARATE_SPECULAR_COLOR
)
413 newenum
= GL_SEPARATE_SPECULAR_COLOR
;
415 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLightModel(param=0x0%x)",
419 if (ctx
->Light
.Model
.ColorControl
== newenum
)
421 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
422 ctx
->Light
.Model
.ColorControl
= newenum
;
424 if ((ctx
->Light
.Enabled
&&
425 ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
)
426 || ctx
->Fog
.ColorSumEnabled
)
427 ctx
->_TriangleCaps
|= DD_SEPARATE_SPECULAR
;
429 ctx
->_TriangleCaps
&= ~DD_SEPARATE_SPECULAR
;
433 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLightModel(pname=0x%x)", pname
);
437 if (ctx
->Driver
.LightModelfv
)
438 ctx
->Driver
.LightModelfv( ctx
, pname
, params
);
443 _mesa_LightModeliv( GLenum pname
, const GLint
*params
)
448 case GL_LIGHT_MODEL_AMBIENT
:
449 fparam
[0] = INT_TO_FLOAT( params
[0] );
450 fparam
[1] = INT_TO_FLOAT( params
[1] );
451 fparam
[2] = INT_TO_FLOAT( params
[2] );
452 fparam
[3] = INT_TO_FLOAT( params
[3] );
454 case GL_LIGHT_MODEL_LOCAL_VIEWER
:
455 case GL_LIGHT_MODEL_TWO_SIDE
:
456 case GL_LIGHT_MODEL_COLOR_CONTROL
:
457 fparam
[0] = (GLfloat
) params
[0];
460 /* Error will be caught later in gl_LightModelfv */
463 _mesa_LightModelfv( pname
, fparam
);
468 _mesa_LightModeli( GLenum pname
, GLint param
)
470 _mesa_LightModeliv( pname
, ¶m
);
475 _mesa_LightModelf( GLenum pname
, GLfloat param
)
477 _mesa_LightModelfv( pname
, ¶m
);
482 /********** MATERIAL **********/
486 * Given a face and pname value (ala glColorMaterial), compute a bitmask
487 * of the targeted material values.
490 _mesa_material_bitmask( GLcontext
*ctx
, GLenum face
, GLenum pname
,
491 GLuint legal
, const char *where
)
495 /* Make a bitmask indicating what material attribute(s) we're updating */
498 bitmask
|= MAT_BIT_FRONT_EMISSION
| MAT_BIT_BACK_EMISSION
;
501 bitmask
|= MAT_BIT_FRONT_AMBIENT
| MAT_BIT_BACK_AMBIENT
;
504 bitmask
|= MAT_BIT_FRONT_DIFFUSE
| MAT_BIT_BACK_DIFFUSE
;
507 bitmask
|= MAT_BIT_FRONT_SPECULAR
| MAT_BIT_BACK_SPECULAR
;
510 bitmask
|= MAT_BIT_FRONT_SHININESS
| MAT_BIT_BACK_SHININESS
;
512 case GL_AMBIENT_AND_DIFFUSE
:
513 bitmask
|= MAT_BIT_FRONT_AMBIENT
| MAT_BIT_BACK_AMBIENT
;
514 bitmask
|= MAT_BIT_FRONT_DIFFUSE
| MAT_BIT_BACK_DIFFUSE
;
516 case GL_COLOR_INDEXES
:
517 bitmask
|= MAT_BIT_FRONT_INDEXES
| MAT_BIT_BACK_INDEXES
;
520 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
524 if (face
==GL_FRONT
) {
525 bitmask
&= FRONT_MATERIAL_BITS
;
527 else if (face
==GL_BACK
) {
528 bitmask
&= BACK_MATERIAL_BITS
;
530 else if (face
!= GL_FRONT_AND_BACK
) {
531 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
535 if (bitmask
& ~legal
) {
536 _mesa_error( ctx
, GL_INVALID_ENUM
, where
);
545 /* Perform a straight copy between materials.
547 void _mesa_copy_materials( struct gl_material
*dst
,
548 const struct gl_material
*src
,
553 for (i
= 0 ; i
< MAT_ATTRIB_MAX
; i
++)
554 if (bitmask
& (1<<i
))
555 COPY_4FV( dst
->Attrib
[i
], src
->Attrib
[i
] );
560 /* Update derived values following a change in ctx->Light.Material
562 void _mesa_update_material( GLcontext
*ctx
, GLuint bitmask
)
564 struct gl_light
*light
, *list
= &ctx
->Light
.EnabledList
;
565 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
567 if (MESA_VERBOSE
&VERBOSE_IMMEDIATE
)
568 _mesa_debug(ctx
, "_mesa_update_material, mask 0x%x\n", bitmask
);
573 /* update material ambience */
574 if (bitmask
& MAT_BIT_FRONT_AMBIENT
) {
575 foreach (light
, list
) {
576 SCALE_3V( light
->_MatAmbient
[0], light
->Ambient
,
577 mat
[MAT_ATTRIB_FRONT_AMBIENT
]);
581 if (bitmask
& MAT_BIT_BACK_AMBIENT
) {
582 foreach (light
, list
) {
583 SCALE_3V( light
->_MatAmbient
[1], light
->Ambient
,
584 mat
[MAT_ATTRIB_BACK_AMBIENT
]);
588 /* update BaseColor = emission + scene's ambience * material's ambience */
589 if (bitmask
& (MAT_BIT_FRONT_EMISSION
| MAT_BIT_FRONT_AMBIENT
)) {
590 COPY_3V( ctx
->Light
._BaseColor
[0], mat
[MAT_ATTRIB_FRONT_EMISSION
] );
591 ACC_SCALE_3V( ctx
->Light
._BaseColor
[0], mat
[MAT_ATTRIB_FRONT_AMBIENT
],
592 ctx
->Light
.Model
.Ambient
);
595 if (bitmask
& (MAT_BIT_BACK_EMISSION
| MAT_BIT_BACK_AMBIENT
)) {
596 COPY_3V( ctx
->Light
._BaseColor
[1], mat
[MAT_ATTRIB_BACK_EMISSION
] );
597 ACC_SCALE_3V( ctx
->Light
._BaseColor
[1], mat
[MAT_ATTRIB_BACK_AMBIENT
],
598 ctx
->Light
.Model
.Ambient
);
601 /* update material diffuse values */
602 if (bitmask
& MAT_BIT_FRONT_DIFFUSE
) {
603 foreach (light
, list
) {
604 SCALE_3V( light
->_MatDiffuse
[0], light
->Diffuse
,
605 mat
[MAT_ATTRIB_FRONT_DIFFUSE
] );
609 if (bitmask
& MAT_BIT_BACK_DIFFUSE
) {
610 foreach (light
, list
) {
611 SCALE_3V( light
->_MatDiffuse
[1], light
->Diffuse
,
612 mat
[MAT_ATTRIB_BACK_DIFFUSE
] );
616 /* update material specular values */
617 if (bitmask
& MAT_BIT_FRONT_SPECULAR
) {
618 foreach (light
, list
) {
619 SCALE_3V( light
->_MatSpecular
[0], light
->Specular
,
620 mat
[MAT_ATTRIB_FRONT_SPECULAR
]);
624 if (bitmask
& MAT_BIT_BACK_SPECULAR
) {
625 foreach (light
, list
) {
626 SCALE_3V( light
->_MatSpecular
[1], light
->Specular
,
627 mat
[MAT_ATTRIB_BACK_SPECULAR
]);
631 if (bitmask
& MAT_BIT_FRONT_SHININESS
) {
632 _mesa_invalidate_shine_table( ctx
, 0 );
635 if (bitmask
& MAT_BIT_BACK_SHININESS
) {
636 _mesa_invalidate_shine_table( ctx
, 1 );
642 * Update the current materials from the given rgba color
643 * according to the bitmask in ColorMaterialBitmask, which is
644 * set by glColorMaterial().
646 void _mesa_update_color_material( GLcontext
*ctx
,
647 const GLfloat color
[4] )
649 GLuint bitmask
= ctx
->Light
.ColorMaterialBitmask
;
650 struct gl_material
*mat
= &ctx
->Light
.Material
;
653 for (i
= 0 ; i
< MAT_ATTRIB_MAX
; i
++)
654 if (bitmask
& (1<<i
))
655 COPY_4FV( mat
->Attrib
[i
], color
);
657 _mesa_update_material( ctx
, bitmask
);
664 _mesa_ColorMaterial( GLenum face
, GLenum mode
)
666 GET_CURRENT_CONTEXT(ctx
);
668 GLuint legal
= (MAT_BIT_FRONT_EMISSION
| MAT_BIT_BACK_EMISSION
|
669 MAT_BIT_FRONT_SPECULAR
| MAT_BIT_BACK_SPECULAR
|
670 MAT_BIT_FRONT_DIFFUSE
| MAT_BIT_BACK_DIFFUSE
|
671 MAT_BIT_FRONT_AMBIENT
| MAT_BIT_BACK_AMBIENT
);
672 ASSERT_OUTSIDE_BEGIN_END(ctx
);
674 if (MESA_VERBOSE
&VERBOSE_API
)
675 _mesa_debug(ctx
, "glColorMaterial %s %s\n",
676 _mesa_lookup_enum_by_nr(face
),
677 _mesa_lookup_enum_by_nr(mode
));
679 bitmask
= _mesa_material_bitmask(ctx
, face
, mode
, legal
, "glColorMaterial");
681 if (ctx
->Light
.ColorMaterialBitmask
== bitmask
&&
682 ctx
->Light
.ColorMaterialFace
== face
&&
683 ctx
->Light
.ColorMaterialMode
== mode
)
686 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
687 ctx
->Light
.ColorMaterialBitmask
= bitmask
;
688 ctx
->Light
.ColorMaterialFace
= face
;
689 ctx
->Light
.ColorMaterialMode
= mode
;
691 if (ctx
->Light
.ColorMaterialEnabled
) {
692 FLUSH_CURRENT( ctx
, 0 );
693 _mesa_update_color_material(ctx
,ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
696 if (ctx
->Driver
.ColorMaterial
)
697 (*ctx
->Driver
.ColorMaterial
)( ctx
, face
, mode
);
705 _mesa_GetMaterialfv( GLenum face
, GLenum pname
, GLfloat
*params
)
707 GET_CURRENT_CONTEXT(ctx
);
709 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
710 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* update materials */
712 if (face
==GL_FRONT
) {
715 else if (face
==GL_BACK
) {
719 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(face)" );
725 COPY_4FV( params
, mat
[MAT_ATTRIB_AMBIENT(f
)] );
728 COPY_4FV( params
, mat
[MAT_ATTRIB_DIFFUSE(f
)] );
731 COPY_4FV( params
, mat
[MAT_ATTRIB_SPECULAR(f
)] );
734 COPY_4FV( params
, mat
[MAT_ATTRIB_EMISSION(f
)] );
737 *params
= mat
[MAT_ATTRIB_SHININESS(f
)][0];
739 case GL_COLOR_INDEXES
:
740 params
[0] = mat
[MAT_ATTRIB_INDEXES(f
)][0];
741 params
[1] = mat
[MAT_ATTRIB_INDEXES(f
)][1];
742 params
[2] = mat
[MAT_ATTRIB_INDEXES(f
)][2];
745 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(pname)" );
752 _mesa_GetMaterialiv( GLenum face
, GLenum pname
, GLint
*params
)
754 GET_CURRENT_CONTEXT(ctx
);
756 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
757 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* update materials */
759 if (face
==GL_FRONT
) {
762 else if (face
==GL_BACK
) {
766 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialiv(face)" );
771 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][0] );
772 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][1] );
773 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][2] );
774 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_AMBIENT(f
)][3] );
777 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][0] );
778 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][1] );
779 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][2] );
780 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_DIFFUSE(f
)][3] );
783 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][0] );
784 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][1] );
785 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][2] );
786 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_SPECULAR(f
)][3] );
789 params
[0] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][0] );
790 params
[1] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][1] );
791 params
[2] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][2] );
792 params
[3] = FLOAT_TO_INT( mat
[MAT_ATTRIB_EMISSION(f
)][3] );
795 *params
= IROUND( mat
[MAT_ATTRIB_SHININESS(f
)][0] );
797 case GL_COLOR_INDEXES
:
798 params
[0] = IROUND( mat
[MAT_ATTRIB_INDEXES(f
)][0] );
799 params
[1] = IROUND( mat
[MAT_ATTRIB_INDEXES(f
)][1] );
800 params
[2] = IROUND( mat
[MAT_ATTRIB_INDEXES(f
)][2] );
803 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMaterialfv(pname)" );
810 /**********************************************************************/
811 /***** Lighting computation *****/
812 /**********************************************************************/
817 * When two-sided lighting is enabled we compute the color (or index)
818 * for both the front and back side of the primitive. Then, when the
819 * orientation of the facet is later learned, we can determine which
820 * color (or index) to use for rendering.
822 * KW: We now know orientation in advance and only shade for
823 * the side or sides which are actually required.
827 * V = vertex position
828 * P = light source position
833 * // light at infinity
834 * IF local_viewer THEN
835 * _VP_inf_norm = unit vector from V to P // Precompute
838 * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
843 * Normalize( v ) = normalized vector v
844 * Magnitude( v ) = length of vector v
850 * Whenever the spotlight exponent for a light changes we must call
851 * this function to recompute the exponent lookup table.
854 _mesa_invalidate_spot_exp_table( struct gl_light
*l
)
856 l
->_SpotExpTable
[0][0] = -1;
859 static void validate_spot_exp_table( struct gl_light
*l
)
862 GLdouble exponent
= l
->SpotExponent
;
866 l
->_SpotExpTable
[0][0] = 0.0;
868 for (i
= EXP_TABLE_SIZE
- 1; i
> 0 ;i
--) {
870 tmp
= _mesa_pow(i
/ (GLdouble
) (EXP_TABLE_SIZE
- 1), exponent
);
871 if (tmp
< FLT_MIN
* 100.0) {
876 l
->_SpotExpTable
[i
][0] = (GLfloat
) tmp
;
878 for (i
= 0; i
< EXP_TABLE_SIZE
- 1; i
++) {
879 l
->_SpotExpTable
[i
][1] = (l
->_SpotExpTable
[i
+1][0] -
880 l
->_SpotExpTable
[i
][0]);
882 l
->_SpotExpTable
[EXP_TABLE_SIZE
-1][1] = 0.0;
888 /* Calculate a new shine table. Doing this here saves a branch in
889 * lighting, and the cost of doing it early may be partially offset
890 * by keeping a MRU cache of shine tables for various shine values.
893 _mesa_invalidate_shine_table( GLcontext
*ctx
, GLuint i
)
895 if (ctx
->_ShineTable
[i
])
896 ctx
->_ShineTable
[i
]->refcount
--;
897 ctx
->_ShineTable
[i
] = 0;
900 static void validate_shine_table( GLcontext
*ctx
, GLuint i
, GLfloat shininess
)
902 struct gl_shine_tab
*list
= ctx
->_ShineTabList
;
903 struct gl_shine_tab
*s
;
906 if ( s
->shininess
== shininess
)
914 if (s
->refcount
== 0)
919 if (shininess
== 0.0) {
920 for (j
= 1 ; j
<= SHINE_TABLE_SIZE
; j
++)
924 for (j
= 1 ; j
< SHINE_TABLE_SIZE
; j
++) {
925 GLdouble t
, x
= j
/ (GLfloat
) (SHINE_TABLE_SIZE
- 1);
926 if (x
< 0.005) /* underflow check */
928 t
= _mesa_pow(x
, shininess
);
934 m
[SHINE_TABLE_SIZE
] = 1.0;
937 s
->shininess
= shininess
;
940 if (ctx
->_ShineTable
[i
])
941 ctx
->_ShineTable
[i
]->refcount
--;
943 ctx
->_ShineTable
[i
] = s
;
944 move_to_tail( list
, s
);
949 _mesa_validate_all_lighting_tables( GLcontext
*ctx
)
954 shininess
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_SHININESS
][0];
955 if (!ctx
->_ShineTable
[0] || ctx
->_ShineTable
[0]->shininess
!= shininess
)
956 validate_shine_table( ctx
, 0, shininess
);
958 shininess
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_BACK_SHININESS
][0];
959 if (!ctx
->_ShineTable
[1] || ctx
->_ShineTable
[1]->shininess
!= shininess
)
960 validate_shine_table( ctx
, 1, shininess
);
962 for (i
= 0 ; i
< MAX_LIGHTS
; i
++)
963 if (ctx
->Light
.Light
[i
]._SpotExpTable
[0][0] == -1)
964 validate_spot_exp_table( &ctx
->Light
.Light
[i
] );
971 * Examine current lighting parameters to determine if the optimized lighting
972 * function can be used.
973 * Also, precompute some lighting values such as the products of light
974 * source and material ambient, diffuse and specular coefficients.
977 _mesa_update_lighting( GLcontext
*ctx
)
979 struct gl_light
*light
;
980 ctx
->Light
._NeedEyeCoords
= 0;
981 ctx
->Light
._Flags
= 0;
983 if (!ctx
->Light
.Enabled
)
986 foreach(light
, &ctx
->Light
.EnabledList
) {
987 ctx
->Light
._Flags
|= light
->_Flags
;
990 ctx
->Light
._NeedVertices
=
991 ((ctx
->Light
._Flags
& (LIGHT_POSITIONAL
|LIGHT_SPOT
)) ||
992 ctx
->Light
.Model
.ColorControl
== GL_SEPARATE_SPECULAR_COLOR
||
993 ctx
->Light
.Model
.LocalViewer
);
995 ctx
->Light
._NeedEyeCoords
= ((ctx
->Light
._Flags
& LIGHT_POSITIONAL
) ||
996 ctx
->Light
.Model
.LocalViewer
);
1000 /* XXX: This test is overkill & needs to be fixed both for software and
1001 * hardware t&l drivers. The above should be sufficient & should
1002 * be tested to verify this.
1004 if (ctx
->Light
._NeedVertices
)
1005 ctx
->Light
._NeedEyeCoords
= GL_TRUE
;
1008 /* Precompute some shading values. Although we reference
1009 * Light.Material here, we can get away without flushing
1010 * FLUSH_UPDATE_CURRENT, as when any outstanding material changes
1011 * are flushed, they will update the derived state at that time.
1013 if (ctx
->Visual
.rgbMode
) {
1014 if (ctx
->Light
.Model
.TwoSide
)
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
|
1020 MAT_BIT_BACK_EMISSION
|
1021 MAT_BIT_BACK_AMBIENT
|
1022 MAT_BIT_BACK_DIFFUSE
|
1023 MAT_BIT_BACK_SPECULAR
);
1025 _mesa_update_material( ctx
,
1026 MAT_BIT_FRONT_EMISSION
|
1027 MAT_BIT_FRONT_AMBIENT
|
1028 MAT_BIT_FRONT_DIFFUSE
|
1029 MAT_BIT_FRONT_SPECULAR
);
1032 static const GLfloat ci
[3] = { .30F
, .59F
, .11F
};
1033 foreach(light
, &ctx
->Light
.EnabledList
) {
1034 light
->_dli
= DOT3(ci
, light
->Diffuse
);
1035 light
->_sli
= DOT3(ci
, light
->Specular
);
1043 * _TNL_NEW_NEED_EYE_COORDS
1045 * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled.
1046 * Also update on lighting space changes.
1049 _mesa_compute_light_positions( GLcontext
*ctx
)
1051 struct gl_light
*light
;
1052 static const GLfloat eye_z
[3] = { 0, 0, 1 };
1054 if (!ctx
->Light
.Enabled
)
1057 if (ctx
->_NeedEyeCoords
) {
1058 COPY_3V( ctx
->_EyeZDir
, eye_z
);
1061 TRANSFORM_NORMAL( ctx
->_EyeZDir
, eye_z
, ctx
->ModelviewMatrixStack
.Top
->m
);
1064 foreach (light
, &ctx
->Light
.EnabledList
) {
1066 if (ctx
->_NeedEyeCoords
) {
1067 COPY_4FV( light
->_Position
, light
->EyePosition
);
1070 TRANSFORM_POINT( light
->_Position
, ctx
->ModelviewMatrixStack
.Top
->inv
,
1071 light
->EyePosition
);
1074 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
1075 /* VP (VP) = Normalize( Position ) */
1076 COPY_3V( light
->_VP_inf_norm
, light
->_Position
);
1077 NORMALIZE_3FV( light
->_VP_inf_norm
);
1079 if (!ctx
->Light
.Model
.LocalViewer
) {
1080 /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
1081 ADD_3V( light
->_h_inf_norm
, light
->_VP_inf_norm
, ctx
->_EyeZDir
);
1082 NORMALIZE_3FV( light
->_h_inf_norm
);
1084 light
->_VP_inf_spot_attenuation
= 1.0;
1087 if (light
->_Flags
& LIGHT_SPOT
) {
1088 if (ctx
->_NeedEyeCoords
) {
1089 COPY_3V( light
->_NormDirection
, light
->EyeDirection
);
1092 TRANSFORM_NORMAL( light
->_NormDirection
,
1093 light
->EyeDirection
,
1094 ctx
->ModelviewMatrixStack
.Top
->m
);
1097 NORMALIZE_3FV( light
->_NormDirection
);
1099 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
1100 GLfloat PV_dot_dir
= - DOT3(light
->_VP_inf_norm
,
1101 light
->_NormDirection
);
1103 if (PV_dot_dir
> light
->_CosCutoff
) {
1104 double x
= PV_dot_dir
* (EXP_TABLE_SIZE
-1);
1106 light
->_VP_inf_spot_attenuation
=
1107 (GLfloat
) (light
->_SpotExpTable
[k
][0] +
1108 (x
-k
)*light
->_SpotExpTable
[k
][1]);
1111 light
->_VP_inf_spot_attenuation
= 0;
1123 update_modelview_scale( GLcontext
*ctx
)
1125 ctx
->_ModelViewInvScale
= 1.0F
;
1126 if (ctx
->ModelviewMatrixStack
.Top
->flags
& (MAT_FLAG_UNIFORM_SCALE
|
1127 MAT_FLAG_GENERAL_SCALE
|
1128 MAT_FLAG_GENERAL_3D
|
1129 MAT_FLAG_GENERAL
) ) {
1130 const GLfloat
*m
= ctx
->ModelviewMatrixStack
.Top
->inv
;
1131 GLfloat f
= m
[2] * m
[2] + m
[6] * m
[6] + m
[10] * m
[10];
1132 if (f
< 1e-12) f
= 1.0;
1133 if (ctx
->_NeedEyeCoords
)
1134 ctx
->_ModelViewInvScale
= (GLfloat
) INV_SQRTF(f
);
1136 ctx
->_ModelViewInvScale
= (GLfloat
) SQRTF(f
);
1141 /* Bring uptodate any state that relies on _NeedEyeCoords.
1143 void _mesa_update_tnl_spaces( GLcontext
*ctx
, GLuint new_state
)
1145 const GLuint oldneedeyecoords
= ctx
->_NeedEyeCoords
;
1147 ctx
->_NeedEyeCoords
= 0;
1149 if (ctx
->_ForceEyeCoords
||
1150 (ctx
->Texture
._GenFlags
& TEXGEN_NEED_EYE_COORD
) ||
1151 ctx
->Point
._Attenuated
||
1152 ctx
->Light
._NeedEyeCoords
)
1153 ctx
->_NeedEyeCoords
= 1;
1155 if (ctx
->Light
.Enabled
&&
1156 !TEST_MAT_FLAGS( ctx
->ModelviewMatrixStack
.Top
,
1157 MAT_FLAGS_LENGTH_PRESERVING
))
1158 ctx
->_NeedEyeCoords
= 1;
1161 /* Check if the truth-value interpretations of the bitfields have
1164 if (oldneedeyecoords
!= ctx
->_NeedEyeCoords
) {
1165 /* Recalculate all state that depends on _NeedEyeCoords.
1167 update_modelview_scale(ctx
);
1168 _mesa_compute_light_positions( ctx
);
1170 if (ctx
->Driver
.LightingSpaceChange
)
1171 ctx
->Driver
.LightingSpaceChange( ctx
);
1174 GLuint new_state
= ctx
->NewState
;
1176 /* Recalculate that same state only if it has been invalidated
1177 * by other statechanges.
1179 if (new_state
& _NEW_MODELVIEW
)
1180 update_modelview_scale(ctx
);
1182 if (new_state
& (_NEW_LIGHT
|_NEW_MODELVIEW
))
1183 _mesa_compute_light_positions( ctx
);
1188 /* Drivers may need this if the hardware tnl unit doesn't support the
1189 * light-in-modelspace optimization. It's also useful for debugging.
1192 _mesa_allow_light_in_model( GLcontext
*ctx
, GLboolean flag
)
1194 ctx
->_ForceEyeCoords
= flag
;
1195 ctx
->NewState
|= _NEW_POINT
; /* one of the bits from
1196 * _MESA_NEW_NEED_EYE_COORDS.
1202 /**********************************************************************/
1203 /***** Initialization *****/
1204 /**********************************************************************/
1207 * Initialize the n-th light data structure.
1209 * \param l pointer to the gl_light structure to be initialized.
1210 * \param n number of the light.
1211 * \note The defaults for light 0 are different than the other lights.
1214 init_light( struct gl_light
*l
, GLuint n
)
1216 make_empty_list( l
);
1218 ASSIGN_4V( l
->Ambient
, 0.0, 0.0, 0.0, 1.0 );
1220 ASSIGN_4V( l
->Diffuse
, 1.0, 1.0, 1.0, 1.0 );
1221 ASSIGN_4V( l
->Specular
, 1.0, 1.0, 1.0, 1.0 );
1224 ASSIGN_4V( l
->Diffuse
, 0.0, 0.0, 0.0, 1.0 );
1225 ASSIGN_4V( l
->Specular
, 0.0, 0.0, 0.0, 1.0 );
1227 ASSIGN_4V( l
->EyePosition
, 0.0, 0.0, 1.0, 0.0 );
1228 ASSIGN_3V( l
->EyeDirection
, 0.0, 0.0, -1.0 );
1229 l
->SpotExponent
= 0.0;
1230 _mesa_invalidate_spot_exp_table( l
);
1231 l
->SpotCutoff
= 180.0;
1232 l
->_CosCutoff
= 0.0; /* KW: -ve values not admitted */
1233 l
->ConstantAttenuation
= 1.0;
1234 l
->LinearAttenuation
= 0.0;
1235 l
->QuadraticAttenuation
= 0.0;
1236 l
->Enabled
= GL_FALSE
;
1240 * Initialize the light model data structure.
1242 * \param lm pointer to the gl_lightmodel structure to be initialized.
1245 init_lightmodel( struct gl_lightmodel
*lm
)
1247 ASSIGN_4V( lm
->Ambient
, 0.2F
, 0.2F
, 0.2F
, 1.0F
);
1248 lm
->LocalViewer
= GL_FALSE
;
1249 lm
->TwoSide
= GL_FALSE
;
1250 lm
->ColorControl
= GL_SINGLE_COLOR
;
1254 * Initialize the material data structure.
1256 * \param m pointer to the gl_material structure to be initialized.
1259 init_material( struct gl_material
*m
)
1261 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_AMBIENT
], 0.2F
, 0.2F
, 0.2F
, 1.0F
);
1262 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_DIFFUSE
], 0.8F
, 0.8F
, 0.8F
, 1.0F
);
1263 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_SPECULAR
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1264 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_EMISSION
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1265 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_SHININESS
], 0.0F
, 0.0F
, 0.0F
, 0.0F
);
1266 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_FRONT_INDEXES
], 0.0F
, 1.0F
, 1.0F
, 0.0F
);
1268 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_AMBIENT
], 0.2F
, 0.2F
, 0.2F
, 1.0F
);
1269 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_DIFFUSE
], 0.8F
, 0.8F
, 0.8F
, 1.0F
);
1270 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_SPECULAR
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1271 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_EMISSION
], 0.0F
, 0.0F
, 0.0F
, 1.0F
);
1272 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_SHININESS
], 0.0F
, 0.0F
, 0.0F
, 0.0F
);
1273 ASSIGN_4V( m
->Attrib
[MAT_ATTRIB_BACK_INDEXES
], 0.0F
, 1.0F
, 1.0F
, 0.0F
);
1277 void _mesa_init_lighting( GLcontext
*ctx
)
1281 /* Lighting group */
1282 for (i
=0;i
<MAX_LIGHTS
;i
++) {
1283 init_light( &ctx
->Light
.Light
[i
], i
);
1285 make_empty_list( &ctx
->Light
.EnabledList
);
1287 init_lightmodel( &ctx
->Light
.Model
);
1288 init_material( &ctx
->Light
.Material
);
1289 ctx
->Light
.ShadeModel
= GL_SMOOTH
;
1290 ctx
->Light
.Enabled
= GL_FALSE
;
1291 ctx
->Light
.ColorMaterialFace
= GL_FRONT_AND_BACK
;
1292 ctx
->Light
.ColorMaterialMode
= GL_AMBIENT_AND_DIFFUSE
;
1293 ctx
->Light
.ColorMaterialBitmask
= _mesa_material_bitmask( ctx
,
1295 GL_AMBIENT_AND_DIFFUSE
, ~0, 0 );
1297 ctx
->Light
.ColorMaterialEnabled
= GL_FALSE
;
1299 /* Lighting miscellaneous */
1300 ctx
->_ShineTabList
= MALLOC_STRUCT( gl_shine_tab
);
1301 make_empty_list( ctx
->_ShineTabList
);
1302 for (i
= 0 ; i
< 10 ; i
++) {
1303 struct gl_shine_tab
*s
= MALLOC_STRUCT( gl_shine_tab
);
1306 insert_at_tail( ctx
->_ShineTabList
, s
);
1312 ctx
->Light
._NeedEyeCoords
= 0;
1313 ctx
->_NeedEyeCoords
= 0;
1314 ctx
->_ModelViewInvScale
= 1.0;
1318 void _mesa_free_lighting_data( GLcontext
*ctx
)
1320 struct gl_shine_tab
*s
, *tmps
;
1322 /* Free lighting shininess exponentiation table */
1323 foreach_s( s
, tmps
, ctx
->_ShineTabList
) {
1326 FREE( ctx
->_ShineTabList
);