summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2000-02-16 23:15:01 +0000
committerBrian Paul <[email protected]>2000-02-16 23:15:01 +0000
commit5bd2987840567047f19cc2dad6fc5f3fb84345fc (patch)
tree15be7a59293166ac3bc6e8a72af65ca1d6ee0cea
parent7a0f9dbb94947110ed47c3ba4befc2d9ffb1e8c8 (diff)
update fog near/far bug fix
-rw-r--r--src/mesa/drivers/glide/fxdrv.h1
-rw-r--r--src/mesa/drivers/glide/fxsetup.c83
2 files changed, 37 insertions, 47 deletions
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index 208801e87b4..1c6e3f0639b 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -478,6 +478,7 @@ struct tfxMesaContext {
GLenum fogTableMode;
GLfloat fogDensity;
+ GLfloat fogStart, fogEnd;
GrFog_t *fogTable;
/* Acc. functions */
diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c
index 6ebd037fd57..8707aed1d0a 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;i<FX_grGetInteger(FX_FOG_TABLE_ENTRIES);i++) {
- eyez=guFogTableIndexToW(i);
-
- switch(ctx->Fog.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);