From 3ef5505faa78f0fba655ce6049c09c0e84f48b86 Mon Sep 17 00:00:00 2001 From: shadowislord Date: Sun, 2 Nov 2014 19:14:08 -0500 Subject: [PATCH] Allow render buffers to use 'Depth' format even if depth textures are not supported. Fixes post processing on GPUs without depth texture support (e.g. NVIDIA Tegra) --- .../com/jme3/renderer/android/OGLESShaderRenderer.java | 2 +- .../main/java/com/jme3/renderer/android/TextureUtil.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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 3d9a1b3b7..0655b347f 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 @@ -1283,7 +1283,7 @@ public class OGLESShaderRenderer implements Renderer { + ":" + fb.getHeight() + " is not supported."); } - AndroidGLImageFormat imageFormat = TextureUtil.getImageFormat(rb.getFormat()); + AndroidGLImageFormat imageFormat = TextureUtil.getImageFormat(rb.getFormat(), true); if (imageFormat.renderBufferStorageFormat == 0) { throw new RendererException("The format '" + rb.getFormat() + "' cannot be used for renderbuffers."); } diff --git a/jme3-android/src/main/java/com/jme3/renderer/android/TextureUtil.java b/jme3-android/src/main/java/com/jme3/renderer/android/TextureUtil.java index daecb05c9..329ccc19d 100644 --- a/jme3-android/src/main/java/com/jme3/renderer/android/TextureUtil.java +++ b/jme3-android/src/main/java/com/jme3/renderer/android/TextureUtil.java @@ -265,7 +265,8 @@ public class TextureUtil { throw new UnsupportedOperationException("The image format '" + fmt + "' is unsupported by the video hardware."); } - public static AndroidGLImageFormat getImageFormat(Format fmt) throws UnsupportedOperationException { + public static AndroidGLImageFormat getImageFormat(Format fmt, boolean forRenderBuffer) + throws UnsupportedOperationException { AndroidGLImageFormat imageFormat = new AndroidGLImageFormat(); switch (fmt) { case RGBA16: @@ -352,7 +353,7 @@ public class TextureUtil { break; case Depth: case Depth16: - if (!DEPTH_TEXTURE) { + if (!DEPTH_TEXTURE && !forRenderBuffer) { unsupportedFormat(fmt); } imageFormat.format = GLES20.GL_DEPTH_COMPONENT; @@ -434,7 +435,7 @@ public class TextureUtil { + "are not supported by the video hardware " + "and no scaling path available for image: " + img); } - AndroidGLImageFormat imageFormat = getImageFormat(fmt); + AndroidGLImageFormat imageFormat = getImageFormat(fmt, false); if (data != null) { GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1); @@ -527,7 +528,7 @@ public class TextureUtil { + "are not supported by the video hardware " + "and no scaling path available for image: " + img); } - AndroidGLImageFormat imageFormat = getImageFormat(fmt); + AndroidGLImageFormat imageFormat = getImageFormat(fmt, false); if (data != null) { GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);