mirror of
https://github.com/jenshemprich/MacGLide.git
synced 2025-03-12 14:31:20 +00:00
Fixed alpha in Descent in simple car mode
This commit is contained in:
parent
23b0ee801d
commit
4e9d33a345
File diff suppressed because one or more lines are too long
@ -46,25 +46,24 @@ inline void SetChromaKeyAndAlphaState_update()
|
||||
{
|
||||
glReportErrors("SetChromaKeyAndAlpha_update");
|
||||
|
||||
// Setup alpha and chrma keying
|
||||
// Chromakeying really works for textures only, and chroma keying
|
||||
// Chromakeying works for textures only, but chroma keying
|
||||
// without textures doesn't make sense anyway.
|
||||
if(!OpenGL.Blend && OpenGL.ChromaKey && OpenGL.Texture)
|
||||
{
|
||||
#ifdef OPENGL_DEBUG
|
||||
GlideMsg("Changing Chromakeymode state to enabled\n");
|
||||
#endif
|
||||
// setup chroma keying
|
||||
const GLenum alphaTestFunction = GL_GEQUAL;
|
||||
const GLfloat alphaTestReferenceValue = 0.5;
|
||||
// setup chroma keying (and ignore Glide alpha tests)
|
||||
const GLenum alphaTestFunction = GL_GREATER;
|
||||
const GLfloat alphaTestReferenceValue = 0.0;
|
||||
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
||||
// Update only when necessary
|
||||
if (alphaTestFunction != OpenGL.AlphaTestFunction
|
||||
|| alphaTestReferenceValue != OpenGL.AlphaReferenceValue)
|
||||
{
|
||||
#endif
|
||||
OpenGL.AlphaTestFunction = alphaTestFunction;
|
||||
OpenGL.AlphaReferenceValue = alphaTestReferenceValue;
|
||||
#endif
|
||||
glAlphaFunc(alphaTestFunction, alphaTestReferenceValue);
|
||||
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
||||
}
|
||||
@ -81,8 +80,7 @@ inline void SetChromaKeyAndAlphaState_update()
|
||||
#ifdef OPENGL_DEBUG
|
||||
GlideMsg("Changing Chromakeymode state to disabled\n");
|
||||
#endif
|
||||
// Alpha Fix
|
||||
// (todo: find out why this is a fix)
|
||||
// Apply the alpha test values as requested by the glide application
|
||||
if (Glide.State.AlphaOther != GR_COMBINE_OTHER_TEXTURE)
|
||||
{
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
@ -197,18 +195,18 @@ void RenderUpdateState()
|
||||
SetChromaKeyAndAlphaState();
|
||||
}
|
||||
|
||||
if (s_bUpdateBlendState)
|
||||
{
|
||||
s_bUpdateBlendState = false;
|
||||
SetBlendState_update();
|
||||
}
|
||||
|
||||
if (s_bUpdateChromaKeyAndAlphaState)
|
||||
{
|
||||
s_bUpdateChromaKeyAndAlphaState = false;
|
||||
SetChromaKeyAndAlphaState_update();
|
||||
}
|
||||
|
||||
if (s_bUpdateBlendState)
|
||||
{
|
||||
s_bUpdateBlendState = false;
|
||||
SetBlendState_update();
|
||||
}
|
||||
|
||||
bool active_texture_unit_not_coloralpha1 = false;
|
||||
bool active_texture_unit_client_state_not_coloralpha1 = false;
|
||||
const bool useCompiledVertexArrays = InternalConfig.EXT_compiled_vertex_array;
|
||||
@ -841,20 +839,21 @@ void RenderUpdateState()
|
||||
}
|
||||
else // OpenGL.ColorAlphaTectureUnit2 == 0
|
||||
{
|
||||
if (active_texture_unit_not_coloralpha1)
|
||||
{
|
||||
glActiveTextureARB(OpenGL.ColorAlphaUnit1);
|
||||
active_texture_unit_not_coloralpha1 = false;
|
||||
if (active_texture_unit_client_state_not_coloralpha1)
|
||||
{
|
||||
glClientActiveTextureARB(OpenGL.ColorAlphaUnit1);
|
||||
active_texture_unit_client_state_not_coloralpha1 = false;
|
||||
}
|
||||
glReportError();
|
||||
}
|
||||
|
||||
if (s_bUpdateTextureState)
|
||||
{
|
||||
s_bUpdateTextureState = false;
|
||||
if (active_texture_unit_not_coloralpha1)
|
||||
{
|
||||
glActiveTextureARB(OpenGL.ColorAlphaUnit1);
|
||||
active_texture_unit_not_coloralpha1 = false;
|
||||
if (active_texture_unit_client_state_not_coloralpha1)
|
||||
{
|
||||
glClientActiveTextureARB(OpenGL.ColorAlphaUnit1);
|
||||
active_texture_unit_client_state_not_coloralpha1 = false;
|
||||
}
|
||||
glReportError();
|
||||
}
|
||||
if (OpenGL.Texture)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
@ -905,6 +904,11 @@ void RenderUpdateState()
|
||||
}
|
||||
glReportError();
|
||||
}
|
||||
|
||||
if (s_bUpdateAlphaCombineState)
|
||||
{
|
||||
s_bUpdateAlphaCombineState = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Restore state
|
||||
|
@ -99,7 +99,7 @@ grConstantColorValue4( float a, float r, float g, float b )
|
||||
// according to the linux driver src,
|
||||
// alpha is completely ignored
|
||||
// Glide.State.Delta0ModeColor[3] = a * D10255;
|
||||
// Thus, alpha is take from grConstantColorValue()
|
||||
// Thus, alpha is taken from grConstantColorValue()
|
||||
OpenGL.Delta0Color[3] = OpenGL.ConstantColor[3];
|
||||
|
||||
SetConstantColorValue4State();
|
||||
@ -323,17 +323,8 @@ grAlphaTestReferenceValue( GrAlpha_t value )
|
||||
#endif
|
||||
|
||||
RenderDrawTriangles( );
|
||||
|
||||
Glide.State.AlphaReferenceValue = value;
|
||||
OpenGL.AlphaReferenceValue = value * D1OVER255;
|
||||
// Only call if the state needs to be changed
|
||||
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
||||
// alpha reference value applies only when the following conditons are true
|
||||
if ((!OpenGL.ChromaKey || !OpenGL.Texture || OpenGL.Blend)
|
||||
&& Glide.State.AlphaOther == GR_COMBINE_OTHER_TEXTURE
|
||||
&& Glide.State.AlphaTestFunction != GR_CMP_ALWAYS)
|
||||
#endif
|
||||
SetChromaKeyAndAlphaState();
|
||||
SetChromaKeyAndAlphaState();
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
@ -349,20 +340,8 @@ grAlphaTestFunction( GrCmpFnc_t function )
|
||||
#endif
|
||||
|
||||
RenderDrawTriangles( );
|
||||
|
||||
Glide.State.AlphaTestFunction = function;
|
||||
|
||||
// We can do this just because we know the constant values for both OpenGL and Glide
|
||||
// To port it to anything else than OpenGL we NEED to change this code
|
||||
OpenGL.AlphaTestFunction = GL_NEVER + function;
|
||||
|
||||
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
||||
if ((Glide.State.AlphaOther == GR_COMBINE_OTHER_TEXTURE)
|
||||
&& (!OpenGL.ChromaKey || OpenGL.Blend || !OpenGL.Texture))
|
||||
#endif
|
||||
{
|
||||
SetChromaKeyAndAlphaState();
|
||||
}
|
||||
SetChromaKeyAndAlphaState();
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
@ -470,7 +449,7 @@ grAlphaBlendFunction( GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df,
|
||||
OpenGL.Blend = !(( rgb_sf == GR_BLEND_ONE ) && ( rgb_df == GR_BLEND_ZERO ));
|
||||
SetTextureState();
|
||||
SetBlendState();
|
||||
|
||||
|
||||
VERIFY_ACTIVE_TEXTURE_UNIT(OpenGL.ColorAlphaUnit1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user