diff options
author | Sven Gothel <[email protected]> | 2013-06-24 06:51:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-24 06:51:16 +0200 |
commit | e5dd5757379353a9dd10248136afef65c33f6420 (patch) | |
tree | 0bed9f93211f3b425fcbccdcc29f9df1d06b687d /src | |
parent | 62f9525a9caba51fc4484c2ab47d64b516dc9d43 (diff) |
GearsES2/RedSquareES2: Detect !GLSL and don't attempt to render in such case.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java | 21 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java | 22 |
2 files changed, 34 insertions, 9 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 66a8082a6..7e86db972 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -124,7 +124,7 @@ public class GearsES2 implements GLEventListener { public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.init ..."); - GL2ES2 gl = drawable.getGL().getGL2ES2(); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(verbose) { System.err.println("GearsES2 init on "+Thread.currentThread()); @@ -138,6 +138,10 @@ public class GearsES2 implements GLEventListener { System.err.println("GL Profile: "+gl.getGLProfile()); System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion()); + } + if( !gl.hasGLSL() ) { + System.err.println("No GLSL available, no rendering."); + return; } gl.glEnable(GL.GL_DEPTH_TEST); @@ -228,11 +232,14 @@ public class GearsES2 implements GLEventListener { drawableHeight = height; // Thread.dumpStack(); - GL2ES2 gl = drawable.getGL().getGL2ES2(); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) } + if( !gl.hasGLSL() ) { + return; + } st.useProgram(gl, true); pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); @@ -264,7 +271,10 @@ public class GearsES2 implements GLEventListener { window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); } - GL2ES2 gl = drawable.getGL().getGL2ES2(); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + if( !gl.hasGLSL() ) { + return; + } st.useProgram(gl, false); gear1.destroy(gl); gear1 = null; @@ -291,7 +301,7 @@ public class GearsES2 implements GLEventListener { } // Get the GL corresponding to the drawable we are animating - GL2ES2 gl = drawable.getGL().getGL2ES2(); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); final boolean hasFocus; final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -320,6 +330,9 @@ public class GearsES2 implements GLEventListener { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } } + if( !gl.hasGLSL() ) { + return; + } gl.glEnable(GL.GL_CULL_FACE); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 3f092e341..b7f989637 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -64,7 +64,7 @@ public class RedSquareES2 implements GLEventListener { public void init(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.init ..."); - GL2ES2 gl = glad.getGL().getGL2ES2(); + final GL2ES2 gl = glad.getGL().getGL2ES2(); System.err.println("RedSquareES2 init on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + glad.getChosenGLCapabilities()); @@ -77,7 +77,10 @@ public class RedSquareES2 implements GLEventListener { System.err.println("GL Profile: "+gl.getGLProfile()); System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion()); - + if( !gl.hasGLSL() ) { + System.err.println("No GLSL available, no rendering."); + return; + } st = new ShaderState(); st.setVerbose(true); final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", @@ -132,11 +135,14 @@ public class RedSquareES2 implements GLEventListener { public void display(GLAutoDrawable glad) { long t1 = System.currentTimeMillis(); - GL2ES2 gl = glad.getGL().getGL2ES2(); + final GL2ES2 gl = glad.getGL().getGL2ES2(); if( clearBuffers ) { gl.glClearColor(0, 0, 0, 0); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } + if( !gl.hasGLSL() ) { + return; + } st.useProgram(gl, true); // One rotation every four seconds pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); @@ -161,7 +167,10 @@ public class RedSquareES2 implements GLEventListener { public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(glad.getHandle())); // Thread.dumpStack(); - GL2ES2 gl = glad.getGL().getGL2ES2(); + final GL2ES2 gl = glad.getGL().getGL2ES2(); + if( !gl.hasGLSL() ) { + return; + } if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) @@ -181,7 +190,10 @@ public class RedSquareES2 implements GLEventListener { public void dispose(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... "); - GL2ES2 gl = glad.getGL().getGL2ES2(); + final GL2ES2 gl = glad.getGL().getGL2ES2(); + if( !gl.hasGLSL() ) { + return; + } st.destroy(gl); st = null; pmvMatrix.destroy(); |