From: <eli...@us...> - 2006-11-19 16:24:21
|
Revision: 2663 http://svn.sourceforge.net/java-game-lib/?rev=2663&view=rev Author: elias_naur Date: 2006-11-19 08:24:18 -0800 (Sun, 19 Nov 2006) Log Message: ----------- AWTInputAdapter.destroy() now destroys the Keyboard and Mouse to mimic the behaviour of Display.destroy() more closely. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2006-11-19 13:33:45 UTC (rev 2662) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2006-11-19 16:24:18 UTC (rev 2663) @@ -92,6 +92,8 @@ if (awt_input != null) { awt_input.destroy(); awt_input = null; + Mouse.destroy(); + Keyboard.destroy(); } } } Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2006-11-19 13:33:45 UTC (rev 2662) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2006-11-19 16:24:18 UTC (rev 2663) @@ -140,18 +140,25 @@ + (fps / (timeUsed / 1000f))); fps = 0; } - Mouse.poll(); - while (Mouse.next()) { - view_roty += Mouse.getEventDX()*.1; - view_rotx -= Mouse.getEventDY()*.1; + if (Mouse.isCreated()) { + Mouse.poll(); + while (Mouse.next()) { + view_roty += Mouse.getEventDX()*.1; + view_rotx -= Mouse.getEventDY()*.1; + } } - Keyboard.poll(); - while (Keyboard.next()) { + if (Keyboard.isCreated()) { + Keyboard.poll(); + } + while (Keyboard.isCreated() && Keyboard.next()) { if (Keyboard.getEventKeyState()) { switch (Keyboard.getEventKey()) { case Keyboard.KEY_ESCAPE: System.exit(0); break; + case Keyboard.KEY_H: + AWTInputAdapter.destroy(); + break; case Keyboard.KEY_G: Mouse.setGrabbed(!Mouse.isGrabbed()); break; @@ -162,14 +169,16 @@ if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE) System.out.println("Typed: " + Keyboard.getEventCharacter()); } - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) - view_rotx -= .1; - else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) - view_rotx += .1; - if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) - view_roty -= .1; - else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) - view_roty += .1; + if (Keyboard.isCreated()) { + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) + view_rotx -= .1; + else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) + view_rotx += .1; + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) + view_roty -= .1; + else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) + view_roty += .1; + } } }); addWindowListener(new WindowAdapter() { @@ -225,7 +234,7 @@ GL11.glMatrixMode(GL11.GL_PROJECTION); - System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing."); + System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing. Press 'H' to destroy the AWTInputAdapter."); System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |