mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 01:50:10 +01:00
update fog near/far bug fix
This commit is contained in:
parent
7a0f9dbb94
commit
5bd2987840
2 changed files with 37 additions and 47 deletions
|
|
@ -478,6 +478,7 @@ struct tfxMesaContext {
|
|||
|
||||
GLenum fogTableMode;
|
||||
GLfloat fogDensity;
|
||||
GLfloat fogStart, fogEnd;
|
||||
GrFog_t *fogTable;
|
||||
|
||||
/* Acc. functions */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
if (ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT) {
|
||||
fxMesaContext fxMesa = FX_CONTEXT(ctx);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue