mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Fix gui being rendered with solid background after restoring from lost opengl context
This commit is contained in:
parent
d050126868
commit
f819e49aaa
@ -477,7 +477,6 @@ static void Game_Load(void) {
|
|||||||
Gfx_SetDepthTest(true);
|
Gfx_SetDepthTest(true);
|
||||||
Gfx_SetDepthTestFunc(COMPARE_FUNC_LESSEQUAL);
|
Gfx_SetDepthTestFunc(COMPARE_FUNC_LESSEQUAL);
|
||||||
/* Gfx_SetDepthWrite(true) */
|
/* Gfx_SetDepthWrite(true) */
|
||||||
Gfx_SetAlphaBlendFunc(BLEND_FUNC_SRC_ALPHA, BLEND_FUNC_INV_SRC_ALPHA);
|
|
||||||
|
|
||||||
Game_AddComponent(&PickedPosRenderer_Component);
|
Game_AddComponent(&PickedPosRenderer_Component);
|
||||||
Game_AddComponent(&Audio_Component);
|
Game_AddComponent(&Audio_Component);
|
||||||
|
@ -41,6 +41,9 @@ CC_NOINLINE static void Gfx_RestoreState(void);
|
|||||||
/* Destroys render state, but can be restored later. */
|
/* Destroys render state, but can be restored later. */
|
||||||
CC_NOINLINE static void Gfx_FreeState(void);
|
CC_NOINLINE static void Gfx_FreeState(void);
|
||||||
|
|
||||||
|
static PackedCol gfx_clearCol, gfx_fogCol;
|
||||||
|
static float gfx_fogEnd = -1.0f, gfx_fogDensity = -1.0f;
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Generic/Common-----------------------------------------------------*
|
*------------------------------------------------------Generic/Common-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -428,6 +431,8 @@ static void Gfx_RestoreState(void) {
|
|||||||
/* States relevant to the game */
|
/* States relevant to the game */
|
||||||
D3D9_SetRenderState2(D3DRS_ALPHAFUNC, D3DCMP_GREATER, "D3D9_AlphaTestFunc");
|
D3D9_SetRenderState2(D3DRS_ALPHAFUNC, D3DCMP_GREATER, "D3D9_AlphaTestFunc");
|
||||||
D3D9_SetRenderState2(D3DRS_ALPHAREF, 127, "D3D9_AlphaRefFunc");
|
D3D9_SetRenderState2(D3DRS_ALPHAREF, 127, "D3D9_AlphaRefFunc");
|
||||||
|
D3D9_SetRenderState2(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA, "D3D9_AlphaSrcBlend");
|
||||||
|
D3D9_SetRenderState2(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA, "D3D9_AlphaDstBlend");
|
||||||
D3D9_RestoreRenderStates();
|
D3D9_RestoreRenderStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,14 +580,8 @@ void Gfx_DisableMipmaps(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------State management----------------------------------------------------*
|
*-----------------------------------------------------State management----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static PackedCol gfx_fogCol;
|
|
||||||
static float gfx_fogDensity = -1.0f, gfx_fogEnd = -1.0f;
|
|
||||||
static D3DFOGMODE gfx_fogMode = D3DFOG_NONE;
|
static D3DFOGMODE gfx_fogMode = D3DFOG_NONE;
|
||||||
|
|
||||||
static bool gfx_alphaTesting, gfx_alphaBlending;
|
static bool gfx_alphaTesting, gfx_alphaBlending;
|
||||||
static D3DBLEND gfx_srcBlendFunc = D3DBLEND_ONE, gfx_dstBlendFunc = D3DBLEND_ZERO;
|
|
||||||
|
|
||||||
static PackedCol gfx_clearCol;
|
|
||||||
static bool gfx_depthTesting, gfx_depthWriting;
|
static bool gfx_depthTesting, gfx_depthWriting;
|
||||||
static D3DCMPFUNC gfx_depthTestFunc = D3DCMP_LESSEQUAL;
|
static D3DCMPFUNC gfx_depthTestFunc = D3DCMP_LESSEQUAL;
|
||||||
|
|
||||||
@ -649,15 +648,6 @@ void Gfx_SetAlphaBlending(bool enabled) {
|
|||||||
D3D9_SetRenderState(D3DRS_ALPHABLENDENABLE, enabled, "D3D9_SetAlphaBlending");
|
D3D9_SetRenderState(D3DRS_ALPHABLENDENABLE, enabled, "D3D9_SetAlphaBlending");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetAlphaBlendFunc(BlendFunc srcFunc, BlendFunc dstFunc) {
|
|
||||||
static D3DBLEND funcs[6] = { D3DBLEND_ZERO, D3DBLEND_ONE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA, D3DBLEND_DESTALPHA, D3DBLEND_INVDESTALPHA };
|
|
||||||
|
|
||||||
gfx_srcBlendFunc = funcs[srcFunc];
|
|
||||||
D3D9_SetRenderState(D3DRS_SRCBLEND, gfx_srcBlendFunc, "D3D9_SetAlphaBlendFunc_Src");
|
|
||||||
gfx_dstBlendFunc = funcs[dstFunc];
|
|
||||||
D3D9_SetRenderState2(D3DRS_DESTBLEND, gfx_dstBlendFunc, "D3D9_SetAlphaBlendFunc_Dst");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Gfx_SetAlphaArgBlend(bool enabled) {
|
void Gfx_SetAlphaArgBlend(bool enabled) {
|
||||||
D3DTEXTUREOP op = enabled ? D3DTOP_MODULATE : D3DTOP_SELECTARG1;
|
D3DTEXTUREOP op = enabled ? D3DTOP_MODULATE : D3DTOP_SELECTARG1;
|
||||||
ReturnCode res = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, op);
|
ReturnCode res = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, op);
|
||||||
@ -689,8 +679,6 @@ static void D3D9_RestoreRenderStates(void) {
|
|||||||
union IntAndFloat raw;
|
union IntAndFloat raw;
|
||||||
D3D9_SetRenderState(D3DRS_ALPHATESTENABLE, gfx_alphaTesting, "D3D9_AlphaTest");
|
D3D9_SetRenderState(D3DRS_ALPHATESTENABLE, gfx_alphaTesting, "D3D9_AlphaTest");
|
||||||
D3D9_SetRenderState2(D3DRS_ALPHABLENDENABLE, gfx_alphaBlending, "D3D9_AlphaBlend");
|
D3D9_SetRenderState2(D3DRS_ALPHABLENDENABLE, gfx_alphaBlending, "D3D9_AlphaBlend");
|
||||||
D3D9_SetRenderState2(D3DRS_SRCBLEND, gfx_srcBlendFunc, "D3D9_AlphaSrcBlend");
|
|
||||||
D3D9_SetRenderState2(D3DRS_DESTBLEND, gfx_dstBlendFunc, "D3D9_AlphaDstBlend");
|
|
||||||
|
|
||||||
D3D9_SetRenderState2(D3DRS_FOGENABLE, gfx_fogEnabled, "D3D9_Fog");
|
D3D9_SetRenderState2(D3DRS_FOGENABLE, gfx_fogEnabled, "D3D9_Fog");
|
||||||
D3D9_SetRenderState2(D3DRS_FOGCOLOR, gfx_fogCol._raw, "gfx_fogColor");
|
D3D9_SetRenderState2(D3DRS_FOGCOLOR, gfx_fogCol._raw, "gfx_fogColor");
|
||||||
@ -1157,17 +1145,10 @@ void Gfx_DisableMipmaps(void) { }
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------State management----------------------------------------------------*
|
*-----------------------------------------------------State management----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static PackedCol gfx_clearCol, gfx_fogCol;
|
|
||||||
static float gfx_fogEnd = -1, gfx_fogDensity = -1;
|
|
||||||
static int gfx_fogMode = -1;
|
static int gfx_fogMode = -1;
|
||||||
|
|
||||||
void Gfx_SetFaceCulling(bool enabled) { gl_Toggle(GL_CULL_FACE); }
|
void Gfx_SetFaceCulling(bool enabled) { gl_Toggle(GL_CULL_FACE); }
|
||||||
|
|
||||||
void Gfx_SetAlphaBlending(bool enabled) { gl_Toggle(GL_BLEND); }
|
void Gfx_SetAlphaBlending(bool enabled) { gl_Toggle(GL_BLEND); }
|
||||||
void Gfx_SetAlphaBlendFunc(BlendFunc srcFunc, BlendFunc dstFunc) {
|
|
||||||
static GLenum funcs[6] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA };
|
|
||||||
glBlendFunc(funcs[srcFunc], funcs[dstFunc]);
|
|
||||||
}
|
|
||||||
void Gfx_SetAlphaArgBlend(bool enabled) { }
|
void Gfx_SetAlphaArgBlend(bool enabled) { }
|
||||||
|
|
||||||
void Gfx_ClearCol(PackedCol col) {
|
void Gfx_ClearCol(PackedCol col) {
|
||||||
@ -1669,8 +1650,10 @@ static void Gfx_RestoreState(void) {
|
|||||||
Gfx_InitDefaultResources();
|
Gfx_InitDefaultResources();
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
|
|
||||||
Gfx_SwitchProgram();
|
Gfx_SwitchProgram();
|
||||||
Gfx_DirtyUniform(UNI_MASK_ALL);
|
Gfx_DirtyUniform(UNI_MASK_ALL);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GL_SetupVbPos3fCol4b(void) {
|
static void GL_SetupVbPos3fCol4b(void) {
|
||||||
@ -1798,10 +1781,12 @@ void Gfx_LoadIdentityMatrix(MatrixType type) {
|
|||||||
static void Gfx_FreeState(void) { Gfx_FreeDefaultResources(); }
|
static void Gfx_FreeState(void) { Gfx_FreeDefaultResources(); }
|
||||||
static void Gfx_RestoreState(void) {
|
static void Gfx_RestoreState(void) {
|
||||||
Gfx_InitDefaultResources();
|
Gfx_InitDefaultResources();
|
||||||
glHint(GL_FOG_HINT, GL_NICEST);
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
|
glHint(GL_FOG_HINT, GL_NICEST);
|
||||||
glAlphaFunc(GL_GREATER, 0.5f);
|
glAlphaFunc(GL_GREATER, 0.5f);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,10 +16,6 @@ typedef enum CompareFunc_ {
|
|||||||
COMPARE_FUNC_LESS, COMPARE_FUNC_LESSEQUAL, COMPARE_FUNC_EQUAL,
|
COMPARE_FUNC_LESS, COMPARE_FUNC_LESSEQUAL, COMPARE_FUNC_EQUAL,
|
||||||
COMPARE_FUNC_GREATEREQUAL, COMPARE_FUNC_GREATER
|
COMPARE_FUNC_GREATEREQUAL, COMPARE_FUNC_GREATER
|
||||||
} CompareFunc;
|
} CompareFunc;
|
||||||
typedef enum BlendFunc_ {
|
|
||||||
BLEND_FUNC_ZERO, BLEND_FUNC_ONE, BLEND_FUNC_SRC_ALPHA,
|
|
||||||
BLEND_FUNC_INV_SRC_ALPHA, BLEND_FUNC_DST_ALPHA, BLEND_FUNC_INV_DST_ALPHA
|
|
||||||
} BlendFunc;
|
|
||||||
|
|
||||||
typedef enum VertexFormat_ {
|
typedef enum VertexFormat_ {
|
||||||
VERTEX_FORMAT_P3FC4B, VERTEX_FORMAT_P3FT2FC4B
|
VERTEX_FORMAT_P3FC4B, VERTEX_FORMAT_P3FT2FC4B
|
||||||
@ -93,8 +89,6 @@ CC_API void Gfx_SetFaceCulling(bool enabled);
|
|||||||
CC_API void Gfx_SetAlphaTest(bool enabled);
|
CC_API void Gfx_SetAlphaTest(bool enabled);
|
||||||
/* Sets whether existing and new pixels are blended together. */
|
/* Sets whether existing and new pixels are blended together. */
|
||||||
CC_API void Gfx_SetAlphaBlending(bool enabled);
|
CC_API void Gfx_SetAlphaBlending(bool enabled);
|
||||||
/* Sets in what way existing and new pixels are blended. */
|
|
||||||
CC_API void Gfx_SetAlphaBlendFunc(BlendFunc srcFunc, BlendFunc dstFunc);
|
|
||||||
/* Sets whether blending between the alpha components of texture and vertex colour is performed. */
|
/* Sets whether blending between the alpha components of texture and vertex colour is performed. */
|
||||||
CC_API void Gfx_SetAlphaArgBlend(bool enabled);
|
CC_API void Gfx_SetAlphaArgBlend(bool enabled);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user