aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLContextImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-12 20:27:21 +0200
committerSven Gothel <[email protected]>2013-04-12 20:27:21 +0200
commitcfe62741e19196d973d9b31f2c8f3873705cb74b (patch)
tree6c9ee8f3404f2ad1e1039b88767c6340cb5423a1 /src/jogl/classes/jogamp/opengl/GLContextImpl.java
parentdc898f14eeebf524726c820e25ffefb166a6c7f3 (diff)
GLContextImpl: destroy(): Fix null drawable check; makeCurrentWithinLock(): Add drawable size validation before attempt to create context; MacOSXCGLContext: Explicit exception for Null AttachGLLayerCmd.
GLContextImpl: - destroy(): - Fix null drawable check Only if the GLContext isCreated(), we require a drawable to be set. - Proper name of associateDrawable Exception - makeCurrentWithinLock(): - Add drawable size validation before attempt to create context. - 'makeCurrent()' shall never be called w/o proper sized drawable, i.e. > 0x0. - returns CONTEXT_NOT_CURRENT, if drawable size is <= 0x0 MacOSXCGLContext: - Explicit exception for Null AttachGLLayerCmd. In case context creation has failed via makeCurrent(), AttachGLLayerCmd may never been issued and hence maybe NULL. Catch this case and send a meaningful exception, which is catched and fwd in GLContext.destroy().
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLContextImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 0d8b193af..376b3c0e5 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -342,23 +342,24 @@ public abstract class GLContextImpl extends GLContext {
@Override
public final void destroy() {
- if ( null == drawable ) {
- throw new GLException("Drawable is null: "+toString());
- }
if ( DEBUG_TRACE_SWITCH ) {
+ final long drawH = null != drawable ? drawable.getHandle() : 0;
System.err.println(getThreadName() + ": GLContextImpl.destroy.0: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) +
- ", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
+ ", surf "+toHexString(drawH)+", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
}
- if ( 0 != contextHandle ) {
+ if ( 0 != contextHandle ) { // isCreated() ?
+ if ( null == drawable ) {
+ throw new GLException("GLContext created but drawable is null: "+toString());
+ }
final int lockRes = drawable.lockSurface();
if ( NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes ) {
// this would be odd ..
throw new GLException("Surface not ready to lock: "+drawable);
}
- Throwable drawableContextRealizedException = null;
+ Throwable associateDrawableException = null;
try {
if ( !drawable.isRealized() ) {
- throw new GLException("Drawable not realized: "+toString());
+ throw new GLException("GLContext created but drawable not realized: "+toString());
}
// Must hold the lock around the destroy operation to make sure we
// don't destroy the context while another thread renders to it.
@@ -380,7 +381,7 @@ public abstract class GLContextImpl extends GLContext {
try {
associateDrawable(false);
} catch (Throwable t) {
- drawableContextRealizedException = t;
+ associateDrawableException = t;
}
if ( 0 != defaultVAO ) {
int[] tmp = new int[] { defaultVAO };
@@ -410,8 +411,8 @@ public abstract class GLContextImpl extends GLContext {
} finally {
drawable.unlockSurface();
}
- if(null != drawableContextRealizedException) {
- throw new GLException("GLContext.destroy() during GLDrawableImpl.contextRealized(this, false)", drawableContextRealizedException);
+ if( null != associateDrawableException ) {
+ throw new GLException("GLContext.destroy() during associateDrawable(false)", associateDrawableException);
}
}
resetStates();
@@ -601,6 +602,13 @@ public abstract class GLContextImpl extends GLContext {
private final int makeCurrentWithinLock(int surfaceLockRes) throws GLException {
if (!isCreated()) {
+ if( 0 >= drawable.getWidth() || 0 >= drawable.getHeight() ) {
+ if ( DEBUG_TRACE_SWITCH ) {
+ System.err.println(getThreadName() + ": Create GL context REJECTED (zero surface size) obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName());
+ System.err.println(drawable.toString());
+ }
+ return CONTEXT_NOT_CURRENT;
+ }
if(DEBUG_GL) {
// only impacts w/ createContextARB(..)
additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG ;