summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-12 02:11:15 -0700
committerSven Gothel <[email protected]>2009-10-12 02:11:15 -0700
commit93a269bccf608baa5e7f8b7ec13ba823b8b2f086 (patch)
treece7506646e3100b94a8380528ca42da1ec0c3350
parentd1a53b3ba93789aea1c37d042bc722a2a9c052d9 (diff)
JOGLNewtAppletBase et al - no dispose event at destruction, since it's critical within a browser
-rwxr-xr-xsrc/demos/applets/JOGLNewtApplet1Run.java12
-rwxr-xr-xsrc/demos/applets/JOGLNewtAppletBase.java5
-rwxr-xr-xsrc/demos/es1/RedSquare.java8
-rwxr-xr-xsrc/demos/es2/RedSquare.java7
4 files changed, 24 insertions, 8 deletions
diff --git a/src/demos/applets/JOGLNewtApplet1Run.java b/src/demos/applets/JOGLNewtApplet1Run.java
index f839387..e3696ab 100755
--- a/src/demos/applets/JOGLNewtApplet1Run.java
+++ b/src/demos/applets/JOGLNewtApplet1Run.java
@@ -16,6 +16,7 @@ import com.sun.javafx.newt.opengl.*;
public class JOGLNewtApplet1Run extends Applet {
JOGLNewtAppletBase base;
+ Window nWindow = null;
public void init() {
if(!(this instanceof Container)) {
@@ -51,8 +52,8 @@ public class JOGLNewtApplet1Run extends Applet {
GLCapabilities caps = new GLCapabilities(GLProfile.get(glProfileName));
Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
- Window nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, new Object[] { container },
- nScreen, caps, true /* undecorated */);
+ nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, new Object[] { container },
+ nScreen, caps, true /* undecorated */);
// nWindow.setPosition(x, y);
// nWindow.setSize(container.getWidth(), container.getHeight());
if(null!=nWindow) {
@@ -85,7 +86,12 @@ public class JOGLNewtApplet1Run extends Applet {
}
public void destroy() {
- base.destroy();
+ base.destroy(false); // no dispose events
+ base=null;
+ if(null!=nWindow) {
+ nWindow.destroy();
+ nWindow=null;
+ }
}
}
diff --git a/src/demos/applets/JOGLNewtAppletBase.java b/src/demos/applets/JOGLNewtAppletBase.java
index 12d2af7..428e0b2 100755
--- a/src/demos/applets/JOGLNewtAppletBase.java
+++ b/src/demos/applets/JOGLNewtAppletBase.java
@@ -151,7 +151,8 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis
}
}
- public void destroy() {
+ /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
+ public void destroy(boolean sendDisposeEvent) {
isValid = false;
if(null!=glAnimator) {
glAnimator.stop();
@@ -159,7 +160,7 @@ public class JOGLNewtAppletBase implements WindowListener, KeyListener, MouseLis
glAnimator=null;
}
if(null!=glWindow) {
- glWindow.destroy(true); // deep, incl. Screen and Display
+ glWindow.destroy(sendDisposeEvent);
glWindow=null;
}
}
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index 026e1c2..5f573f8 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -17,6 +17,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
public static boolean glDebugEmu = false;
public static boolean glDebug = false ;
public static boolean glTrace = false ;
+ public Window nWindow = null;
public GLWindow window;
private GLProfile glp;
private GLU glu;
@@ -110,7 +111,6 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
try {
GLCapabilities caps = new GLCapabilities(glp);
- Window nWindow = null;
if(0!=(type&USE_AWT)) {
Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
@@ -167,11 +167,15 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
try {
System.out.println("SHUTDOWN "+Thread.currentThread()+" START");
// Shut things down cooperatively
- window.destroy(true);
+ window.destroy();
if(oneThread) {
window.getFactory().shutdown();
}
window = null;
+ if(null!=nWindow) {
+ nWindow.destroy();
+ nWindow=null;
+ }
System.out.println("SHUTDOWN "+Thread.currentThread()+" FIN");
} catch (Throwable t) {
t.printStackTrace();
diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java
index be7e7f5..65f70c2 100755
--- a/src/demos/es2/RedSquare.java
+++ b/src/demos/es2/RedSquare.java
@@ -13,6 +13,7 @@ import com.sun.javafx.newt.opengl.*;
public class RedSquare extends Thread implements WindowListener, KeyListener, MouseListener, GLEventListener {
+ public Window nWindow = null;
public GLWindow window;
private GLProfile glp;
private boolean quit = false;
@@ -98,7 +99,6 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
try {
GLCapabilities caps = new GLCapabilities(glp);
- Window nWindow = null;
if(0!=(type&USE_AWT)) {
Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
@@ -147,6 +147,11 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
if(oneThread) {
window.getFactory().shutdown();
}
+ window = null;
+ if(null!=nWindow) {
+ nWindow.destroy();
+ nWindow=null;
+ }
System.out.println("SHUTDOWN "+Thread.currentThread()+" cleanly");
} catch (Throwable t) {
t.printStackTrace();