From 5ece52d5d7f4fd815199acd6cb0f4e6f586e8252 Mon Sep 17 00:00:00 2001 From: Steve Vaughan Date: Fri, 19 Nov 2010 11:03:02 -0500 Subject: Avoid sendDestroy mechanism in favor of immediate destroy using AnimatorControl to pause rendering. --- .../classes/com/jogamp/newt/opengl/GLWindow.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/newt') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 7c0384bd0..dfc2651e7 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -85,11 +85,30 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer { } public void windowDestroyNotify(WindowEvent e) { - if( !GLWindow.this.window.isSurfaceLockedByOtherThread() && !GLWindow.this.helper.isExternalAnimatorAnimating() ) { + // Is an animator thread perform rendering? + if (GLWindow.this.helper.isExternalAnimatorAnimating()) { + // Pause animations before initiating destroy. + GLAnimatorControl ctrl = GLWindow.this.helper + .getAnimator(); + ctrl.pause(); + destroy(); - } else { + + // Resume animations. + ctrl.resume(); + } + // Is the surface locked another thread? + else if (GLWindow.this.window + .isSurfaceLockedByOtherThread()) { + // Flag that destroy should be performed on the next + // attempt to display. sendDestroy = true; } + else { + // Without an external thread animating or locking the + // surface, we should be safe. + destroy (); + } } }); this.window.setLifecycleHook(new GLLifecycleHook()); -- cgit v1.2.3