From 662fbf8a629d93ae210837fefc0765381bf0b708 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 12 Nov 2005 18:58:12 +0000 Subject: Added _mesa_light() helper function so we can avoid transforming then un-transforming light positions and spot directions when popping light state off the attribute stack. --- src/mesa/main/attrib.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src/mesa/main/attrib.c') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 9c2a666e478..b4a587efb04 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -951,25 +951,21 @@ _mesa_PopAttrib(void) _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); for (i = 0; i < ctx->Const.MaxLights; i++) { - GLenum lgt = (GLenum) (GL_LIGHT0 + i); const struct gl_light *l = &light->Light[i]; - GLfloat tmp[4]; - _mesa_set_enable(ctx, lgt, l->Enabled); - _mesa_Lightfv( lgt, GL_AMBIENT, l->Ambient ); - _mesa_Lightfv( lgt, GL_DIFFUSE, l->Diffuse ); - _mesa_Lightfv( lgt, GL_SPECULAR, l->Specular ); - TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->inv, l->EyePosition ); - _mesa_Lightfv( lgt, GL_POSITION, tmp ); - TRANSFORM_NORMAL( tmp, l->EyeDirection, ctx->ModelviewMatrixStack.Top->m ); - _mesa_Lightfv( lgt, GL_SPOT_DIRECTION, tmp ); - _mesa_Lightfv( lgt, GL_SPOT_EXPONENT, &l->SpotExponent ); - _mesa_Lightfv( lgt, GL_SPOT_CUTOFF, &l->SpotCutoff ); - _mesa_Lightfv( lgt, GL_CONSTANT_ATTENUATION, - &l->ConstantAttenuation ); - _mesa_Lightfv( lgt, GL_LINEAR_ATTENUATION, - &l->LinearAttenuation ); - _mesa_Lightfv( lgt, GL_QUADRATIC_ATTENUATION, - &l->QuadraticAttenuation ); + _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled); + _mesa_light(ctx, i, GL_AMBIENT, l->Ambient); + _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse); + _mesa_light(ctx, i, GL_SPECULAR, l->Specular ); + _mesa_light(ctx, i, GL_POSITION, l->EyePosition); + _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->EyeDirection); + _mesa_light(ctx, i, GL_SPOT_EXPONENT, &l->SpotExponent); + _mesa_light(ctx, i, GL_SPOT_CUTOFF, &l->SpotCutoff); + _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, + &l->ConstantAttenuation); + _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, + &l->LinearAttenuation); + _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, + &l->QuadraticAttenuation); } /* light model */ _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, -- cgit v1.2.3