From 9b35c57425b0a5f6b789b9b43a62a8b64be51d86 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 4 Jul 2012 18:02:11 +0200 Subject: GLAutoDrawable* refinement of abstraction / generalization - API Change! - GLAutoDrawable (compat change - recompile): - 'void invoke(boolean wait, GLRunnable glRunnable)' -> 'boolean invoke(boolean wait, GLRunnable glRunnable)' Allows notifying caller whether the task has been executed or at least enqueued. - GLAutoDrawable add 'GLEventListener removeGLEventListener(int index)' - This allow one to remove a specific GLEventListener and reusing it (return value). - GLDrawableImpl remove 'destroy()' to favor 'setRealized(false)' - Using more common code of GLAutoDrawableBase, i.e. GLPbufferImpl can use defaultDestroyOp(). - Removes redundancy of methods - GLAutoDrawableBase/Delegate - better 'default' names to emphasize it's purpose, adding API doc - includes more generic functionality - defaultWindowDestroyNotify() - defaultDestroyOp() - TestGLAutoDrawableDelegateNEWT demonstrates a simple example w/ all window events handled. - Fix TestParenting01cSwingAWT's threading use (gl disturbance thread) --- .../classes/com/jogamp/newt/opengl/GLWindow.java | 42 +++------------------- 1 file changed, 4 insertions(+), 38 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 6a328ed07..96baab3ae 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -53,7 +53,6 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.newt.WindowImpl; @@ -109,37 +108,17 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { - defaultRepaintOp(); + defaultWindowRepaintOp(); } @Override public void windowResized(WindowEvent e) { - defaultReshapeOp(); + defaultWindowResizedOp(); } @Override public void windowDestroyNotify(WindowEvent e) { - if( WindowClosingMode.DISPOSE_ON_CLOSE == GLWindow.this.getDefaultCloseOperation() ) { - // Is an animator thread perform rendering? - if (GLWindow.this.helper.isExternalAnimatorRunning()) { - // Pause animations before initiating safe destroy. - final GLAnimatorControl ctrl = GLWindow.this.helper.getAnimator(); - boolean isPaused = ctrl.pause(); - destroy(); - if(isPaused) { - ctrl.resume(); - } - } else if (GLWindow.this.window.isWindowLockedByOtherThread()) { - // Window is locked by another thread - // 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 are safe. - destroy (); - } - } + defaultWindowDestroyNotifyOp(); } }); this.window.setLifecycleHook(new GLLifecycleHook()); @@ -453,20 +432,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind //e1.printStackTrace(); } - if( window.isNativeValid() && null != drawable && drawable.isRealized() ) { - if( null != context && context.isCreated() ) { - // Catch dispose GLExceptions by GLEventListener, just 'print' them - // so we can continue with the destruction. - try { - helper.disposeGL(GLWindow.this, drawable, context, null); - } catch (GLException gle) { - gle.printStackTrace(); - } - } - drawable.setRealized(false); - } - context = null; - drawable = null; + defaultDestroyOp(); if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.destroy() "+Thread.currentThread()+", fin"); -- cgit v1.2.3