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");
|
glReportErrors("SetChromaKeyAndAlpha_update");
|
||||||
|
|
||||||
// Setup alpha and chrma keying
|
// Chromakeying works for textures only, but chroma keying
|
||||||
// Chromakeying really works for textures only, and chroma keying
|
|
||||||
// without textures doesn't make sense anyway.
|
// without textures doesn't make sense anyway.
|
||||||
if(!OpenGL.Blend && OpenGL.ChromaKey && OpenGL.Texture)
|
if(!OpenGL.Blend && OpenGL.ChromaKey && OpenGL.Texture)
|
||||||
{
|
{
|
||||||
#ifdef OPENGL_DEBUG
|
#ifdef OPENGL_DEBUG
|
||||||
GlideMsg("Changing Chromakeymode state to enabled\n");
|
GlideMsg("Changing Chromakeymode state to enabled\n");
|
||||||
#endif
|
#endif
|
||||||
// setup chroma keying
|
// setup chroma keying (and ignore Glide alpha tests)
|
||||||
const GLenum alphaTestFunction = GL_GEQUAL;
|
const GLenum alphaTestFunction = GL_GREATER;
|
||||||
const GLfloat alphaTestReferenceValue = 0.5;
|
const GLfloat alphaTestReferenceValue = 0.0;
|
||||||
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
||||||
// Update only when necessary
|
// Update only when necessary
|
||||||
if (alphaTestFunction != OpenGL.AlphaTestFunction
|
if (alphaTestFunction != OpenGL.AlphaTestFunction
|
||||||
|| alphaTestReferenceValue != OpenGL.AlphaReferenceValue)
|
|| alphaTestReferenceValue != OpenGL.AlphaReferenceValue)
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
OpenGL.AlphaTestFunction = alphaTestFunction;
|
OpenGL.AlphaTestFunction = alphaTestFunction;
|
||||||
OpenGL.AlphaReferenceValue = alphaTestReferenceValue;
|
OpenGL.AlphaReferenceValue = alphaTestReferenceValue;
|
||||||
#endif
|
|
||||||
glAlphaFunc(alphaTestFunction, alphaTestReferenceValue);
|
glAlphaFunc(alphaTestFunction, alphaTestReferenceValue);
|
||||||
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
#ifdef OPTIMISE_OPENGL_STATE_CHANGES
|
||||||
}
|
}
|
||||||
|
@ -81,8 +80,7 @@ inline void SetChromaKeyAndAlphaState_update()
|
||||||
#ifdef OPENGL_DEBUG
|
#ifdef OPENGL_DEBUG
|
||||||
GlideMsg("Changing Chromakeymode state to disabled\n");
|
GlideMsg("Changing Chromakeymode state to disabled\n");
|
||||||
#endif
|
#endif
|
||||||
// Alpha Fix
|
// Apply the alpha test values as requested by the glide application
|
||||||
// (todo: find out why this is a fix)
|
|
||||||
if (Glide.State.AlphaOther != GR_COMBINE_OTHER_TEXTURE)
|
if (Glide.State.AlphaOther != GR_COMBINE_OTHER_TEXTURE)
|
||||||
{
|
{
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
@ -197,18 +195,18 @@ void RenderUpdateState()
|
||||||
SetChromaKeyAndAlphaState();
|
SetChromaKeyAndAlphaState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bUpdateBlendState)
|
|
||||||
{
|
|
||||||
s_bUpdateBlendState = false;
|
|
||||||
SetBlendState_update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s_bUpdateChromaKeyAndAlphaState)
|
if (s_bUpdateChromaKeyAndAlphaState)
|
||||||
{
|
{
|
||||||
s_bUpdateChromaKeyAndAlphaState = false;
|
s_bUpdateChromaKeyAndAlphaState = false;
|
||||||
SetChromaKeyAndAlphaState_update();
|
SetChromaKeyAndAlphaState_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s_bUpdateBlendState)
|
||||||
|
{
|
||||||
|
s_bUpdateBlendState = false;
|
||||||
|
SetBlendState_update();
|
||||||
|
}
|
||||||
|
|
||||||
bool active_texture_unit_not_coloralpha1 = false;
|
bool active_texture_unit_not_coloralpha1 = false;
|
||||||
bool active_texture_unit_client_state_not_coloralpha1 = false;
|
bool active_texture_unit_client_state_not_coloralpha1 = false;
|
||||||
const bool useCompiledVertexArrays = InternalConfig.EXT_compiled_vertex_array;
|
const bool useCompiledVertexArrays = InternalConfig.EXT_compiled_vertex_array;
|
||||||
|
@ -841,20 +839,21 @@ void RenderUpdateState()
|
||||||
}
|
}
|
||||||
else // OpenGL.ColorAlphaTectureUnit2 == 0
|
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)
|
if (s_bUpdateTextureState)
|
||||||
{
|
{
|
||||||
s_bUpdateTextureState = false;
|
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)
|
if (OpenGL.Texture)
|
||||||
{
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
@ -905,6 +904,11 @@ void RenderUpdateState()
|
||||||
}
|
}
|
||||||
glReportError();
|
glReportError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s_bUpdateAlphaCombineState)
|
||||||
|
{
|
||||||
|
s_bUpdateAlphaCombineState = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Restore state
|
// Restore state
|
||||||
|
|
|
@ -99,7 +99,7 @@ grConstantColorValue4( float a, float r, float g, float b )
|
||||||
// according to the linux driver src,
|
// according to the linux driver src,
|
||||||
// alpha is completely ignored
|
// alpha is completely ignored
|
||||||
// Glide.State.Delta0ModeColor[3] = a * D10255;
|
// Glide.State.Delta0ModeColor[3] = a * D10255;
|
||||||
// Thus, alpha is take from grConstantColorValue()
|
// Thus, alpha is taken from grConstantColorValue()
|
||||||
OpenGL.Delta0Color[3] = OpenGL.ConstantColor[3];
|
OpenGL.Delta0Color[3] = OpenGL.ConstantColor[3];
|
||||||
|
|
||||||
SetConstantColorValue4State();
|
SetConstantColorValue4State();
|
||||||
|
@ -323,17 +323,8 @@ grAlphaTestReferenceValue( GrAlpha_t value )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RenderDrawTriangles( );
|
RenderDrawTriangles( );
|
||||||
|
|
||||||
Glide.State.AlphaReferenceValue = value;
|
Glide.State.AlphaReferenceValue = value;
|
||||||
OpenGL.AlphaReferenceValue = value * D1OVER255;
|
SetChromaKeyAndAlphaState();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -349,20 +340,8 @@ grAlphaTestFunction( GrCmpFnc_t function )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RenderDrawTriangles( );
|
RenderDrawTriangles( );
|
||||||
|
|
||||||
Glide.State.AlphaTestFunction = function;
|
Glide.State.AlphaTestFunction = function;
|
||||||
|
SetChromaKeyAndAlphaState();
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************
|
//*************************************************
|
||||||
|
@ -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 ));
|
OpenGL.Blend = !(( rgb_sf == GR_BLEND_ONE ) && ( rgb_df == GR_BLEND_ZERO ));
|
||||||
SetTextureState();
|
SetTextureState();
|
||||||
SetBlendState();
|
SetBlendState();
|
||||||
|
|
||||||
VERIFY_ACTIVE_TEXTURE_UNIT(OpenGL.ColorAlphaUnit1);
|
VERIFY_ACTIVE_TEXTURE_UNIT(OpenGL.ColorAlphaUnit1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue