From 5bd2987840567047f19cc2dad6fc5f3fb84345fc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 16 Feb 2000 23:15:01 +0000 Subject: update fog near/far bug fix --- src/mesa/drivers/glide/fxsetup.c | 83 +++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 47 deletions(-) (limited to 'src/mesa/drivers/glide/fxsetup.c') diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index 6ebd037fd5..8707aed1d0 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -66,8 +66,6 @@ static void fxSetupTexture_NoLock(GLcontext *ctx); static void fxSetupTexture(GLcontext *ctx); static void fxSetupBlend(GLcontext *ctx); static void fxSetupDepthTest(GLcontext *ctx); -static void fxFogTableGenerate(GLcontext *ctx); -static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild); static void fxSetupScissor(GLcontext *ctx); static void fxSetupCull(GLcontext *ctx); static void gl_print_fx_state_flags( const char *msg, GLuint flags); @@ -1424,67 +1422,58 @@ static void fxSetupColorMask(GLcontext *ctx) /**************************** Fog Mode SetUp ****************************/ /************************************************************************/ -static void fxFogTableGenerate(GLcontext *ctx) +/* + * This is called during state update in order to update the Glide fog state. + */ +static void fxSetupFog(GLcontext *ctx) { - int i; - float f,eyez; - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - - for(i=0;iFog.Mode) { - case GL_LINEAR: - f=(ctx->Fog.End-eyez)/(ctx->Fog.End-ctx->Fog.Start); - break; - case GL_EXP: - f=exp(-ctx->Fog.Density*eyez); - break; - case GL_EXP2: - f=exp(-ctx->Fog.Density*ctx->Fog.Density*eyez*eyez); - break; - default: /* That should never happen */ - f=0.0f; - break; - } + if (ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT) { + fxMesaContext fxMesa = FX_CONTEXT(ctx); - fxMesa->fogTable[i]=(GrFog_t)((1.0f-CLAMP(f,0.0f,1.0f))*255.0f); - } -} - -static void fxSetupFog(GLcontext *ctx, GLboolean forceTableRebuild) -{ - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - - if(ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT) { + /* update fog color */ GLubyte col[4]; - FX_grFogMode(GR_FOG_WITH_TABLE); - col[0]=(unsigned int)(255*ctx->Fog.Color[0]); col[1]=(unsigned int)(255*ctx->Fog.Color[1]); col[2]=(unsigned int)(255*ctx->Fog.Color[2]); col[3]=(unsigned int)(255*ctx->Fog.Color[3]); - FX_grFogColorValue(FXCOLOR4(col)); - if(forceTableRebuild || - (fxMesa->fogTableMode!=ctx->Fog.Mode) || - (fxMesa->fogDensity!=ctx->Fog.Density)) { - fxFogTableGenerate(ctx); - - fxMesa->fogTableMode=ctx->Fog.Mode; - fxMesa->fogDensity=ctx->Fog.Density; + if(fxMesa->fogTableMode != ctx->Fog.Mode || + fxMesa->fogDensity != ctx->Fog.Density || + fxMesa->fogStart != ctx->Fog.Start || + fxMesa->fogEnd != ctx->Fog.End) { + /* reload the fog table */ + switch (ctx->Fog.Mode) { + case GL_LINEAR: + guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start, ctx->Fog.End); + break; + case GL_EXP: + guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density); + break; + case GL_EXP2: + guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density); + break; + default: + ; + } + fxMesa->fogTableMode = ctx->Fog.Mode; + fxMesa->fogDensity = ctx->Fog.Density; + fxMesa->fogStart = ctx->Fog.Start; + fxMesa->fogEnd = ctx->Fog.End; } - + FX_grFogTable(fxMesa->fogTable); - } else + FX_grFogMode(GR_FOG_WITH_TABLE); + } + else { FX_grFogMode(GR_FOG_DISABLE); + } } void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) { FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG; - ctx->Driver.RenderStart = fxSetupFXUnits; + ctx->Driver.RenderStart = fxSetupFXUnits; /* XXX why is this here? */ } /************************************************************************/ @@ -1823,7 +1812,7 @@ void fxSetupFXUnits( GLcontext *ctx ) fxSetupDepthTest(ctx); if (newstate & FX_NEW_FOG) - fxSetupFog(ctx,GL_FALSE); + fxSetupFog(ctx); if (newstate & FX_NEW_SCISSOR) fxSetupScissor(ctx); -- cgit v1.2.3