From 289ba90b9ce118ba987b47ee70870cca77287cc0 Mon Sep 17 00:00:00 2001
From: Sven Gothel
* [1] See Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX
*
+ * Because of above mentioned locking, if this method is not performed + * on {@link GLAutoDrawable#isThreadGLCapable() a OpenGL capable thread} of both + * {@link GLAutoDrawable}s, it must be invoked on such an OpenGL capable thread, + * e.g. via {@link Threading#invokeOnOpenGLThread(boolean, Runnable)}. + *
* @throws GLException if the {@link AbstractGraphicsDevice} are incompatible w/ each other. + * @see #isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable) */ public static final void swapGLContextAndAllGLEventListener(final GLAutoDrawable a, final GLAutoDrawable b) { final GLEventListenerState gllsA = GLEventListenerState.moveFrom(a, true); @@ -232,8 +241,15 @@ public class GLDrawableUtil { * hence atomicity of operation is guaranteed, * see GLAutoDrawable Locking. * + *+ * Because of above mentioned locking, if this method is not performed + * on {@link GLAutoDrawable#isThreadGLCapable() a OpenGL capable thread} of both + * {@link GLAutoDrawable}s, it must be invoked on such an OpenGL capable thread, + * e.g. via {@link Threading#invokeOnOpenGLThread(boolean, Runnable)}. + *
* @param a * @param b + * @see #isSwapGLContextSafe(GLCapabilitiesImmutable, GLCapabilitiesImmutable) */ public static final void swapGLContext(final GLAutoDrawable a, final GLAutoDrawable b) { final GLAnimatorControl aAnim = a.getAnimator(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java index 49d16a80a..239cab26d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase0.java @@ -34,6 +34,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; +import javax.media.opengl.Threading; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLDrawableUtil; @@ -226,8 +227,17 @@ public abstract class GLContextDrawableSwitchBase0 extends UITestCase { s++; System.err.println(s+" - switch - START "+ ( t1 - t0 )); + final Runnable switchAction = new Runnable() { + public void run() { + GLDrawableUtil.swapGLContextAndAllGLEventListener(gladSource, gladDest); + } }; + // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(gladSource, gladDest); + if( gladSource.isThreadGLCapable() && gladDest.isThreadGLCapable() ) { + switchAction.run(); + } else { + Threading.invokeOnOpenGLThread(true, switchAction); + } snapshotGLEventListener.setMakeSnapshot(); System.err.println(s+" - switch - END "+ ( t1 - t0 )); -- cgit v1.2.3