summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/demos/applets/JOGLNewtApplet1Run.java85
-rwxr-xr-xsrc/demos/applets/JOGLNewtAppletBase.java9
2 files changed, 80 insertions, 14 deletions
diff --git a/src/demos/applets/JOGLNewtApplet1Run.java b/src/demos/applets/JOGLNewtApplet1Run.java
index 0a5311b..b321c14 100755
--- a/src/demos/applets/JOGLNewtApplet1Run.java
+++ b/src/demos/applets/JOGLNewtApplet1Run.java
@@ -11,13 +11,55 @@ 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. */
-
+/**
+ * Simple GLEventListener deployment as an applet using JOGL. This demo must be
+ * referenced from a web page via an <applet> tag.
+ *
+ * <p>
+ * Example of an applet tag using GearsES2 within the applet area (normal case):
+ * <pre>
+ &lt;applet width=100 height=100&gt;
+ &lt;param name="java_arguments" value="-Dsun.java2d.noddraw=true"&gt;
+ &lt;param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"&gt;
+ &lt;param name="gl_profile" value="GL2"&gt;
+ &lt;param name="gl_swap_interval" value="1"&gt;
+ &lt;param name="gl_debug" value="false"&gt;
+ &lt;param name="gl_trace" value="false"&gt;
+ &lt;param name="jnlp_href" value="jogl-newt-applet-runner.jnlp"&gt;
+ &lt;/applet&gt;Hello Gears !
+ * </pre>
+ * </p>
+ *
+ * <p>
+ * Example of an applet tag using GearsES2 in an undecorated, translucent and always-on-top window:
+ * <pre>
+ &lt;applet width=1 height=1&gt;
+ &lt;param name="java_arguments" value="-Dsun.java2d.noddraw=true"&gt;
+ &lt;param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"&gt;
+ &lt;param name="gl_profile" value="GL2"&gt;
+ &lt;param name="gl_swap_interval" value="1"&gt;
+ &lt;param name="gl_undecorated" value="true"&gt;
+ &lt;param name="gl_alwaysontop" value="true"&gt;
+ &lt;param name="gl_opaque" value="false"&gt;
+ &lt;param name="gl_dx" value="10"&gt;
+ &lt;param name="gl_dy" value="0"&gt;
+ &lt;param name="gl_width" value="100"&gt;
+ &lt;param name="gl_height" value="100"&gt;
+ &lt;param name="gl_debug" value="false"&gt;
+ &lt;param name="gl_trace" value="false"&gt;
+ &lt;param name="jnlp_href" value="jogl-newt-applet-runner.jnlp"&gt;
+ &lt;/applet&gt;Hello Gears !
+ * </pre>
+ * </p>
+ */
+@SuppressWarnings("serial")
public class JOGLNewtApplet1Run extends Applet {
GLWindow glWindow;
NewtCanvasAWT newtCanvasAWT;
JOGLNewtAppletBase base;
+ /** if valid glStandalone:=true (own window) ! */
+ int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE;
+ boolean glStandalone = false;
public void init() {
if(!(this instanceof Container)) {
@@ -30,19 +72,30 @@ public class JOGLNewtApplet1Run extends Applet {
int glSwapInterval=0;
boolean glDebug=false;
boolean glTrace=false;
- String tmp;
+ boolean glUndecorated=false;
+ boolean glAlwaysOnTop=false;
+ boolean glOpaque=true;
try {
glEventListenerClazzName = getParameter("gl_event_listener_class");
glProfileName = getParameter("gl_profile");
glSwapInterval = JOGLNewtAppletBase.str2Int(getParameter("gl_swap_interval"), glSwapInterval);
glDebug = JOGLNewtAppletBase.str2Bool(getParameter("gl_debug"), glDebug);
glTrace = JOGLNewtAppletBase.str2Bool(getParameter("gl_trace"), glTrace);
+ glUndecorated = JOGLNewtAppletBase.str2Bool(getParameter("gl_undecorated"), glUndecorated);
+ glAlwaysOnTop = JOGLNewtAppletBase.str2Bool(getParameter("gl_alwaysontop"), glAlwaysOnTop);
+ glOpaque = JOGLNewtAppletBase.str2Bool(getParameter("gl_opaque"), glOpaque);
+ glXd = JOGLNewtAppletBase.str2Int(getParameter("gl_dx"), glXd);
+ glYd = JOGLNewtAppletBase.str2Int(getParameter("gl_dy"), glYd);
+ glWidth = JOGLNewtAppletBase.str2Int(getParameter("gl_width"), glWidth);
+ glHeight = JOGLNewtAppletBase.str2Int(getParameter("gl_height"), glHeight);
} catch (Exception e) {
e.printStackTrace();
}
if(null==glEventListenerClazzName) {
throw new RuntimeException("No applet parameter 'gl_event_listener_class'");
}
+ glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
+
base = new JOGLNewtAppletBase(glEventListenerClazzName,
glSwapInterval,
glDebug,
@@ -51,10 +104,17 @@ public class JOGLNewtApplet1Run extends Applet {
try {
GLProfile.initSingleton(false);
GLCapabilities caps = new GLCapabilities(GLProfile.get(glProfileName));
+ caps.setBackgroundOpaque(glOpaque);
glWindow = GLWindow.create(caps);
- newtCanvasAWT = new NewtCanvasAWT(glWindow);
- container.setLayout(new BorderLayout());
- container.add(newtCanvasAWT, BorderLayout.CENTER);
+ glWindow.setUndecorated(glUndecorated);
+ glWindow.setAlwaysOnTop(glAlwaysOnTop);
+ if(glStandalone) {
+ newtCanvasAWT = null;
+ } else {
+ newtCanvasAWT = new NewtCanvasAWT(glWindow);
+ container.setLayout(new BorderLayout());
+ container.add(newtCanvasAWT, BorderLayout.CENTER);
+ }
base.init(glWindow);
if(base.isValid()) {
GLEventListener glEventListener = base.getGLEventListener();
@@ -75,6 +135,11 @@ public class JOGLNewtApplet1Run extends Applet {
}
public void start() {
+ if(glStandalone) {
+ glWindow.setSize(glWidth, glHeight);
+ final java.awt.Point p0 = this.getLocationOnScreen();
+ glWindow.setPosition(p0.x+glXd, p0.y+glYd);
+ }
base.start();
}
@@ -84,8 +149,10 @@ public class JOGLNewtApplet1Run extends Applet {
public void destroy() {
glWindow.setVisible(false); // hide 1st
- glWindow.reparentWindow(null); // get out of newtCanvasAWT
- this.remove(newtCanvasAWT); // remove newtCanvasAWT
+ if(!glStandalone) {
+ glWindow.reparentWindow(null); // get out of newtCanvasAWT
+ this.remove(newtCanvasAWT); // remove newtCanvasAWT
+ }
base.destroy(); // destroy glWindow unrecoverable
base=null;
}
diff --git a/src/demos/applets/JOGLNewtAppletBase.java b/src/demos/applets/JOGLNewtAppletBase.java
index 5f85715..c8c6ac6 100755
--- a/src/demos/applets/JOGLNewtAppletBase.java
+++ b/src/demos/applets/JOGLNewtAppletBase.java
@@ -60,7 +60,7 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo
Object instance = null;
try {
- Class clazz = Class.forName(clazzName);
+ Class<?> clazz = Class.forName(clazzName);
instance = clazz.newInstance();
} catch (Throwable t) {
t.printStackTrace();
@@ -139,9 +139,6 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo
glWindow.setVisible(true);
glAnimator.start();
awtParent = glWindow.getParent();
- if(null==awtParent) {
- throw new RuntimeException("Parent of GLWindow is null: "+glWindow);
- }
}
}
@@ -209,7 +206,9 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo
glWindow.setUndecorated(!glWindow.isUndecorated());
} if(e.getKeyChar()=='f') {
glWindow.setFullscreen(!glWindow.isFullscreen());
- } else if(e.getKeyChar()=='r') {
+ } else if(e.getKeyChar()=='a') {
+ glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
+ } else if(e.getKeyChar()=='r' && null!=awtParent) {
if(null == glWindow.getParent()) {
glWindow.reparentWindow(awtParent);
} else {