aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-20 15:25:55 +0200
committerSven Gothel <[email protected]>2012-09-20 15:25:55 +0200
commit55e2ff7c04aa4dc1e8838bcf23690dc9e01c0130 (patch)
treefe3e61838d3820b142dbfe60ebeb290f306d242e /src/jogl/classes/com/jogamp/opengl
parent5684b94b1e7330b0008463bdee170358e9ecfa4c (diff)
GLReadBufferUtil, ShaderUtil: Catch GLException (and dump if thrown), to increase robustness $ glReadPixels and Get NUM_SHADER_BINARY_FORMATS
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java47
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<Integer>();
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; i<numFormats; i++) {
- info.shaderBinaryFormats.add(new Integer(formats[i]));
+ try {
+ 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; i<numFormats; i++) {
+ info.shaderBinaryFormats.add(new Integer(formats[i]));
+ }
}
- }
+ } catch (GLException gle) { gle.printStackTrace(); }
}
}
return info.shaderBinaryFormats;
@@ -180,17 +182,24 @@ public class ShaderUtil {
final ProfileInformation info = getProfileInformation(gl);
if(null==info.shaderCompilerAvailable) {
if(gl.isGLES2()) {
- final byte[] param = new byte[1];
- gl.glGetBooleanv(GL2ES2.GL_SHADER_COMPILER, param, 0);
- boolean v = param[0]!=(byte)0x00;
- if(!v) {
- final Set<Integer> 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<Integer> 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 {