From 768cf72ca79ab0a0da30480705974f988b0c8a4d Mon Sep 17 00:00:00 2001 From: PendingChaos Date: Thu, 19 May 2016 20:15:34 +0100 Subject: [PATCH] GL: Fixed a bug where the depth buffer is not written to (#793) `glDisable(GL_DEPTH_TEST)` disables not just depth testing but depth writing too. In the OpenGL renderer, it is called even when depth writing is enabled. This commit makes it fall back to `glEnable(GL_DEPTH_TEST)` and `glDepthFunc(GL_ALWAYS)` when it is enabled. --- src/renderer_gl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 86c67ac42..68e4b952c 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -6198,7 +6198,15 @@ namespace bgfx { namespace gl } else { - GL_CHECK(glDisable(GL_DEPTH_TEST) ); + if (BGFX_STATE_DEPTH_WRITE & newFlags) + { + GL_CHECK(glEnable(GL_DEPTH_TEST) ); + GL_CHECK(glDepthFunc(GL_ALWAYS) ); + } + else + { + GL_CHECK(glDisable(GL_DEPTH_TEST) ); + } } }