Don't add diffuse and specular colors when using fragment program.
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;
+ }
}
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)
GLboolean _AnyTextureCombine;
GLchan _FogColor[3];
GLboolean _FogEnabled;
+ GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */
/* Accum buffer temporaries.
*/
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "s_span.h"
-
-
/**
* Used to convert current raster distance to a fog factor in [0,1].
*/
/* The span's fog values are fog coordinates, now compute blend factors
* and blend the fragment colors with the fog color.
*/
- switch (ctx->Fog.Mode) {
+ switch (swrast->_FogMode) {
case GL_LINEAR:
{
const GLfloat fogEnd = ctx->Fog.End;
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
ASSERT(span->arrayMask & SPAN_RGBA);
- /* Add base and specular colors */
- if (ctx->Fog.ColorSumEnabled ||
- (ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) {
- if (span->interpMask & SPAN_SPEC) {
- interpolate_specular(ctx, span);
+ if (!ctx->FragmentProgram._Enabled) {
+ /* Add base and specular colors */
+ if (ctx->Fog.ColorSumEnabled ||
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) {
+ if (span->interpMask & SPAN_SPEC) {
+ interpolate_specular(ctx, span);
+ }
+ ASSERT(span->arrayMask & SPAN_SPEC);
+ add_colors( span->end, span->array->rgba, span->array->spec );
}
- ASSERT(span->arrayMask & SPAN_SPEC);
- add_colors( span->end, span->array->rgba, span->array->spec );
}
/* Fog */