summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-10-17 22:22:42 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-10-17 22:22:42 +0000
commit32c3243e4d8237ecfeccd5a554abefaa0679e94b (patch)
treeddb704d8c37962ca7337088882db3af65714dd7f /src
parentc2074645cd23e23ff86ed7f0a71845a3209f0bea (diff)
fix fog color bug
Diffstat (limited to 'src')
-rw-r--r--src/mesa/swrast/s_fog.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 1d6c4cd024..3961185824 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -110,15 +110,30 @@ void
_swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span )
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLfloat rFog = ctx->Fog.Color[RCOMP] * CHAN_MAX;
- const GLfloat gFog = ctx->Fog.Color[GCOMP] * CHAN_MAX;
- const GLfloat bFog = ctx->Fog.Color[BCOMP] * CHAN_MAX;
+ GLfloat rFog, gFog, bFog;
const GLuint haveW = (span->interpMask & SPAN_W);
ASSERT(swrast->_FogEnabled);
ASSERT((span->interpMask | span->arrayMask) & SPAN_FOG);
ASSERT(span->arrayMask & SPAN_RGBA);
+ if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ rFog = ctx->Fog.Color[RCOMP] * 255.0;
+ gFog = ctx->Fog.Color[GCOMP] * 255.0;
+ bFog = ctx->Fog.Color[BCOMP] * 255.0;
+ }
+ else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
+ rFog = ctx->Fog.Color[RCOMP] * 65535.0;
+ gFog = ctx->Fog.Color[GCOMP] * 65535.0;
+ bFog = ctx->Fog.Color[BCOMP] * 65535.0;
+ }
+ else {
+ rFog = ctx->Fog.Color[RCOMP];
+ gFog = ctx->Fog.Color[GCOMP];
+ bFog = ctx->Fog.Color[BCOMP];
+ }
+
+
/* NOTE: if haveW is true, that means the fog start/step values are
* perspective-corrected and we have to divide each fog coord by W.
*/