From 55e2ff7c04aa4dc1e8838bcf23690dc9e01c0130 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 20 Sep 2012 15:25:55 +0200 Subject: GLReadBufferUtil, ShaderUtil: Catch GLException (and dump if thrown), to increase robustness $ glReadPixels and Get NUM_SHADER_BINARY_FORMATS --- .../com/jogamp/opengl/util/GLReadBufferUtil.java | 4 +- .../com/jogamp/opengl/util/glsl/ShaderUtil.java | 47 +++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 34cc0eb07..b8709f31c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -179,7 +179,9 @@ public class GLReadBufferUtil { if(res) { psm.setAlignment(gl, alignment, alignment); readPixelBuffer.clear(); - gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), textureDataFormat, textureDataType, readPixelBuffer); + try { + gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), textureDataFormat, textureDataType, readPixelBuffer); + } catch(GLException gle) { res = false; gle.printStackTrace(); } readPixelBuffer.position(readPixelSize); readPixelBuffer.flip(); final int glerr1 = gl.glGetError(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java index 40c052498..8c0addb78 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java @@ -159,16 +159,18 @@ public class ShaderUtil { if(null == info.shaderBinaryFormats) { info.shaderBinaryFormats = new HashSet(); if (gl.isGLES2Compatible()) { - final int[] param = new int[1]; - gl.glGetIntegerv(GL2ES2.GL_NUM_SHADER_BINARY_FORMATS, param, 0); - int numFormats = param[0]; - if(numFormats>0) { - int[] formats = new int[numFormats]; - gl.glGetIntegerv(GL2ES2.GL_SHADER_BINARY_FORMATS, formats, 0); - for(int i=0; i0) { + int[] formats = new int[numFormats]; + gl.glGetIntegerv(GL2ES2.GL_SHADER_BINARY_FORMATS, formats, 0); + for(int i=0; i bfs = getShaderBinaryFormats(gl); - if(bfs.size()==0) { - // no supported binary formats, hence a compiler must be available! - v = true; + boolean queryOK = false; + try { + final byte[] param = new byte[1]; + gl.glGetBooleanv(GL2ES2.GL_SHADER_COMPILER, param, 0); + boolean v = param[0]!=(byte)0x00; + if(!v) { + final Set bfs = getShaderBinaryFormats(gl); + if(bfs.size()==0) { + // no supported binary formats, hence a compiler must be available! + v = true; + } } - } - info.shaderCompilerAvailable = new Boolean(v); + info.shaderCompilerAvailable = new Boolean(v); + queryOK = true; + } catch (GLException gle) { gle.printStackTrace(); } + if(!queryOK) { + info.shaderCompilerAvailable = new Boolean(true); + } } else if( gl.isGL2ES2() ) { info.shaderCompilerAvailable = new Boolean(true); } else { -- cgit v1.2.3