diff options
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/Gears.java | 20 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/newt/TestGearsNEWT.java | 6 |
2 files changed, 25 insertions, 1 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()); + } }); } } }); |