From ff5dba28610b4f680c9320e9e52669ed54d4de43 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Jul 2014 20:13:34 +0200 Subject: Bug 830 - Add Heuristics for to query whether GLDrawableUtil.swapGLContextAndAllGLEventListener is safe (Doesn't work w/ pre MSAA onscreen drawable) GLDrawableUtil.isSwapGLContextSafe(..) allows user to query whether 'we think' it's safe to utilize swapping of GLContext between GLAutoDrawable instances. Currently known unsafe cases are: - between on- and offscreen and one of the following: - MSAA involved, or - STEREO involved Enhanced unit tests in this regard: - TestGLContextDrawableSwitch02AWT - using GLContextDrawableSwitchBase0 - TestGLContextDrawableSwitch02NEWT - using GLContextDrawableSwitchBase0 Utilized safe query for setupPrint(..) action in: - AWT GLCanvas - AWT GLJPanel - NewtCanvasAWT --- .../com/jogamp/opengl/util/GLDrawableUtil.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/jogl/classes/com') diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index a2978d6d5..c19bb12e9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -148,6 +148,37 @@ public class GLDrawableUtil { } } + /** + * Return a heuristic value whether switching the {@link GLContext} is safe between {@lin GLAutoDrawable}s, + * i.e. via {@link #swapGLContext(GLAutoDrawable, GLAutoDrawable)} or {@link #swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)}. + *

+ * Method currently returns false if: + *

+ * Otherwise method returns true + *

+ *

+ * [1] See Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + *

+ */ + public static boolean isSwapGLContextSafe(final GLCapabilitiesImmutable a, final GLCapabilitiesImmutable b) { + if( ( a.isOnscreen() && !b.isOnscreen() || !a.isOnscreen() && b.isOnscreen() ) && // switching between on- and offscreen + ( + ( a.getSampleBuffers() || b.getSampleBuffers() ) || // MSAA involved + ( a.getStereo() || b.getStereo() ) // Stereo involved + ) + ) + { + return false; + } else { + return true; + } + } /** * Swaps the {@link GLContext} and all {@link GLEventListener} between {@link GLAutoDrawable} a and b, * while preserving it's initialized state, resets the GL-Viewport and issuing {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)}. -- cgit v1.2.3