summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-15 13:26:06 +0200
committerSven Gothel <[email protected]>2011-09-15 13:26:06 +0200
commitbaa88fe536b0b8a70cadabe5412120a9168dec11 (patch)
treead76ec6b15e41bbfbdba1e51fc5604bbe63393c7 /src
parent42129070c5262c7f6c881c41a70fcb4550c33efa (diff)
JOGLNewtAppletBase: Use proper context ClassLoader; Add ElektronenMultiplizierer (NEWT Applet Runner)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java25
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java9
3 files changed, 44 insertions, 11 deletions
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);