From e267d43976101a0b43e2b5a22f90f1c92ac34b40 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 15 Jul 2019 11:12:04 +1000 Subject: [PATCH] Remove Gfx_SetAlphaTestFunc. It's not actually supported in the modern GL backend at all, and only ever set internally to discard pixels with alpha > 128. --- src/Core.h | 2 +- src/Game.c | 1 - src/Graphics.c | 22 ++++++---------------- src/Graphics.h | 4 +--- src/Logger.c | 5 +---- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/Core.h b/src/Core.h index 22a6ede1d..00c1e61dd 100644 --- a/src/Core.h +++ b/src/Core.h @@ -113,7 +113,7 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec; #define CC_BUILD_GLMODERN #define CC_BUILD_GLES #define CC_BUILD_EGL -#define CC_BUILD_LIBUNWIND +#define CC_BUILD_UNWIND #elif defined __linux__ #define CC_BUILD_LINUX #define CC_BUILD_POSIX diff --git a/src/Game.c b/src/Game.c index 55ea4e52f..63671d16a 100644 --- a/src/Game.c +++ b/src/Game.c @@ -482,7 +482,6 @@ static void Game_Load(void) { Gfx_SetDepthTestFunc(COMPARE_FUNC_LESSEQUAL); /* Gfx_SetDepthWrite(true) */ Gfx_SetAlphaBlendFunc(BLEND_FUNC_SRC_ALPHA, BLEND_FUNC_INV_SRC_ALPHA); - Gfx_SetAlphaTestFunc(COMPARE_FUNC_GREATER, 0.5f); Game_AddComponent(&PickedPosRenderer_Component); Game_AddComponent(&Audio_Component); diff --git a/src/Graphics.c b/src/Graphics.c index 47e303309..ea2d493a8 100644 --- a/src/Graphics.c +++ b/src/Graphics.c @@ -568,8 +568,6 @@ static float gfx_fogDensity = -1.0f, gfx_fogEnd = -1.0f; static D3DFOGMODE gfx_fogMode = D3DFOG_NONE; static bool gfx_alphaTesting, gfx_alphaBlending; -static int gfx_alphaTestRef; -static D3DCMPFUNC gfx_alphaTestFunc = D3DCMP_ALWAYS; static D3DBLEND gfx_srcBlendFunc = D3DBLEND_ONE, gfx_dstBlendFunc = D3DBLEND_ZERO; static PackedColUnion gfx_clearCol; @@ -633,13 +631,6 @@ void Gfx_SetAlphaTest(bool enabled) { D3D9_SetRenderState(D3DRS_ALPHATESTENABLE, enabled, "D3D9_SetAlphaTest"); } -void Gfx_SetAlphaTestFunc(CompareFunc func, float refValue) { - gfx_alphaTestFunc = d3d9_compareFuncs[func]; - D3D9_SetRenderState(D3DRS_ALPHAFUNC, gfx_alphaTestFunc, "D3D9_SetAlphaTest_Func"); - gfx_alphaTestRef = (int)(refValue * 255); - D3D9_SetRenderState2(D3DRS_ALPHAREF, gfx_alphaTestRef, "D3D9_SetAlphaTest_Ref"); -} - void Gfx_SetAlphaBlending(bool enabled) { if (gfx_alphaBlending == enabled) return; gfx_alphaBlending = enabled; @@ -674,7 +665,7 @@ void Gfx_SetDepthTest(bool enabled) { void Gfx_SetDepthTestFunc(CompareFunc func) { gfx_depthTestFunc = d3d9_compareFuncs[func]; - D3D9_SetRenderState(D3DRS_ZFUNC, gfx_alphaTestFunc, "D3D9_SetDepthTestFunc"); + D3D9_SetRenderState(D3DRS_ZFUNC, gfx_depthTestFunc, "D3D9_SetDepthTestFunc"); } void Gfx_SetDepthWrite(bool enabled) { @@ -690,14 +681,16 @@ static void D3D9_SetDefaultRenderStates(void) { D3D9_SetRenderState2(D3DRS_SPECULARENABLE, false, "D3D9_SpecularEnable"); D3D9_SetRenderState2(D3DRS_LOCALVIEWER, false, "D3D9_LocalViewer"); D3D9_SetRenderState2(D3DRS_DEBUGMONITORTOKEN, false, "D3D9_DebugMonitor"); + + /* States relevant to the game */ + D3D9_SetRenderState2(D3DRS_ALPHAFUNC, D3DCMP_GREATER, "D3D9_AlphaTestFunc"); + D3D9_SetRenderState2(D3DRS_ALPHAREF, 127, "D3D9_AlphaRefFunc"); } static void D3D9_RestoreRenderStates(void) { union IntAndFloat raw; D3D9_SetRenderState(D3DRS_ALPHATESTENABLE, gfx_alphaTesting, "D3D9_AlphaTest"); D3D9_SetRenderState2(D3DRS_ALPHABLENDENABLE, gfx_alphaBlending, "D3D9_AlphaBlend"); - D3D9_SetRenderState2(D3DRS_ALPHAFUNC, gfx_alphaTestFunc, "D3D9_AlphaTestFunc"); - D3D9_SetRenderState2(D3DRS_ALPHAREF, gfx_alphaTestRef, "D3D9_AlphaRefFunc"); D3D9_SetRenderState2(D3DRS_SRCBLEND, gfx_srcBlendFunc, "D3D9_AlphaSrcBlend"); D3D9_SetRenderState2(D3DRS_DESTBLEND, gfx_dstBlendFunc, "D3D9_AlphaDstBlend"); @@ -1629,7 +1622,6 @@ void Gfx_SetFogMode(FogFunc func) { void Gfx_SetTexturing(bool enabled) { } void Gfx_SetAlphaTest(bool enabled) { gfx_alphaTest = enabled; Gfx_SwitchProgram(); } -void Gfx_SetAlphaTestFunc(CompareFunc func, float refValue) { } void Gfx_LoadMatrix(MatrixType type, struct Matrix* matrix) { if (type == MATRIX_VIEW || type == MATRIX_PROJECTION) { @@ -1775,9 +1767,6 @@ void Gfx_SetFogMode(FogFunc func) { void Gfx_SetTexturing(bool enabled) { gl_Toggle(GL_TEXTURE_2D); } void Gfx_SetAlphaTest(bool enabled) { gl_Toggle(GL_ALPHA_TEST); } -void Gfx_SetAlphaTestFunc(CompareFunc func, float value) { - glAlphaFunc(gl_compare[func], value); -} static GLenum matrix_modes[3] = { GL_PROJECTION, GL_MODELVIEW, GL_TEXTURE }; static int lastMatrix; @@ -1796,6 +1785,7 @@ static void GL_InitState(void) { glHint(GL_FOG_HINT, GL_NICEST); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); + glAlphaFunc(GL_GREATER, 0.5f); } diff --git a/src/Graphics.h b/src/Graphics.h index b2949000a..f8719db22 100644 --- a/src/Graphics.h +++ b/src/Graphics.h @@ -91,10 +91,8 @@ CC_API void Gfx_SetFogMode(FogFunc func); /* Sets whether backface culling is performed. */ CC_API void Gfx_SetFaceCulling(bool enabled); -/* Sets whether new pixels may be discarded based on their alpha. */ +/* Sets whether pixels with an alpha of less than 128 are discarded. */ CC_API void Gfx_SetAlphaTest(bool enabled); -/* Sets in what way pixels may be discarded based on their alpha. */ -CC_API void Gfx_SetAlphaTestFunc(CompareFunc func, float refValue); /* Sets whether existing and new pixels are blended together. */ CC_API void Gfx_SetAlphaBlending(bool enabled); /* Sets in what way existing and new pixels are blended. */ diff --git a/src/Logger.c b/src/Logger.c index 626bce189..65741322e 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -20,6 +20,7 @@ #endif /* POSIX can be shared between unix-ish systems */ +/* NOTE: Android's bionic libc doesn't provide backtrace (execinfo.h) */ #ifdef CC_BUILD_POSIX #if defined CC_BUILD_OPENBSD #include @@ -35,10 +36,6 @@ #include #endif #endif -/* android's bionic libc doesn't provide backtrace */ -#ifdef CC_BUILD_ANDROID -#define CC_BUILD_UNWIND -#endif /*########################################################################################################################*