Index: r200_state.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_state.c,v retrieving revision 1.38 diff -u -r1.38 r200_state.c --- r200_state.c 14 Sep 2005 00:42:33 -0000 1.38 +++ r200_state.c 30 Sep 2005 20:46:13 -0000 @@ -1318,8 +1398,23 @@ } } - - +static void r200UpdateLocalViewer ( GLcontext *ctx ) +{ +/* It looks like for texgen (confirmed for GL_SPHERE_MAP at least) we need + R200_LOCAL_VIEWER set. This means specular highlights may turn out wrong + in some cases when lighting is enabled but GL_LIGHT_MODEL_LOCAL_VIEWER is + not set, though it seems to happen rarely and the effect seems quite + subtle. May need TCL fallback to fix it completely, though I'm not sure + how you'd identify the cases where the specular highlights indeed will + be wrong. */ + r200ContextPtr rmesa = R200_CONTEXT(ctx); + R200_STATECHANGE( rmesa, tcl ); + if (ctx->Light.Model.LocalViewer || + ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) + rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LOCAL_VIEWER; + else + rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_LOCAL_VIEWER; +} static void r200LightModelfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) @@ -1332,11 +1427,7 @@ break; case GL_LIGHT_MODEL_LOCAL_VIEWER: - R200_STATECHANGE( rmesa, tcl ); - if (ctx->Light.Model.LocalViewer) - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LOCAL_VIEWER; - else - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_LOCAL_VIEWER; + r200UpdateLocalViewer( ctx ); break; case GL_LIGHT_MODEL_TWO_SIDE: @@ -2291,6 +2382,7 @@ if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) { r200UpdateTextureState( ctx ); new_state |= rmesa->NewGLState; /* may add TEXTURE_MATRIX */ + r200UpdateLocalViewer( ctx ); } /* Need an event driven matrix update?