diff options
author | Sven Gothel <[email protected]> | 2012-03-25 03:29:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-03-25 03:29:53 +0200 |
commit | 3ed491213f8f7f05d7b9866b50d764370d8ff5f6 (patch) | |
tree | 07ea2547be486eb50db9d79a19f6e0c4dfa4dc70 /src/jogl/classes/jogamp | |
parent | 45a42f7c7f7fce4e6c7eb495591c438bdf0170a2 (diff) |
Enhance and generalize AWT Threading* implementation; Minor changes ..
Threading*:
- add invoke(..) generalizing the Therading decision
GLCanvas:
- remove 'manual' Threading decision, simply call Threading.invoke(..)
- use anonymous Runnable instances
- remove drawable lock, drawable is volatile instead
GLJPanel:
- remove 'manual' Threading decision, simply call Threading.invoke(..)
- use anonymous Runnable instances
- DEBUG: Use getThreadName() prefix
GLContextImpl:
- Remove GLWorkerThread idle command on makeCurrent(),
no holding of context in worker thread while idle.
- DEBUG: Use getThreadName() prefix
X11GLXContext:
- DEBUG: Use getThreadName() prefix
TODO: Validate whether it's OK for GLCanvas and GLJPanel to set Threading.Mode.MT as the default mode!
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 28 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLWorkerThread.java | 11 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/ThreadingImpl.java | 106 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java (renamed from src/jogl/classes/jogamp/opengl/ThreadingPlugin.java) | 11 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java | 41 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java | 46 |
6 files changed, 125 insertions, 118 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 7fd9970a4..f21b61b48 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -247,7 +247,7 @@ public abstract class GLContextImpl extends GLContext { } private void release(boolean force) throws GLException { if(TRACE_SWITCH) { - System.err.println("GLContext.ContextSwitch: - release() - "+Thread.currentThread().getName()+": force: "+force+", "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: - release() - force: "+force+", "+lock); } if ( !lock.isOwner() ) { throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); @@ -267,11 +267,7 @@ public abstract class GLContextImpl extends GLContext { drawable.unlockSurface(); lock.unlock(); if(TRACE_SWITCH) { - if( actualRelease ) { - System.err.println("GLContext.ContextSwitch: - switch - CONTEXT_RELEASE - "+Thread.currentThread().getName()+" - "+lock); - } else { - System.err.println("GLContext.ContextSwitch: - keep - CONTEXT_RELEASE - "+Thread.currentThread().getName()+" - "+lock); - } + System.err.println(getThreadName() +": GLContext.ContextSwitch: - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock); } } } @@ -285,7 +281,7 @@ public abstract class GLContextImpl extends GLContext { if(lock.getHoldCount() > 2) { throw new GLException("XXX: "+lock); } - if (DEBUG || TRACE_SWITCH) { + if (TRACE_SWITCH) { System.err.println(getThreadName() + ": GLContextImpl.destroy.0: " + toHexString(contextHandle) + ", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } @@ -321,7 +317,7 @@ public abstract class GLContextImpl extends GLContext { } } finally { lock.unlock(); - if (DEBUG || TRACE_SWITCH) { + if (TRACE_SWITCH) { System.err.println(getThreadName() + ": GLContextImpl.destroy.X: " + toHexString(contextHandle) + ", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } @@ -415,19 +411,13 @@ public abstract class GLContextImpl extends GLContext { // For Mac OS X, however, we need to update the context to track resizes drawableUpdatedNotify(); if(TRACE_SWITCH) { - System.err.println("GLContext.ContextSwitch: - keep - CONTEXT_CURRENT - "+Thread.currentThread().getName()+" - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: - keep - CONTEXT_CURRENT - "+lock); } return CONTEXT_CURRENT; } else { current.release(); } - } - if (GLWorkerThread.isStarted() && - !GLWorkerThread.isWorkerThread()) { - // Kick the GLWorkerThread off its current context - GLWorkerThread.invokeLater(new Runnable() { public void run() {} }); - } - + } if (0 == drawable.getHandle()) { throw new GLException("drawable has invalid handle: "+drawable); } @@ -460,7 +450,7 @@ public abstract class GLContextImpl extends GLContext { } if (res == CONTEXT_NOT_CURRENT) { if(TRACE_SWITCH) { - System.err.println("GLContext.ContextSwitch: - switch - CONTEXT_NOT_CURRENT - "+Thread.currentThread().getName()+" - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: - switch - CONTEXT_NOT_CURRENT - "+lock); } } else { setCurrent(this); @@ -481,10 +471,10 @@ public abstract class GLContextImpl extends GLContext { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } if(TRACE_SWITCH) { - System.err.println("GLContext.ContextSwitch: - switch - CONTEXT_CURRENT_NEW - "+Thread.currentThread().getName()+" - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: - switch - CONTEXT_CURRENT_NEW - "+lock); } } else if(TRACE_SWITCH) { - System.err.println("GLContext.ContextSwitch: - switch - CONTEXT_CURRENT - "+Thread.currentThread().getName()+" - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: - switch - CONTEXT_CURRENT - "+lock); } /* FIXME: refactor dependence on Java 2D / JOGL bridge diff --git a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java index e717ec64c..f7d59e127 100644 --- a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java +++ b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java @@ -79,7 +79,7 @@ public class GLWorkerThread { if (!started) { lock = new Object(); thread = new Thread(new WorkerRunnable(), - "JOGL GLWorkerThread"); + "JOGL-GLWorkerThread-"); thread.setDaemon(true); started = true; synchronized (lock) { @@ -149,6 +149,15 @@ public class GLWorkerThread { } } + public static void invoke(boolean wait, Runnable runnable) + throws InvocationTargetException, InterruptedException { + if(wait) { + invokeAndWait(runnable); + } else { + invokeLater(runnable); + } + } + public static void invokeAndWait(Runnable runnable) throws InvocationTargetException, InterruptedException { if (!started) { diff --git a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java index 0ba86870d..61a47675f 100644 --- a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java +++ b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java @@ -38,12 +38,13 @@ import java.lang.reflect.InvocationTargetException; import java.security.AccessController; import java.security.PrivilegedAction; -import com.jogamp.common.JogampRuntimeException; -import com.jogamp.common.util.*; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import com.jogamp.common.JogampRuntimeException; +import com.jogamp.common.util.ReflectionUtil; + /** Implementation of the {@link javax.media.opengl.Threading} class. */ public class ThreadingImpl { @@ -59,23 +60,23 @@ public class ThreadingImpl { protected static final boolean DEBUG = Debug.debug("Threading"); - private static boolean singleThreaded = true; - private static Mode mode = Mode.MT; + private static boolean singleThreaded; + private static Mode mode; private static boolean hasAWT; // We need to know whether we're running on X11 platforms to change // our behavior when the Java2D/JOGL bridge is active private static boolean _isX11; - private static final ThreadingPlugin threadingPlugin; + private static final ToolkitThreadingPlugin threadingPlugin; static { threadingPlugin = - AccessController.doPrivileged(new PrivilegedAction<ThreadingPlugin>() { - public ThreadingPlugin run() { - final String workaround; + AccessController.doPrivileged(new PrivilegedAction<ToolkitThreadingPlugin>() { + public ToolkitThreadingPlugin run() { + final String singleThreadProp; { final String w = Debug.getProperty("jogl.1thread", true); - workaround = null != w ? w.toLowerCase() : null; + singleThreadProp = null != w ? w.toLowerCase() : null; } ClassLoader cl = ThreadingImpl.class.getClassLoader(); // Default to using the AWT thread on all platforms except @@ -91,37 +92,42 @@ public class ThreadingImpl { String osType = NativeWindowFactory.getNativeWindowType(false); _isX11 = NativeWindowFactory.TYPE_X11.equals(osType); - mode = ( hasAWT ? Mode.ST_AWT : Mode.ST_WORKER ); // default + // default setting + singleThreaded = true; + mode = ( hasAWT ? Mode.ST_AWT : Mode.ST_WORKER ); - if (workaround != null) { - if (workaround.equals("true") || - workaround.equals("auto")) { - // Nothing to do; singleThreaded and mode already set up - } else if (workaround.equals("worker")) { + if (singleThreadProp != null) { + if (singleThreadProp.equals("true") || + singleThreadProp.equals("auto")) { + singleThreaded = true; + mode = ( hasAWT ? Mode.ST_AWT : Mode.ST_WORKER ); + } else if (singleThreadProp.equals("worker")) { singleThreaded = true; mode = Mode.ST_WORKER; - } else if (hasAWT && workaround.equals("awt")) { + } else if (hasAWT && singleThreadProp.equals("awt")) { singleThreaded = true; mode = Mode.ST_AWT; - } else { + } else if (singleThreadProp.equals("false")) { singleThreaded = false; mode = Mode.MT; + } else { + throw new RuntimeException("Unsupported value for property jogl.1thread: "+singleThreadProp+", should be [true/auto, worker, awt or false]"); } } - ThreadingPlugin threadingPlugin=null; - if(Mode.ST_AWT == mode) { + ToolkitThreadingPlugin threadingPlugin=null; + if(hasAWT) { // try to fetch the AWTThreadingPlugin Exception error=null; try { - threadingPlugin = (ThreadingPlugin) ReflectionUtil.createInstance("jogamp.opengl.awt.AWTThreadingPlugin", cl); + threadingPlugin = (ToolkitThreadingPlugin) ReflectionUtil.createInstance("jogamp.opengl.awt.AWTThreadingPlugin", cl); } catch (JogampRuntimeException jre) { error = jre; } - if(null==threadingPlugin) { + if( Mode.ST_AWT == mode && null==threadingPlugin ) { throw new GLException("Mode is AWT, but class 'jogamp.opengl.awt.AWTThreadingPlugin' is not available", error); } } if(DEBUG) { - System.err.println("Threading: jogl.1thread "+workaround+", singleThreaded "+singleThreaded+", hasAWT "+hasAWT+", mode "+mode+", plugin "+threadingPlugin); + System.err.println("Threading: jogl.1thread "+singleThreadProp+", singleThreaded "+singleThreaded+", hasAWT "+hasAWT+", mode "+mode+", plugin "+threadingPlugin); } return threadingPlugin; } @@ -147,7 +153,7 @@ public class ThreadingImpl { once disabled, partly to discourage careless use of this method. This method should be called as early as possible in an application. */ - public static void disableSingleThreading() { + public static final void disableSingleThreading() { singleThreaded = false; if (Debug.verbose()) { System.err.println("Application forced disabling of single-threading of javax.media.opengl implementation"); @@ -156,7 +162,7 @@ public class ThreadingImpl { /** Indicates whether OpenGL work is being automatically forced to a single thread in this implementation. */ - public static boolean isSingleThreaded() { + public static final boolean isSingleThreaded() { return singleThreaded; } @@ -164,11 +170,7 @@ public class ThreadingImpl { which this implementation of the javax.media.opengl APIs performs all of its OpenGL-related work. This method should only be called if the single-thread model is in effect. */ - public static boolean isOpenGLThread() throws GLException { - if (!isSingleThreaded()) { - throw new GLException("Should only call this in single-threaded mode"); - } - + public static final boolean isOpenGLThread() throws GLException { if(null!=threadingPlugin) { return threadingPlugin.isOpenGLThread(); } @@ -182,6 +184,13 @@ public class ThreadingImpl { throw new InternalError("Illegal single-threading mode " + mode); } } + + public static final boolean isToolkitThread() throws GLException { + if(null!=threadingPlugin) { + return threadingPlugin.isToolkitThread(); + } + return false; + } /** Executes the passed Runnable on the single thread used for all OpenGL work in this javax.media.opengl API implementation. It is @@ -192,43 +201,30 @@ public class ThreadingImpl { false). It is up to the end user to check to see whether the current thread is the OpenGL thread and either execute the Runnable directly or perform the work inside it. */ - public static void invokeOnOpenGLThread(Runnable r) throws GLException { - if (!isSingleThreaded()) { - throw new GLException ("Should only call this in single-threaded mode"); - } - - if (isOpenGLThread()) { - throw new GLException ("Should only call this from other threads than the OpenGL thread"); - } - + public static final void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException { if(null!=threadingPlugin) { - threadingPlugin.invokeOnOpenGLThread(r); + threadingPlugin.invokeOnOpenGLThread(wait, r); return; } switch (mode) { - case ST_AWT: - throw new InternalError(); - case ST_WORKER: - GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking - try { - GLWorkerThread.invokeAndWait(r); - } catch (InvocationTargetException e) { - throw new GLException(e.getTargetException()); - } catch (InterruptedException e) { - throw new GLException(e); - } + invokeOnWorkerThread(wait, r); break; default: throw new InternalError("Illegal single-threading mode " + mode); } } - - /** This is a workaround for AWT-related deadlocks which only seem - to show up in the context of applets */ - public static boolean isAWTMode() { - return (mode == Mode.ST_AWT); + + public static final void invokeOnWorkerThread(boolean wait, Runnable r) throws GLException { + GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking + try { + GLWorkerThread.invoke(wait, r); + } catch (InvocationTargetException e) { + throw new GLException(e.getTargetException()); + } catch (InterruptedException e) { + throw new GLException(e); + } } } diff --git a/src/jogl/classes/jogamp/opengl/ThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java index 0b0748b59..22972953a 100644 --- a/src/jogl/classes/jogamp/opengl/ThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -41,8 +42,12 @@ package jogamp.opengl; import javax.media.opengl.*; -public interface ThreadingPlugin { - /** Indicates whether the current thread is the single thread on +public interface ToolkitThreadingPlugin { + /** Indicates whether the current thread is the designated toolkit thread, + if such semantics exists. */ + public boolean isToolkitThread() throws GLException; + + /** Indicates whether the current thread is the thread on which this implementation of the javax.media.opengl APIs performs all of its OpenGL-related work. This method should only be called if the single-thread model is in effect. */ @@ -57,6 +62,6 @@ public interface ThreadingPlugin { false). It is up to the end user to check to see whether the current thread is the OpenGL thread and either execute the Runnable directly or perform the work inside it. */ - public void invokeOnOpenGLThread(Runnable r) throws GLException; + public void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException; } diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java index 901146fc4..73b7d197d 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java @@ -40,18 +40,24 @@ package jogamp.opengl.awt; -import javax.media.opengl.*; - import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; -import jogamp.opengl.*; +import javax.media.opengl.GLException; + +import jogamp.opengl.GLWorkerThread; +import jogamp.opengl.ThreadingImpl; +import jogamp.opengl.ToolkitThreadingPlugin; -public class AWTThreadingPlugin implements ThreadingPlugin { +public class AWTThreadingPlugin implements ToolkitThreadingPlugin { public AWTThreadingPlugin() {} - public boolean isOpenGLThread() throws GLException { + public final boolean isToolkitThread() throws GLException { + return EventQueue.isDispatchThread(); + } + + public final boolean isOpenGLThread() throws GLException { switch (ThreadingImpl.getMode()) { case ST_AWT: // FIXME: See the FIXME below in 'invokeOnOpenGLThread' @@ -76,7 +82,7 @@ public class AWTThreadingPlugin implements ThreadingPlugin { } } - public void invokeOnOpenGLThread(Runnable r) throws GLException { + public final void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException { switch (ThreadingImpl.getMode()) { case ST_AWT: // FIXME: ideally should run all OpenGL work on the Java2D QFT @@ -87,11 +93,19 @@ public class AWTThreadingPlugin implements ThreadingPlugin { // implementation, which attempts to grab the AWT lock on the // QFT which is not allowed. For now, on X11 platforms, // continue to perform this work on the EDT. - if (Java2D.isOGLPipelineActive() && !ThreadingImpl.isX11()) { - Java2D.invokeWithOGLContextCurrent(null, r); + if (wait && Java2D.isOGLPipelineActive() && !ThreadingImpl.isX11()) { + if(wait) { + Java2D.invokeWithOGLContextCurrent(null, r); + } else { + + } } else { try { - EventQueue.invokeAndWait(r); + if(wait) { + EventQueue.invokeAndWait(r); + } else { + EventQueue.invokeLater(r); + } } catch (InvocationTargetException e) { throw new GLException(e.getTargetException()); } catch (InterruptedException e) { @@ -101,14 +115,7 @@ public class AWTThreadingPlugin implements ThreadingPlugin { break; case ST_WORKER: - GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking - try { - GLWorkerThread.invokeAndWait(r); - } catch (InvocationTargetException e) { - throw new GLException(e.getTargetException()); - } catch (InterruptedException e) { - throw new GLException(e); - } + ThreadingImpl.invokeOnWorkerThread(wait, r); break; default: diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index f4ab92a04..5cfd12ef5 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -55,6 +55,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; +import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; @@ -63,8 +64,7 @@ import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; public abstract class X11GLXContext extends GLContextImpl { - protected static final boolean TRACE_CONTEXT_CURRENT = false; // true; - + private static final boolean DEBUG_GLX_MAKECURRENT = Debug.debug("GLX_MAKE_CURRENT"); private static final Map<String, String> functionNameMap; private static final Map<String, String> extensionNameMap; private GLXExt _glXExt; @@ -139,10 +139,10 @@ public abstract class X11GLXContext extends GLContextImpl { boolean res = false; try { - if(TRACE_CONTEXT_CURRENT) { - Throwable t = new Throwable(Thread.currentThread()+" - glXMakeContextCurrent("+toHexString(dpy)+", "+ - toHexString(writeDrawable)+", "+toHexString(readDrawable)+", "+toHexString(ctx)+") - GLX >= 1.3 "+ isGLXVersionGreaterEqualOneThree()); - t.printStackTrace(); + if(DEBUG_GLX_MAKECURRENT) { + System.err.println(getThreadName()+": glXMakeContextCurrent(dpy "+toHexString(dpy)+", write "+ toHexString(writeDrawable)+ + ", read "+toHexString(readDrawable)+", ctx "+toHexString(ctx)+") - GLX >= 1.3 "+ isGLXVersionGreaterEqualOneThree()); + Thread.dumpStack(); } if ( isGLXVersionGreaterEqualOneThree() ) { res = GLX.glXMakeContextCurrent(dpy, writeDrawable, readDrawable, ctx); @@ -153,8 +153,8 @@ public abstract class X11GLXContext extends GLContextImpl { throw new InternalError("Given readDrawable but no driver support"); } } catch (RuntimeException re) { - if(DEBUG) { - System.err.println("Warning: X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+ + if(TRACE_SWITCH) { + System.err.println(getThreadName()+": Warning: X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+ "dpy "+toHexString(dpy)+ ", write "+toHexString(writeDrawable)+ ", read "+toHexString(readDrawable)+ @@ -190,7 +190,7 @@ public abstract class X11GLXContext extends GLContextImpl { updateGLXProcAddressTable(); GLXExt _glXExt = getGLXExt(); if(DEBUG) { - System.err.println("X11GLXContext.createContextARBImpl: "+getGLVersion(major, minor, ctp, "@creation") + + System.err.println(getThreadName()+": X11GLXContext.createContextARBImpl: "+getGLVersion(major, minor, ctp, "@creation") + ", handle "+toHexString(drawable.getHandle()) + ", share "+toHexString(share)+", direct "+direct+ ", glXCreateContextAttribsARB: "+toHexString(glXExtProcAddressTable._addressof_glXCreateContextAttribsARB)); } @@ -237,14 +237,14 @@ public abstract class X11GLXContext extends GLContextImpl { X11Lib.XSync(display, false); } catch (RuntimeException re) { if(DEBUG) { - Throwable t = new Throwable("Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re); + Throwable t = new Throwable(getThreadName()+": Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re); t.printStackTrace(); } } if(0!=ctx) { if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), ctx)) { if(DEBUG) { - System.err.println("X11GLXContext.createContextARBImpl couldn't make current "+getGLVersion(major, minor, ctp, "@creation")); + System.err.println(getThreadName()+": X11GLXContext.createContextARBImpl couldn't make current "+getGLVersion(major, minor, ctp, "@creation")); } // release & destroy glXMakeContextCurrent(display, 0, 0, 0); @@ -295,14 +295,14 @@ public abstract class X11GLXContext extends GLContextImpl { if(config.getFBConfigID()<0) { // not able to use FBConfig if(glp.isGL3()) { - throw new GLException("Unable to create OpenGL >= 3.1 context"); + throw new GLException(getThreadName()+": Unable to create OpenGL >= 3.1 context"); } contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct); if (contextHandle == 0) { - throw new GLException("Unable to create context(0)"); + throw new GLException(getThreadName()+": Unable to create context(0)"); } if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); + throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION isDirect = GLX.glXIsDirect(display, contextHandle); @@ -329,10 +329,10 @@ public abstract class X11GLXContext extends GLContextImpl { // so we are able to use GetProcAddress temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, direct); if (temp_ctx == 0) { - throw new GLException("Unable to create temp OpenGL context(1)"); + throw new GLException(getThreadName()+": Unable to create temp OpenGL context(1)"); } if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) { - throw new GLException("Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); + throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); } setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION glXMakeContextCurrent(display, 0, 0, 0); // release temp context @@ -364,17 +364,17 @@ public abstract class X11GLXContext extends GLContextImpl { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_ctx); if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Cannot make previous verified context current"); + throw new GLException(getThreadName()+": Cannot make previous verified context current"); } } } else { if(glp.isGL3()) { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_ctx); - throw new GLException("X11GLXContext.createContextImpl ctx !ARB, context > GL2 requested - requested: "+glp+", current: "+getGLVersion()+", "); + throw new GLException(getThreadName()+": X11GLXContext.createContextImpl ctx !ARB, context > GL2 requested - requested: "+glp+", current: "+getGLVersion()+", "); } if(DEBUG) { - System.err.println("X11GLXContext.createContextImpl failed, fall back to !ARB context "+getGLVersion()); + System.err.println(getThreadName()+": X11GLXContext.createContextImpl failed, fall back to !ARB context "+getGLVersion()); } // continue with temp context for GL <= 3.0 @@ -382,7 +382,7 @@ public abstract class X11GLXContext extends GLContextImpl { if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_ctx); - throw new GLException("Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); + throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } if (DEBUG) { System.err.println(getThreadName() + ": createContextImpl: OK (old-2) share "+share); @@ -402,7 +402,7 @@ public abstract class X11GLXContext extends GLContextImpl { X11Util.setX11ErrorHandler(true, DEBUG ? false : true); try { if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Error making context current: "+this); + throw new GLException(getThreadName()+": Error making context current: "+this); } } finally { X11Util.setX11ErrorHandler(false, false); @@ -415,7 +415,7 @@ public abstract class X11GLXContext extends GLContextImpl { X11Util.setX11ErrorHandler(true, DEBUG ? false : true); try { if (!glXMakeContextCurrent(display, 0, 0, 0)) { - throw new GLException("Error freeing OpenGL context"); + throw new GLException(getThreadName()+": Error freeing OpenGL context"); } } finally { X11Util.setX11ErrorHandler(false, false); @@ -431,7 +431,7 @@ public abstract class X11GLXContext extends GLContextImpl { long src = source.getHandle(); long display = drawable.getNativeSurface().getDisplayHandle(); if (0 == display) { - throw new GLException("Connection to X display not yet set up"); + throw new GLException(getThreadName()+": Connection to X display not yet set up"); } GLX.glXCopyContext(display, src, dst, mask); // Should check for X errors and raise GLException |