mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 10:40:11 +01:00
Fix minor fog / fragment program state bug.
Don't add diffuse and specular colors when using fragment program.
This commit is contained in:
parent
886df0926f
commit
dfe508ca7a
4 changed files with 29 additions and 26 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue