From a66a7b7ce99bb76449999dee7db45f73be079ee1 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 26 Feb 2015 01:00:38 -0400 Subject: [PATCH] Prevent invalid stencil buffer contents from being used when switching to a Canvas on mobile. --HG-- branch : minor --- src/modules/graphics/opengl/Canvas.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index d90c5ce78..f8503d926 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -768,6 +768,11 @@ void Canvas::setupGrab() if (msaa_buffer != 0) msaa_dirty = true; + + // We discard the stencil buffer in stopGrab, so we should clear it here + // to prevent the discarded (invalid) contents from being accidentally used. + if (depth_stencil != 0 && (GLAD_ES_VERSION_3_0 || GLAD_EXT_discard_framebuffer)) + glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } void Canvas::startGrab(const std::vector &canvases)