From dfe508ca7af1a6d1099cd65e257512ed1e17d893 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 13 Oct 2004 15:54:48 +0000 Subject: Fix minor fog / fragment program state bug. Don't add diffuse and specular colors when using fragment program. --- src/mesa/swrast/s_context.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/mesa/swrast/s_context.c') diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 87d4bf8cdf3..e9755e91997 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -196,19 +196,22 @@ _swrast_update_fog_state( GLcontext *ctx ) CLAMPED_FLOAT_TO_CHAN(swrast->_FogColor[GCOMP], ctx->Fog.Color[GCOMP]); CLAMPED_FLOAT_TO_CHAN(swrast->_FogColor[BCOMP], ctx->Fog.Color[BCOMP]); - /* determine if fog is needed */ + /* determine if fog is needed, and if so, which fog mode */ swrast->_FogEnabled = GL_FALSE; - if (ctx->Fog.Enabled) { - swrast->_FogEnabled = GL_TRUE; - } - else if (ctx->FragmentProgram._Enabled && - ctx->FragmentProgram.Current->Base.Target == GL_FRAGMENT_PROGRAM_ARB) { - const struct fragment_program *p; - p = (struct fragment_program *) ctx->FragmentProgram.Current; - if (p->FogOption != GL_NONE) { - swrast->_FogEnabled = GL_TRUE; + if (ctx->FragmentProgram._Enabled) { + if (ctx->FragmentProgram.Current->Base.Target==GL_FRAGMENT_PROGRAM_ARB) { + const struct fragment_program *p + = (struct fragment_program *) ctx->FragmentProgram.Current; + if (p->FogOption != GL_NONE) { + swrast->_FogEnabled = GL_TRUE; + swrast->_FogMode = p->FogOption; + } } } + else if (ctx->Fog.Enabled) { + swrast->_FogEnabled = GL_TRUE; + swrast->_FogMode = ctx->Fog.Mode; + } } @@ -480,7 +483,7 @@ _swrast_validate_derived( GLcontext *ctx ) if (swrast->NewState & _SWRAST_NEW_TEXTURE_ENV_MODE) _swrast_update_texture_env( ctx ); - if (swrast->NewState & _NEW_FOG) + if (swrast->NewState & (_NEW_FOG | _NEW_PROGRAM)) _swrast_update_fog_state( ctx ); if (swrast->NewState & _NEW_PROGRAM) -- cgit v1.2.3