From b75a3415c55ebeed3e856270850981f383b94105 Mon Sep 17 00:00:00 2001 From: "Sha..rd" Date: Sat, 11 Feb 2012 05:32:24 +0000 Subject: [PATCH] * Android - fix shader compile error on PowerVR GPUs git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9140 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../renderer/android/OGLESShaderRenderer.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java b/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java index c00680cc9..343a68a19 100644 --- a/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java +++ b/engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java @@ -102,6 +102,7 @@ public class OGLESShaderRenderer implements Renderer { private int vpX, vpY, vpW, vpH; private int clipX, clipY, clipW, clipH; //private final GL10 gl; + private boolean powerVr = false; private boolean powerOf2 = false; private boolean verboseLogging = false; private boolean useVBO = false; @@ -145,6 +146,8 @@ public class OGLESShaderRenderer implements Renderer { logger.log(Level.INFO, "Renderer: {0}", GLES20.glGetString(GLES20.GL_RENDERER)); logger.log(Level.INFO, "Version: {0}", GLES20.glGetString(GLES20.GL_VERSION)); + powerVr = GLES20.glGetString(GLES20.GL_RENDERER).contains("PowerVR"); + String versionStr = GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION); logger.log(Level.INFO, "GLES20.Shading Language Version: {0}", versionStr); if (versionStr == null || versionStr.equals("")) { @@ -987,11 +990,19 @@ public class OGLESShaderRenderer implements Renderer { logger.info("GLES20.glShaderSource(" + id + ")"); } - GLES20.glShaderSource( - id, - "precision mediump float;\n" - + source.getDefines() - + source.getSource()); + if (powerVr) { + // XXX: This is to fix a bug in old PowerVR, remove + // when no longer applicable. + GLES20.glShaderSource( + id, source.getDefines() + + source.getSource()); + } else { + GLES20.glShaderSource( + id, + "precision mediump float;\n" + + source.getDefines() + + source.getSource()); + } checkGLError();