gl: Always use indexed blend caps to avoid conflict with the state cache.

- glEnable/glDisable should not be used with GL_BLEND as the main renderer uses the indexed variant
This commit is contained in:
kd-11 2018-03-23 19:24:40 +03:00
commit 22af70d0d0
2 changed files with 6 additions and 5 deletions

View file

@ -155,7 +155,7 @@ namespace gl
GLboolean scissor_enabled = glIsEnabled(GL_SCISSOR_TEST); GLboolean scissor_enabled = glIsEnabled(GL_SCISSOR_TEST);
GLboolean depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); GLboolean depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
GLboolean cull_face_enabled = glIsEnabled(GL_CULL_FACE); GLboolean cull_face_enabled = glIsEnabled(GL_CULL_FACE);
GLboolean blend_enabled = glIsEnabled(GL_BLEND); GLboolean blend_enabled = glIsEnabledi(GL_BLEND, 0);
GLboolean stencil_test_enabled = glIsEnabled(GL_STENCIL_TEST); GLboolean stencil_test_enabled = glIsEnabled(GL_STENCIL_TEST);
if (use_blending) if (use_blending)
@ -184,14 +184,14 @@ namespace gl
if (use_blending) if (use_blending)
{ {
if (!blend_enabled) if (!blend_enabled)
glEnable(GL_BLEND); glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
} }
else if (blend_enabled) else if (blend_enabled)
{ {
glDisable(GL_BLEND); glDisablei(GL_BLEND, 0);
} }
// Render // Render
@ -226,14 +226,14 @@ namespace gl
if (use_blending) if (use_blending)
{ {
if (!blend_enabled) if (!blend_enabled)
glDisable(GL_BLEND); glDisablei(GL_BLEND, 0);
glBlendFuncSeparate(blend_src_rgb, blend_dst_rgb, blend_src_a, blend_dst_a); glBlendFuncSeparate(blend_src_rgb, blend_dst_rgb, blend_src_a, blend_dst_a);
glBlendEquationSeparate(blend_eq_rgb, blend_eq_a); glBlendEquationSeparate(blend_eq_rgb, blend_eq_a);
} }
else if (blend_enabled) else if (blend_enabled)
{ {
glEnable(GL_BLEND); glEnablei(GL_BLEND, 0);
} }
} }
else else

View file

@ -157,6 +157,7 @@ OPENGL_PROC(PFNGLDRAWBUFFERSPROC, DrawBuffers);
OPENGL_PROC(PFNGLENABLEIPROC, Enablei); OPENGL_PROC(PFNGLENABLEIPROC, Enablei);
OPENGL_PROC(PFNGLDISABLEIPROC, Disablei); OPENGL_PROC(PFNGLDISABLEIPROC, Disablei);
OPENGL_PROC(PFNGLISENABLEDIPROC, IsEnabledi);
OPENGL_PROC(PFNGLPRIMITIVERESTARTINDEXPROC, PrimitiveRestartIndex); OPENGL_PROC(PFNGLPRIMITIVERESTARTINDEXPROC, PrimitiveRestartIndex);