diff options
Diffstat (limited to 'src/demos/applets')
-rwxr-xr-x | src/demos/applets/GearsApplet.java | 4 | ||||
-rwxr-xr-x | src/demos/applets/GearsJOALApplet.java | 4 | ||||
-rwxr-xr-x | src/demos/applets/JOGLNewtApplet1Run.java | 31 | ||||
-rwxr-xr-x | src/demos/applets/JOGLNewtAppletBase.java | 14 |
4 files changed, 23 insertions, 30 deletions
diff --git a/src/demos/applets/GearsApplet.java b/src/demos/applets/GearsApplet.java index dd5183b..811eafe 100755 --- a/src/demos/applets/GearsApplet.java +++ b/src/demos/applets/GearsApplet.java @@ -5,8 +5,8 @@ import java.awt.*; import demos.gears.Gears; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.FPSAnimator; +import javax.media.opengl.GLAnimatorControl; /** Shows how to deploy an applet using JOGL. This demo must be referenced from a web page via an <applet> tag. */ @@ -15,7 +15,7 @@ public class GearsApplet extends Applet { static { GLProfile.initSingleton(); } - private Animator animator; + private GLAnimatorControl animator; public void init() { setLayout(new BorderLayout()); diff --git a/src/demos/applets/GearsJOALApplet.java b/src/demos/applets/GearsJOALApplet.java index 54ee99f..bf36e1b 100755 --- a/src/demos/applets/GearsJOALApplet.java +++ b/src/demos/applets/GearsJOALApplet.java @@ -6,11 +6,11 @@ import java.awt.EventQueue; import java.awt.GridLayout; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.FPSAnimator; import javax.swing.JPanel; import net.java.games.joal.util.ALut; import demos.devmaster.lesson1.SingleStaticSource; +import javax.media.opengl.GLAnimatorControl; /** Shows how to deploy an applet using both JOGL and JOAL. This demo must be referenced from a web page via an <applet> tag. */ @@ -19,7 +19,7 @@ public class GearsJOALApplet extends Applet { static { GLProfile.initSingleton(); } - private Animator animator; + private GLAnimatorControl animator; public void init() { setLayout(new GridLayout(1, 2)); diff --git a/src/demos/applets/JOGLNewtApplet1Run.java b/src/demos/applets/JOGLNewtApplet1Run.java index 0490120..df42da6 100755 --- a/src/demos/applets/JOGLNewtApplet1Run.java +++ b/src/demos/applets/JOGLNewtApplet1Run.java @@ -7,15 +7,17 @@ import java.awt.event.MouseMotionListener; import java.awt.event.KeyListener; import javax.media.opengl.*; -import javax.media.nativewindow.*; -import com.jogamp.newt.*; +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import java.awt.BorderLayout; /** Shows how to deploy an applet using JOGL. This demo must be referenced from a web page via an <applet> tag. */ public class JOGLNewtApplet1Run extends Applet { + GLWindow glWindow; + NewtCanvasAWT newtCanvasAWT; JOGLNewtAppletBase base; - Window nWindow = null; public void init() { if(!(this instanceof Container)) { @@ -48,15 +50,11 @@ public class JOGLNewtApplet1Run extends Applet { try { 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 - 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) { - base.init(nWindow); - } + glWindow = GLWindow.create(caps); + newtCanvasAWT = new NewtCanvasAWT(glWindow); + container.setLayout(new BorderLayout()); + container.add(newtCanvasAWT, BorderLayout.CENTER); + base.init(glWindow); if(base.isValid()) { GLEventListener glEventListener = base.getGLEventListener(); @@ -84,12 +82,11 @@ public class JOGLNewtApplet1Run extends Applet { } public void destroy() { - base.destroy(false); // no dispose events + glWindow.setVisible(false); // hide 1st + glWindow.reparentWindow(null); // get out of newtCanvasAWT + this.remove(newtCanvasAWT); // remove newtCanvasAWT + base.destroy(true); // destroy glWindow unrecoverable base=null; - if(null!=nWindow) { - nWindow.destroy(); - nWindow=null; - } } } diff --git a/src/demos/applets/JOGLNewtAppletBase.java b/src/demos/applets/JOGLNewtAppletBase.java index 4b7377d..e07f34f 100755 --- a/src/demos/applets/JOGLNewtAppletBase.java +++ b/src/demos/applets/JOGLNewtAppletBase.java @@ -2,7 +2,6 @@ package demos.applets; import java.lang.reflect.*; -import com.jogamp.newt.*; import com.jogamp.newt.event.*; import com.jogamp.newt.opengl.GLWindow; @@ -91,16 +90,14 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo return false; } - public void init(Window nWindow) { - init(Thread.currentThread().getThreadGroup(), nWindow); + public void init(GLWindow glWindow) { + init(Thread.currentThread().getThreadGroup(), glWindow); } - public void init(ThreadGroup tg, Window nWindow) { + public void init(ThreadGroup tg, GLWindow glWindow) { glEventListener = createInstance(glEventListenerClazzName); try { - glWindow = GLWindow.create(nWindow); - if(!setField(glEventListener, "window", glWindow)) { setField(glEventListener, "glWindow", glWindow); } @@ -147,8 +144,7 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo } } - /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */ - public void destroy(boolean sendDisposeEvent) { + public void destroy(boolean unrecoverable) { isValid = false; if(null!=glAnimator) { glAnimator.stop(); @@ -156,7 +152,7 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo glAnimator=null; } if(null!=glWindow) { - glWindow.destroy(sendDisposeEvent); + glWindow.destroy(unrecoverable); glWindow=null; } } |