diff --git a/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java b/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java index 5875a94fb..3d9a1b3b7 100644 --- a/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java +++ b/jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java @@ -392,9 +392,22 @@ public class OGLESShaderRenderer implements Renderer { public void clearBuffers(boolean color, boolean depth, boolean stencil) { int bits = 0; if (color) { + //See explanations of the depth below, we must enable color write to be able to clear the color buffer + if (context.colorWriteEnabled == false) { + GLES20.glColorMask(true, true, true, true); + context.colorWriteEnabled = true; + } bits = GLES20.GL_COLOR_BUFFER_BIT; } if (depth) { + //glClear(GL_DEPTH_BUFFER_BIT) seems to not work when glDepthMask is false + //here s some link on openl board + //http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=257223 + //if depth clear is requested, we enable the depthMask + if (context.depthWriteEnabled == false) { + GLES20.glDepthMask(true); + context.depthWriteEnabled = true; + } bits |= GLES20.GL_DEPTH_BUFFER_BIT; } if (stencil) { diff --git a/jme3-ios/src/main/java/com/jme3/renderer/ios/IGLESShaderRenderer.java b/jme3-ios/src/main/java/com/jme3/renderer/ios/IGLESShaderRenderer.java index 5cdbcb4f9..ed78baae2 100644 --- a/jme3-ios/src/main/java/com/jme3/renderer/ios/IGLESShaderRenderer.java +++ b/jme3-ios/src/main/java/com/jme3/renderer/ios/IGLESShaderRenderer.java @@ -121,9 +121,22 @@ public class IGLESShaderRenderer implements Renderer { logger.log(Level.FINE, "IGLESShaderRenderer clearBuffers"); int bits = 0; if (color) { + //See explanations of the depth below, we must enable color write to be able to clear the color buffer + if (context.colorWriteEnabled == false) { + JmeIosGLES.glColorMask(true, true, true, true); + context.colorWriteEnabled = true; + } bits = JmeIosGLES.GL_COLOR_BUFFER_BIT; } if (depth) { + //glClear(GL_DEPTH_BUFFER_BIT) seems to not work when glDepthMask is false + //here s some link on openl board + //http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=257223 + //if depth clear is requested, we enable the depthMask + if (context.depthWriteEnabled == false) { + JmeIosGLES.glDepthMask(true); + context.depthWriteEnabled = true; + } bits |= JmeIosGLES.GL_DEPTH_BUFFER_BIT; } if (stencil) {