summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-10-13 15:54:48 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-10-13 15:54:48 +0000
commitdfe508ca7af1a6d1099cd65e257512ed1e17d893 (patch)
tree1393d22cefdabb68c1b35bb24c108edd76b8abf9
parent886df0926fe6b3d8f82cff62747abfdb95540aa0 (diff)
Fix minor fog / fragment program state bug.
Don't add diffuse and specular colors when using fragment program.
-rw-r--r--src/mesa/swrast/s_context.c25
-rw-r--r--src/mesa/swrast/s_context.h1
-rw-r--r--src/mesa/swrast/s_fog.c9
-rw-r--r--src/mesa/swrast/s_span.c20
4 files changed, 29 insertions, 26 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 87d4bf8cdf..e9755e9199 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -196,19 +196,22 @@ _swrast_update_fog_state( GLcontext *ctx )
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;
+ }
}
@@ -480,7 +483,7 @@ _swrast_validate_derived( GLcontext *ctx )
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)
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index ea877a4bd2..aba32755d1 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -286,6 +286,7 @@ typedef struct
GLboolean _AnyTextureCombine;
GLchan _FogColor[3];
GLboolean _FogEnabled;
+ GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */
/* Accum buffer temporaries.
*/
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 89ed1152b2..613759d1c1 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -1,9 +1,8 @@
-
/*
* 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"),
@@ -34,8 +33,6 @@
#include "s_span.h"
-
-
/**
* Used to convert current raster distance to a fog factor in [0,1].
*/
@@ -99,7 +96,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
/* 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;
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index c4a86f141c..247c7ee688 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -1473,15 +1473,17 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
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 */