diff options
author | Kenneth Russel <[email protected]> | 2005-09-09 07:08:45 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-09-09 07:08:45 +0000 |
commit | ffb098e3eed864346f1bd9f53021b17f9148da49 (patch) | |
tree | c95f36b4e25fb8facace3e8ead0827e61a80093e /src/demos/vertexProgWarp/VertexProgWarp.java | |
parent | 6988570ed0a3ffa8f6d544cdb245cb7f0e77885c (diff) |
Refactored demos to mostly subclass common Demo superclass providing
shutdown capabilities. Moved DemoListener to demos.common package.
Added ManipManager removal code to demos using manipulators or
ExaminerViewer to fix memory leak when run in JRefract harness. Added
workaround for another seeming memory leak when run under current JDK
1.6 due to java.awt.Component now being finalizable and keeping data
alive longer than previously. Made ManipManager.unregisterWindow more
lenient with respect to null or invalid arguments.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JSR-231@122 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/vertexProgWarp/VertexProgWarp.java')
-rw-r--r-- | src/demos/vertexProgWarp/VertexProgWarp.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/demos/vertexProgWarp/VertexProgWarp.java b/src/demos/vertexProgWarp/VertexProgWarp.java index c6e177a..e740a64 100644 --- a/src/demos/vertexProgWarp/VertexProgWarp.java +++ b/src/demos/vertexProgWarp/VertexProgWarp.java @@ -42,6 +42,7 @@ import javax.swing.*; import javax.media.opengl.*; import com.sun.opengl.utils.*; +import demos.common.*; import demos.util.*; import gleem.*; import gleem.linalg.*; @@ -55,11 +56,12 @@ import gleem.linalg.*; Ported to Java by Kenneth Russell */ -public class VertexProgWarp implements GLEventListener { +public class VertexProgWarp extends Demo { private Frame frame; private Animator animator; private volatile boolean quit; + private GLAutoDrawable drawable; private DurationTimer timer = new DurationTimer(); private boolean firstRender = true; private int frameCount; @@ -111,11 +113,6 @@ public class VertexProgWarp implements GLEventListener { titleSetter = setter; } - public void setDemoListener(DemoListener listener) { - demoListener = listener; - } - - private DemoListener demoListener; private TitleSetter titleSetter; private boolean initComplete; @@ -158,7 +155,7 @@ public class VertexProgWarp implements GLEventListener { try { initExtension(gl, "GL_ARB_vertex_program"); } catch (RuntimeException e) { - demoListener.shutdownDemo(); + shutdownDemo(); throw(e); } @@ -211,6 +208,7 @@ public class VertexProgWarp implements GLEventListener { // Register the window with the ManipManager ManipManager manager = ManipManager.getManipManager(); manager.registerWindow(drawable); + this.drawable = drawable; viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); viewer.setNoAltKeyMode(true); @@ -301,13 +299,18 @@ public class VertexProgWarp implements GLEventListener { //---------------------------------------------------------------------- // Internals only below this point // + public void shutdownDemo() { + ManipManager.getManipManager().unregisterWindow(drawable); + super.shutdownDemo(); + } + private void initExtension(GL gl, String glExtensionName) { if (!gl.isExtensionAvailable(glExtensionName)) { final String message = "OpenGL extension \"" + glExtensionName + "\" not available"; new Thread(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE); - demoListener.shutdownDemo(); + shutdownDemo(); } }).start(); throw new RuntimeException(message); @@ -363,7 +366,7 @@ public class VertexProgWarp implements GLEventListener { case KeyEvent.VK_ESCAPE: case KeyEvent.VK_Q: - demoListener.shutdownDemo(); + shutdownDemo(); return; case KeyEvent.VK_W: @@ -440,7 +443,7 @@ public class VertexProgWarp implements GLEventListener { try { Triceratops.drawObject(gl); } catch (IOException e) { - demoListener.shutdownDemo(); + shutdownDemo(); throw new RuntimeException(e); } break; |