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);
/**************************** 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? */
}
/************************************************************************/
fxSetupDepthTest(ctx);
if (newstate & FX_NEW_FOG)
- fxSetupFog(ctx,GL_FALSE);
+ fxSetupFog(ctx);
if (newstate & FX_NEW_SCISSOR)
fxSetupScissor(ctx);