summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-02-28 19:49:12 +0100
committerSven Gothel <[email protected]>2011-02-28 19:49:12 +0100
commita65516db85582ac3391b4a3d978ac07b9e1e6951 (patch)
tree0fb4669f50ad1533c264ea4e13fd52c2b3284205 /src
parent5681c25cfd4c7abce7d653910c9aa7a4e989057e (diff)
unit tests: Gears, TestGearsNEWT, WindowImplAccess
Gears (add cursor rotation) TestGearsNEWT (add decoraction toggle 'd') WindowImplAccess NEWT Closing tests .. programmatical close on EDT, which simulates 1:1 native closing operation.
Diffstat (limited to 'src')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/Gears.java20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java6
-rw-r--r--src/test/jogamp/newt/WindowImplAccess.java7
3 files changed, 31 insertions, 2 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/Gears.java
index dd28b4e40..0dcf6bec8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/Gears.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/Gears.java
@@ -107,14 +107,17 @@ public class Gears implements GLEventListener {
gl.glEnable(GL2.GL_NORMALIZE);
// MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
- MouseListener gearsMouse = new GearsMouseAdapter();
+ MouseListener gearsMouse = new GearsMouseAdapter();
+ KeyListener gearsKeys = new GearsKeyAdapter();
if (drawable instanceof Window) {
Window window = (Window) drawable;
window.addMouseListener(gearsMouse);
+ window.addKeyListener(gearsKeys);
} else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
java.awt.Component comp = (java.awt.Component) drawable;
new AWTMouseAdapter(gearsMouse).addTo(comp);
+ new AWTKeyAdapter(gearsKeys).addTo(comp);
}
}
@@ -309,6 +312,21 @@ public class Gears implements GLEventListener {
gl.glEnd();
}
+ class GearsKeyAdapter extends KeyAdapter {
+ public void keyPressed(KeyEvent e) {
+ int kc = e.getKeyCode();
+ if(KeyEvent.VK_LEFT == kc) {
+ view_roty -= 1;
+ } else if(KeyEvent.VK_RIGHT == kc) {
+ view_roty += 1;
+ } else if(KeyEvent.VK_UP == kc) {
+ view_rotx -= 1;
+ } else if(KeyEvent.VK_DOWN == kc) {
+ view_rotx += 1;
+ }
+ }
+ }
+
class GearsMouseAdapter extends MouseAdapter {
public void mousePressed(MouseEvent e) {
prevMouseX = e.getX();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java
index 588fe725f..5433a5ba2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java
@@ -88,6 +88,12 @@ public class TestGearsNEWT extends UITestCase {
GLWindow win = (GLWindow)drawable;
win.setFullscreen(!win.isFullscreen());
} });
+ } else if(e.getKeyChar()=='d') {
+ f_glWindow.invoke(false, new GLRunnable() {
+ public void run(GLAutoDrawable drawable) {
+ GLWindow win = (GLWindow)drawable;
+ win.setUndecorated(!win.isUndecorated());
+ } });
}
}
});
diff --git a/src/test/jogamp/newt/WindowImplAccess.java b/src/test/jogamp/newt/WindowImplAccess.java
index 848e58227..76d0dc050 100644
--- a/src/test/jogamp/newt/WindowImplAccess.java
+++ b/src/test/jogamp/newt/WindowImplAccess.java
@@ -45,7 +45,12 @@ public class WindowImplAccess {
} else {
throw new RuntimeException("Given Window not a GLWindow, not WindowImpl, but "+win.getClass());
}
- winImpl.windowDestroyNotify();
+ final WindowImpl winImplF = winImpl;
+ winImplF.runOnEDTIfAvail(true, new Runnable() {
+ public void run() {
+ winImplF.windowDestroyNotify();
+ }
+ });
}
}