diff options
author | Sven Gothel <[email protected]> | 2012-08-17 13:47:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-08-17 13:47:48 +0200 |
commit | ee5c34e5bb067631572a7001ab1ec3543c52065f (patch) | |
tree | 6bd997c3da8e114b923faf66015fdbaac5791f24 /src/jogl | |
parent | 09a8151abe3934ccf17fa84d5b2000e259351312 (diff) |
Robostness: GLDrawableImpl's contextMadeCurrent()/contextRealized() ; GLFBODrawableImpl.contextMadeCurrent(false), OffscreenAutoDrawable.setSize(..)
GLDrawableImpl's contextMadeCurrent()/contextRealized():
- Catch exception which may appear during callback and cont. w/ GLContextImpl's release()/destroy()
while throwing catched exception at end.
GLFBODrawableImpl.contextMadeCurrent(false):
- Detect null Colorbuffer ASAP and throw exception
OffscreenAutoDrawable.setSize(..):
- Catch exceptions at 1) GLFBODrawableImpl.setSize(..) and
2) GLContext.release() .. throw it in proper order.
Diffstat (limited to 'src/jogl')
3 files changed, 39 insertions, 4 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java index 8450ffdb0..4caea03b2 100644 --- a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java @@ -69,12 +69,26 @@ public class OffscreenAutoDrawable extends GLAutoDrawableDelegate { public boolean setSize(int newWidth, int newHeight) throws GLException { boolean done = false; if(drawable instanceof GLFBODrawableImpl) { + Throwable tFBO = null; + Throwable tGL = null; context.makeCurrent(); try { ((GLFBODrawableImpl)drawable).setSize(context.getGL(), newWidth, newHeight); done = true; + } catch (Throwable t) { + tFBO = t; } finally { - context.release(); + try { + context.release(); + } catch (Throwable t) { + tGL = t; + } + } + if(null != tFBO) { + throw new GLException("OffscreenAutoDrawable.setSize(..) GLFBODrawableImpl.setSize(..) exception", tFBO); + } + if(null != tGL) { + throw new GLException("OffscreenAutoDrawable.setSize(..) GLContext.release() exception", tGL); } } if(done) { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index bf6a0ee6e..e82756022 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -266,11 +266,16 @@ public abstract class GLContextImpl extends GLContext { if ( !lock.isOwner(Thread.currentThread()) ) { throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); } + Throwable drawableContextMadeCurrentException = null; final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle; try { if( actualRelease ) { if( !inDestruction ) { - drawable.contextMadeCurrent(this, false); + try { + drawable.contextMadeCurrent(this, false); + } catch (Throwable t) { + drawableContextMadeCurrentException = t; + } } releaseImpl(); } @@ -285,6 +290,10 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock); } } + if(null != drawableContextMadeCurrentException) { + throw new GLException("GLContext.release(false) during GLDrawableImpl.contextMadeCurrent(this, false)", drawableContextMadeCurrentException); + } + } protected abstract void releaseImpl() throws GLException; @@ -300,6 +309,7 @@ public abstract class GLContextImpl extends GLContext { // this would be odd .. throw new GLException("Surface not ready to lock: "+drawable); } + Throwable drawableContextRealizedException = null; try { // Must hold the lock around the destroy operation to make sure we // don't destroy the context while another thread renders to it. @@ -320,7 +330,11 @@ public abstract class GLContextImpl extends GLContext { // needs current context to disable debug handler makeCurrent(); } - drawable.contextRealized(this, false); + try { + drawable.contextRealized(this, false); + } catch (Throwable t) { + drawableContextRealizedException = t; + } glDebugHandler.enable(false); if(lock.getHoldCount() > 1) { // pending release() after makeCurrent() @@ -343,6 +357,9 @@ public abstract class GLContextImpl extends GLContext { } finally { drawable.unlockSurface(); } + if(null != drawableContextRealizedException) { + throw new GLException("GLContext.destroy() during GLDrawableImpl.contextRealized(this, false)", drawableContextRealizedException); + } } resetStates(); } diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index b7ea4f826..03bc26cbc 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -69,8 +69,12 @@ public class GLFBODrawableImpl extends GLDrawableImpl { fbo.bind(gl); } else { fbo.unbind(gl); + final TextureAttachment attachment = samples > 0 ? fbo.getSamplingSink() : (TextureAttachment) fbo.getColorbuffer(0) ; + if(null == attachment) { + throw new GLException("Null texture colorbuffer, samples "+samples+", "+fbo.toString()); + } gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); - fbo.use(gl, samples > 0 ? fbo.getSamplingSink() : (TextureAttachment) fbo.getColorbuffer(0) ); + fbo.use(gl, attachment ); if( samples > 0) { gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbo.getReadFramebuffer()); } |