aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java16
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java13
4 files changed, 42 insertions, 12 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 8626400f7..131f42e06 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -69,7 +69,8 @@ import jogamp.opengl.GLContextImpl;
refer to a given context. */
public abstract class GLContext {
public static final boolean DEBUG = Debug.debug("GLContext");
-
+
+ public static final boolean TRACE_SWITCH;
/** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
public final static boolean DEBUG_GL;
/** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
@@ -79,6 +80,7 @@ public abstract class GLContext {
final AccessControlContext acl = AccessController.getContext();
DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true, acl);
TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true, acl);
+ TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true, acl);
}
/** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}. */
@@ -295,6 +297,9 @@ public abstract class GLContext {
* new GLContext implementations; not for use by end users.
*/
protected static void setCurrent(GLContext cur) {
+ if(TRACE_SWITCH) {
+ System.err.println("GLContext.ContextSwitch: - setCurrent() - "+Thread.currentThread().getName()+": "+cur);
+ }
currentContext.set(cur);
}
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index e87d283eb..a7710e5bc 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -67,8 +67,6 @@ import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.GLProfile;
public abstract class GLContextImpl extends GLContext {
- public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true);
-
/**
* Context full qualified name: display_type + display_connection + major + minor + ctp.
* This is the key for all cached GL ProcAddressTables, etc, to support multi display/device setups.
@@ -242,18 +240,24 @@ public abstract class GLContextImpl extends GLContext {
release(false);
}
private void release(boolean force) throws GLException {
+ if(TRACE_SWITCH) {
+ System.err.println("GLContext.ContextSwitch: - release() - "+Thread.currentThread().getName()+": force: "+force+", "+lock);
+ }
if ( !lock.isOwner() ) {
- throw new GLException("Context not current on current thread");
+ throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this);
}
final boolean actualRelease = force || lock.getHoldCount() == 1 ;
- try {
+ try {
if( actualRelease ) {
- setCurrent(null);
if (contextHandle != 0) { // allow dbl-release
releaseImpl();
}
}
} finally {
+ // exception prone ..
+ if( actualRelease ) {
+ setCurrent(null);
+ }
drawable.unlockSurface();
lock.unlock();
if(TRACE_SWITCH) {
@@ -276,7 +280,7 @@ public abstract class GLContextImpl extends GLContext {
throw new GLException("XXX: "+lock);
}
if (DEBUG || TRACE_SWITCH) {
- System.err.println("GLContextImpl.destroy.0: " + toHexString(contextHandle) +
+ System.err.println("GLContextImpl.destroy.0 - "+Thread.currentThread().getName()+": " + toHexString(contextHandle) +
", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
}
if (contextHandle != 0) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 0ba7a99cd..522640294 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -536,7 +536,14 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
public boolean release(long ctx) {
- gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze
+ try {
+ gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("MacOSXCGLContext.NSOpenGLImpl.release: INFO: glFinish() catched exception:");
+ gle.printStackTrace();
+ }
+ }
final boolean res = CGL.clearCurrentContext(ctx);
final long cglCtx = CGL.getCGLContext(ctx);
if(0 == cglCtx) {
@@ -640,7 +647,14 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
public boolean release(long ctx) {
- gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze
+ try {
+ gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("MacOSXCGLContext.CGLImpl.release: INFO: glFinish() catched exception:");
+ gle.printStackTrace();
+ }
+ }
int err = CGL.CGLSetCurrentContext(0);
if(DEBUG && CGL.kCGLNoError != err) {
System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this);
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index e1810fd63..5c6486799 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -231,11 +231,18 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
} catch (GLException gle) {
if (DEBUG) {
- System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent failed");
+ System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent catched exception:");
gle.printStackTrace();
}
} finally {
- context.destroy();
+ try {
+ context.destroy();
+ } catch (GLException gle) {
+ if (DEBUG) {
+ System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: destroy catched exception:");
+ gle.printStackTrace();
+ }
+ }
}
}
drawable.destroy();
@@ -266,7 +273,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
} catch (GLException gle) {
if(DEBUG) {
- System.err.println("Catched Exception while MaxOSXCGL Shared Resource initialization");
+ System.err.println("Catched Exception while MaxOSXCGL Shared Resource initialization:");
gle.printStackTrace();
}
}