Fixed alpha test state change inconsistencies

This commit is contained in:
Jens Hemprich 2007-08-26 20:05:31 +00:00
parent 4e9d33a345
commit 4c30564e19
2 changed files with 17 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -87,15 +87,23 @@ inline void SetChromaKeyAndAlphaState_update()
} }
else else
{ {
const GLenum alphaTestFunction = GL_NEVER + Glide.State.AlphaTestFunction;
const GLfloat alphaTestReferenceValue = Glide.State.AlphaReferenceValue * D1OVER255;
if (Glide.State.AlphaTestFunction != GR_CMP_ALWAYS) if (Glide.State.AlphaTestFunction != GR_CMP_ALWAYS)
{ {
glEnable(GL_ALPHA_TEST); #ifdef OPTIMISE_OPENGL_STATE_CHANGES
#ifndef OPTIMISE_OPENGL_STATE_CHANGES if (alphaTestFunction != OpenGL.AlphaTestFunction
// Restore previous values || alphaTestReferenceValue != OpenGL.AlphaReferenceValue)
OpenGL.AlphaTestFunction = GL_NEVER + Glide.State.AlphaTestFunction; {
OpenGL.AlphaReferenceValue = Glide.State.AlphaReferenceValue * D1OVER255;
#endif #endif
glAlphaFunc(OpenGL.AlphaTestFunction, OpenGL.AlphaReferenceValue); // Restore previous values
OpenGL.AlphaTestFunction = alphaTestFunction;
OpenGL.AlphaReferenceValue = alphaTestReferenceValue;
glAlphaFunc(alphaTestFunction, alphaTestReferenceValue);
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
}
#endif
glEnable(GL_ALPHA_TEST);
} }
else else
{ {
@ -184,7 +192,7 @@ void RenderUpdateState()
else else
{ {
#ifdef OPENGL_DEBUG #ifdef OPENGL_DEBUG
GlideMsg( "Calls to grChromakeyMode() didn't change ChromaKeyAndAlphaState\n"); GlideMsg("Calls to grChromakeyMode() didn't change ChromaKeyAndAlphaState\n");
#endif #endif
} }
@ -908,6 +916,7 @@ void RenderUpdateState()
if (s_bUpdateAlphaCombineState) if (s_bUpdateAlphaCombineState)
{ {
s_bUpdateAlphaCombineState = false; s_bUpdateAlphaCombineState = false;
// Alpha is completely ignored in simple coloralpha render mode
} }
} }
} }