diff options
author | Sven Gothel <[email protected]> | 2011-09-15 13:26:06 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-15 13:26:06 +0200 |
commit | baa88fe536b0b8a70cadabe5412120a9168dec11 (patch) | |
tree | ad76ec6b15e41bbfbdba1e51fc5604bbe63393c7 | |
parent | 42129070c5262c7f6c881c41a70fcb4550c33efa (diff) |
JOGLNewtAppletBase: Use proper context ClassLoader; Add ElektronenMultiplizierer (NEWT Applet Runner)
7 files changed, 98 insertions, 21 deletions
diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html new file mode 100644 index 000000000..5c0c088cb --- /dev/null +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html @@ -0,0 +1,42 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> +<title>Demoscene Passivist's Elektronen-Multiplizierer</title> +</head> +<body BGCOLOR="#ffffff"> + +<P> +Demoscene Passivist's Elektronen-Multiplizierer +</P> + +<P> +<applet width=640 height=480> + <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> + <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer"> + <param name="gl_profile" value="GL2ES2"> + <param name="gl_swap_interval" value="1"> + <param name="gl_debug" value="false"> + <param name="gl_trace" value="false"> + <param name="jnlp_href" value="jogl-applet-runner-newt.jnlp"> +</applet> +</P> + +<P> +ElektronenMultiplizierer Keys:<br> +<ul> + <li> Cursor-Left - time backwards</li> + <li> Cursor-Right - time forward</li> +</ul> +</P> +<P> +JOGL NEWT JNLP Applet Runner Special Keys:<br> +<ul> + <li> d - toggle decoration </li> + <li> f - toggle fullscreen </li> + <li> r - in/out browser window </li> + <li> a - on/off always-on-top </li> +</ul> +</P> + +</body> +</html> diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal.html b/jnlp-files/jogl-applet-runner-newt-gears-normal.html index 126ebea08..c0720933d 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal.html @@ -10,7 +10,7 @@ <applet width=200 height=200> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"> - <param name="gl_profile" value="GL2"> + <param name="gl_profile" value="GL2ES2"> <param name="gl_swap_interval" value="1"> <param name="gl_debug" value="false"> <param name="gl_trace" value="false"> diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special.html b/jnlp-files/jogl-applet-runner-newt-gears-special.html index 3472e62ec..033d15b6f 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special.html @@ -6,33 +6,34 @@ <body BGCOLOR="#ffffff"> <P> - +JOGL NEWT JNLP Applet Runner Special Keys: <applet width=1 height=1> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"> - <param name="gl_profile" value="GL2"> + <param name="gl_profile" value="GL2ES2"> <param name="gl_swap_interval" value="1"> <param name="gl_undecorated" value="true"> <param name="gl_opaque" value="false"> <param name="gl_alwaysontop" value="true"> - <param name="gl_dx" value="10"> - <param name="gl_dy" value="0"> + <param name="gl_dx" value="0"> + <param name="gl_dy" value="-50"> <param name="gl_width" value="200"> <param name="gl_height" value="200"> <param name="gl_debug" value="false"> <param name="gl_trace" value="false"> <param name="jnlp_href" value="jogl-applet-runner-newt.jnlp"> -</applet>Hello Gears ! - -</P> -<P> -JOGL NEWT JNLP Applet Runner Special Keys:<br> +</applet> Hello Gears - Hello Gears - Hello Gears +<br> <ul> <li> d - toggle decoration </li> <li> f - toggle fullscreen </li> <li> r - in/out browser window </li> <li> a - on/off always-on-top </li> </ul> +Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text<br> +Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text<br> +Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text<br> +Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text<br> </P> diff --git a/jnlp-files/jogl-test-applets.html b/jnlp-files/jogl-test-applets.html index 60e8f8fe3..ba9733d24 100644 --- a/jnlp-files/jogl-test-applets.html +++ b/jnlp-files/jogl-test-applets.html @@ -22,6 +22,7 @@ <ul> <li><a href="jogl-applet-runner-newt-gears-normal.html">GearsES2 in Applet Area (normal)</a></li> <li><a href="jogl-applet-runner-newt-gears-special.html">GearsES2 translucent over pager (special)</a></li> + <li><a href="jogl-applet-runner-newt-ElektronenMultiplizierer.html">Demoscene Passivist's ElektronenMultiplizierer</a></li> </ul> </p> diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 97142b32b..9d3b8185f 100755 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -1,6 +1,8 @@ package com.jogamp.newt.awt.applet; import java.lang.reflect.*; +import java.security.AccessController; +import java.security.PrivilegedAction; import javax.media.nativewindow.NativeWindow; import javax.media.opengl.*; @@ -56,11 +58,22 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo return def; } - public static GLEventListener createInstance(String clazzName) { + public static GLEventListener createInstance(final String clazzName) { Object instance = null; try { - Class<?> clazz = Class.forName(clazzName); + final Class<?> clazz = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() { + public Class<?> run() { + final ClassLoader cl = Thread.currentThread().getContextClassLoader(); + Class<?> clazz = null; + try { + clazz = Class.forName(clazzName, false, cl); + } catch (Throwable t) { + t.printStackTrace(); + } + return clazz; + } + }); instance = clazz.newInstance(); } catch (Throwable t) { t.printStackTrace(); @@ -97,9 +110,13 @@ public class JOGLNewtAppletBase extends WindowAdapter implements KeyListener, Mo } public void init(ThreadGroup tg, GLWindow glWindow) { + isValid = false; this.glWindow = glWindow; glEventListener = createInstance(glEventListenerClazzName); + if(null == glEventListener) { + return; + } try { if(!setField(glEventListener, "window", glWindow)) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java index 0e43a71b1..6fec015b0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java @@ -42,6 +42,9 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLUniformData; import com.jogamp.common.nio.Buffers; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -153,6 +156,17 @@ public class ElektronenMultiplizierer implements GLEventListener { public boolean wantsFrameSkip() { return mCommandLineParameter_FrameSkip; } public boolean usesFullScreenMode() { return mUsesFullScreenMode; } + class TimeShiftKeys extends KeyAdapter { + public void keyPressed(KeyEvent e) { + if(KeyEvent.VK_RIGHT == e.getKeyCode()) { + skipFrames(120); + } else if(KeyEvent.VK_LEFT == e.getKeyCode()) { + skipFrames(-120); + } + } + } + TimeShiftKeys timeShiftKeys; + public ElektronenMultiplizierer ( String inBaseRoutineClassName, boolean inMultiSampling, @@ -187,6 +201,11 @@ public class ElektronenMultiplizierer implements GLEventListener { mFrameSkipAverageFramerateTimeStart = 0; mFrameCounter = 0; skipFrames(startFrame); + timeShiftKeys = new TimeShiftKeys(); + } + + public ElektronenMultiplizierer() { + this(null, false, -1, false, -1.0f, false, true, 30, 0); } /** @@ -204,6 +223,12 @@ public class ElektronenMultiplizierer implements GLEventListener { } public void init(GLAutoDrawable drawable) { + if(drawable instanceof GLWindow) { + final GLWindow glw = (GLWindow) drawable; + if ( glw.getKeyListener(0) != timeShiftKeys ) { + glw.addKeyListener(0, timeShiftKeys); + } + } GL2ES2 gl = drawable.getGL().getGL2ES2(); gl.setSwapInterval(1); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java index 26917107d..d9cee4fdf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java @@ -114,15 +114,6 @@ public class TestElektronenMultipliziererNEWT extends UITestCase { } }.start(); } } - public void keyPressed(KeyEvent e) { - if(KeyEvent.VK_RIGHT == e.getKeyCode()) { - demo.skipFrames(120); - System.err.println("->"); - } else if(KeyEvent.VK_LEFT == e.getKeyCode()) { - demo.skipFrames(-120); - System.err.println("<-"); - } - } }); glWindow.setVisible(true); |