From 7f8fa4d74c86dd2821ba756b5e6439f9224bbf35 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Thu, 7 Sep 2017 23:07:38 -0400 Subject: [PATCH] Fix depth texture support in OpenGL ES 2.0 --- .../main/java/com/jme3/renderer/opengl/GLImageFormats.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java index f12bfd1bc..23bee3604 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java @@ -206,9 +206,14 @@ public final class GLImageFormats { // Need to check if Caps.DepthTexture is supported prior to using for textures // But for renderbuffers its OK. - format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE); format(formatToGL, Format.Depth16, GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_SHORT); + // NOTE: OpenGL ES 2.0 does not support DEPTH_COMPONENT as internal format -- fallback to 16-bit depth. + if (caps.contains(Caps.OpenGLES20)) { + format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE); + } else { + format(formatToGL, Format.Depth, GL.GL_DEPTH_COMPONENT, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_BYTE); + } if (caps.contains(Caps.OpenGL20)) { format(formatToGL, Format.Depth24, GL2.GL_DEPTH_COMPONENT24, GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_INT); }