summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-11-04 17:02:44 +0100
committerSven Gothel <[email protected]>2012-11-04 17:02:44 +0100
commitb51cab4a8bcf8d9256e39657369510e39d22f162 (patch)
tree6bb1604fe4328dadb053e08ee8dfba8b4467e1bd /src
parent9cf42434eb58160e25c79613efca51f2fd4d6086 (diff)
GLDrawableUtil.swapGLContextAndAllGLEventListener(..): Add glFinish() before and after ctx/drawable swap - sync'ing GL state
Otherwise a driver crash may occur on Windows/NVidia.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java53
1 files changed, 36 insertions, 17 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
index 8197be4f5..08eaf0494 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
@@ -123,41 +123,53 @@ public class GLDrawableUtil {
final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause();
final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause();
- // enqueue reset GL-Viewport
- a.enqueue(setViewport);
- b.enqueue(setViewport);
-
//
- // cache all GLEventListener and their init-state
- // enqueue reshape on their destination, if already initialized
+ // remove and cache all GLEventListener and their init-state
//
final int aSz = a.getGLEventListenerCount();
final GLEventListener[] aGLE = new GLEventListener[aSz];
final boolean[] aInit = new boolean[aSz];
for(int i=0; i<aSz; i++) {
final GLEventListener l = a.getGLEventListener(0);
- final boolean initialized = a.getGLEventListenerInitState(l);
- aInit[i] = initialized;
+ aInit[i] = a.getGLEventListenerInitState(l);
aGLE[i] = a.removeGLEventListener( l );
- if( initialized ) {
- b.enqueue(new ReshapeGLEventListener(l));
- }
}
final int bSz = b.getGLEventListenerCount();
final GLEventListener[] bGLE = new GLEventListener[bSz];
final boolean[] bInit = new boolean[bSz];
for(int i=0; i<bSz; i++) {
final GLEventListener l = b.getGLEventListener(0);
- final boolean initialized = b.getGLEventListenerInitState(l);
- bInit[i] = initialized;
+ bInit[i] = b.getGLEventListenerInitState(l);
bGLE[i] = b.removeGLEventListener( l );
- if( initialized ) {
- a.enqueue(new ReshapeGLEventListener(l));
- }
}
- // switch context and trigger reshape
+ //
+ // trigger glFinish to sync GL ctx
+ //
+ a.enqueue(glFinish);
+ b.enqueue(glFinish);
+ a.display();
+ b.display();
+
+ //
+ // switch context and
+ // trigger GL-Viewport reset and reshape of all initialized GLEventListeners
+ //
b.setContext( a.setContext( b.getContext() ) );
+ a.enqueue(setViewport);
+ b.enqueue(setViewport);
+ for(int i=0; i<aSz; i++) {
+ if( aInit[i] ) {
+ b.enqueue(new ReshapeGLEventListener(aGLE[i]));
+ }
+ }
+ for(int i=0; i<bSz; i++) {
+ if( bInit[i] ) {
+ a.enqueue(new ReshapeGLEventListener(bGLE[i]));
+ }
+ }
+ a.enqueue(glFinish);
+ b.enqueue(glFinish);
a.display();
b.display();
@@ -188,6 +200,13 @@ public class GLDrawableUtil {
return true;
}
};
+ static GLRunnable glFinish = new GLRunnable() {
+ @Override
+ public boolean run(GLAutoDrawable drawable) {
+ drawable.getGL().glFinish();
+ return true;
+ }
+ };
private static class ReshapeGLEventListener implements GLRunnable {
private GLEventListener listener;