You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
1
(5) |
2
(5) |
3
(1) |
4
(1) |
5
(5) |
6
|
|
7
(22) |
8
(2) |
9
(10) |
10
(5) |
11
(5) |
12
(1) |
13
|
|
14
|
15
(2) |
16
|
17
|
18
(2) |
19
|
20
|
|
21
(13) |
22
(4) |
23
(3) |
24
(14) |
25
(6) |
26
(26) |
27
(26) |
|
28
(2) |
29
(13) |
30
(17) |
31
(2) |
|
|
|
|
From: Brian M. <ma...@us...> - 2004-03-26 22:08:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5804/test/opengl Modified Files: FullScreenWindowedTest.java VBOIndexTest.java VBOTest.java Log Message: fixed tests according to new way cleaned up imports Index: VBOIndexTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/VBOIndexTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- VBOIndexTest.java 26 Mar 2004 15:03:07 -0000 1.15 +++ VBOIndexTest.java 26 Mar 2004 21:57:57 -0000 1.16 @@ -117,7 +117,6 @@ else if (Window.isCloseRequested()) System.exit(0); - Keyboard.poll(); mainLoop(); render(); } @@ -136,16 +135,13 @@ if (angle > 360.0f) angle = 0.0f; - Mouse.poll(); if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0) System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel()); for (int i = 0; i < Mouse.getButtonCount(); i++) if (Mouse.isButtonDown(i)) System.out.println("Button " + i + " down"); -/* Keyboard.poll(); if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) - finished = true;*/ - Keyboard.read(); + finished = true; for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { Keyboard.next(); if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) @@ -192,9 +188,6 @@ * Initialize */ private static void init() throws Exception { - Keyboard.create(); - Keyboard.enableBuffer(); - Mouse.create(); Sys.setTime(0); Sys.setProcessPriority(Sys.HIGH_PRIORITY); System.out.println("Timer resolution: " + Sys.getTimerResolution()); @@ -235,8 +228,6 @@ int_buffer.put(0, buffer_id); int_buffer.put(1, indices_buffer_id); ARBVertexBufferObject.glDeleteBuffersARB(int_buffer); - Keyboard.destroy(); - Mouse.destroy(); Window.destroy(); try { Display.resetDisplayMode(); Index: FullScreenWindowedTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- FullScreenWindowedTest.java 26 Mar 2004 11:02:45 -0000 1.27 +++ FullScreenWindowedTest.java 26 Mar 2004 21:57:57 -0000 1.28 @@ -163,6 +163,7 @@ //check for fullscreen key if (Keyboard.isKeyDown(Keyboard.KEY_F)) { try { + Window.destroy(); Display.setDisplayMode(mode); Window.create("Test", mode.bpp, 0, 0, 0, 0); glInit(); @@ -173,6 +174,7 @@ //check for window key if (Keyboard.isKeyDown(Keyboard.KEY_W)) { try { + Window.destroy(); Display.resetDisplayMode(); Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); glInit(); Index: VBOTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/VBOTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- VBOTest.java 26 Mar 2004 15:03:07 -0000 1.21 +++ VBOTest.java 26 Mar 2004 21:57:57 -0000 1.22 @@ -113,7 +113,6 @@ else if (Window.isCloseRequested()) System.exit(0); - Keyboard.poll(); mainLoop(); render(); } @@ -132,16 +131,13 @@ if (angle > 360.0f) angle = 0.0f; - Mouse.poll(); if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0) System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel()); for (int i = 0; i < Mouse.getButtonCount(); i++) if (Mouse.isButtonDown(i)) System.out.println("Button " + i + " down"); -/* Keyboard.poll(); if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) - finished = true;*/ - Keyboard.read(); + finished = true; for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { Keyboard.next(); if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) @@ -175,9 +171,6 @@ * Initialize */ private static void init() throws Exception { - Keyboard.create(); - Keyboard.enableBuffer(); - Mouse.create(); Sys.setTime(0); Sys.setProcessPriority(Sys.HIGH_PRIORITY); System.out.println("Timer resolution: " + Sys.getTimerResolution()); @@ -210,8 +203,6 @@ IntBuffer int_buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); int_buffer.put(0, buffer_id); ARBVertexBufferObject.glDeleteBuffersARB(int_buffer); - Keyboard.destroy(); - Mouse.destroy(); Window.destroy(); try { Display.resetDisplayMode(); |
|
From: Brian M. <ma...@us...> - 2004-03-26 22:08:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5804/test/openal Modified Files: ALCTest.java PositionTest.java Log Message: fixed tests according to new way cleaned up imports Index: PositionTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/PositionTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- PositionTest.java 26 Mar 2004 11:26:03 -0000 1.16 +++ PositionTest.java 26 Mar 2004 21:57:56 -0000 1.17 @@ -194,20 +194,6 @@ Sys.log("Soundfiles loaded successfully"); // ----------------------------------------------------- - - // Setup Keyboard - // ===================================================== - Sys.log("Setting up Keyboard"); - - Keyboard.create(); - // ----------------------------------------------------- - - // Setup Mouse - // ===================================================== - Sys.log("Setting up Mouse"); - - Mouse.create(); - // ----------------------------------------------------- } /** @@ -238,18 +224,18 @@ while (!finished) { // handle any input handleInput(); + + // allow window to process internal messages + Window.update(); // render and paint if !minimized and not dirty - if(Window.isFocused() || Window.isDirty()) { + if(!Window.isMinimized()) { render(); } else { // sleeeeeep pause(100); } - // allow window to process internal messages - Window.update(); - // act on pause mode paused(Window.isMinimized() || !Window.isFocused()); @@ -300,9 +286,6 @@ * Handles any input */ private void handleInput() { - Mouse.poll(); - Keyboard.poll(); - // User wants to exit? finished = Window.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE); if (finished) { @@ -445,12 +428,6 @@ * Shutdown of demonstration */ private void shutdown() { - Sys.log("Shutting down Keyboard"); - Keyboard.destroy(); - - Sys.log("Shutting down Mouse"); - Mouse.destroy(); - Sys.log("Shutting down OpenAL"); AL10.alSourceStop(soundSources); AL10.alDeleteSources(soundSources); Index: ALCTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/ALCTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- ALCTest.java 8 Feb 2004 20:32:10 -0000 1.11 +++ ALCTest.java 26 Mar 2004 21:57:56 -0000 1.12 @@ -77,9 +77,9 @@ //mo query buffer.rewind(); - buffer.limit(1); + buffer.position(0); ALC.alcGetInteger(ALC.ALC_MAJOR_VERSION, buffer); - ALC.alcGetInteger(ALC.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1).limit(2)); + ALC.alcGetInteger(ALC.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1)); System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0)); System.out.println("ALC_MINOR_VERSION: " + buffer.get(1)); |
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5804/test/input Modified Files: ControllerCreationTest.java ControllerTest.java HWCursorTest.java MouseCreationTest.java MouseTest.java Log Message: fixed tests according to new way cleaned up imports Index: ControllerCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerCreationTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ControllerCreationTest.java 26 Mar 2004 15:03:07 -0000 1.23 +++ ControllerCreationTest.java 26 Mar 2004 21:57:56 -0000 1.24 @@ -37,7 +37,6 @@ import org.lwjgl.input.Controller; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.Window; -import org.lwjgl.opengl.glu.GLU; import org.lwjgl.vector.Vector2f; /** @@ -89,7 +88,6 @@ private void initializeOpenGL() { GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - GLU.gluOrtho2D(0.0f, 640f, 0f, 480f); } public void executeTest() { @@ -101,9 +99,7 @@ System.out.println("=========== WINDOWED MODE =============="); for(int i=0; i<2; i++) { System.out.println("Test " + (i+1) + ":"); - createController(); wiggleController(); - destroyController(); System.out.println(""); } @@ -127,31 +123,17 @@ System.out.println("=========== FULLSCREEN MODE =============="); for(int i=0; i<2; i++) { System.out.println("Test " + (i+3) + ":"); - createController(); wiggleController(); - destroyController(); System.out.println(""); } System.out.println("Test completed successfully!"); System.out.print("Shutting down..."); Display.resetDisplayMode(); - Controller.destroy(); Window.destroy(); System.out.println("shutdown complete"); } - private void createController() { - System.out.print("Creating controller..."); - try { - Controller.create(); - } catch (Exception e) { - System.out.println("failed"); - System.exit(-1); - } - System.out.println("success"); - } - private void wiggleController() { System.out.print("Please move the controller around"); @@ -161,8 +143,6 @@ while (Sys.getTime() < endtime) { Window.update(); - - Controller.poll(); //controller is a bit fuzzy if(Controller.getX() > 100) { @@ -186,12 +166,6 @@ System.out.println("thank you"); } - private void destroyController() { - System.out.print("Destroying controller..."); - Controller.destroy(); - System.out.print("success"); - } - private void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); Index: ControllerTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- ControllerTest.java 26 Mar 2004 15:03:07 -0000 1.20 +++ ControllerTest.java 26 Mar 2004 21:57:56 -0000 1.21 @@ -35,7 +35,6 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.Window; -import org.lwjgl.opengl.glu.GLU; import org.lwjgl.vector.Vector2f; import org.lwjgl.vector.Vector3f; @@ -106,9 +105,6 @@ private void initialize() { // create display and opengl setupDisplay(); - - createController(); - createKeyboard(); } /** @@ -136,7 +132,6 @@ */ private void initializeOpenGL() { GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - GLU.gluOrtho2D(0.0f, WINDOW_WIDTH, 0, WINDOW_HEIGHT); } /** @@ -147,36 +142,8 @@ runTest(); - Controller.destroy(); - Keyboard.destroy(); Window.destroy(); } - - /** - * Creates the controller - */ - private void createController() { - try { - Controller.create(); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("No controller found, exiting..."); - System.exit(-1); - } - } - - /** - * Creates the keyboard - */ - private void createKeyboard() { - try { - Keyboard.create(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(-1); - } - } - /** * Runs the test */ @@ -195,10 +162,8 @@ // pause and continue if minimized if(Window.isMinimized()) { - if(Window.isDirty()) { - render(); - } pause(100); + render(); continue; } @@ -242,9 +207,6 @@ * Reads the controller */ private void readController() { - // poll for current values - Controller.poll(); - // get last button down for(int i=0;i<Controller.getButtonCount(); i++) { if(Controller.isButtonDown(i)) { @@ -346,8 +308,6 @@ * Handles the keyboard */ private void handleKeyboard() { - Keyboard.poll(); - // closing on ESCAPE if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { closing = true; Index: MouseCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseCreationTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- MouseCreationTest.java 26 Mar 2004 15:03:07 -0000 1.27 +++ MouseCreationTest.java 26 Mar 2004 21:57:56 -0000 1.28 @@ -37,7 +37,6 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.Window; -import org.lwjgl.opengl.glu.GLU; import org.lwjgl.vector.Vector2f; /** @@ -89,7 +88,6 @@ private void initializeOpenGL() { GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - GLU.gluOrtho2D(0.0f, 640f, 0f, 480f); } public void executeTest() { @@ -101,9 +99,7 @@ System.out.println("=========== WINDOWED MODE =============="); for(int i=0; i<2; i++) { System.out.println("Test " + (i+1) + ":"); - createMouse(); wiggleMouse(); - destroyMouse(); System.out.println(""); } @@ -127,31 +123,17 @@ System.out.println("=========== FULLSCREEN MODE =============="); for(int i=0; i<2; i++) { System.out.println("Test " + (i+3) + ":"); - createMouse(); wiggleMouse(); - destroyMouse(); System.out.println(""); } System.out.println("Test completed successfully!"); System.out.print("Shutting down..."); Display.resetDisplayMode(); - Mouse.destroy(); Window.destroy(); System.out.println("shutdown complete"); } - private void createMouse() { - System.out.print("Creating mouse..."); - try { - Mouse.create(); - } catch (Exception e) { - System.out.println("failed"); - System.exit(-1); - } - System.out.println("success"); - } - private void wiggleMouse() { System.out.print("Please move the mouse around"); @@ -161,8 +143,6 @@ while (Sys.getTime() < endtime) { Window.update(); - Mouse.poll(); - position.x += Mouse.getDX(); position.y += Mouse.getDY(); @@ -188,12 +168,6 @@ System.out.println("thank you"); } - private void destroyMouse() { - System.out.print("Destroying mouse..."); - Mouse.destroy(); - System.out.print("success"); - } - private void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); Index: HWCursorTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/HWCursorTest.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- HWCursorTest.java 26 Mar 2004 15:03:07 -0000 1.28 +++ HWCursorTest.java 26 Mar 2004 21:57:56 -0000 1.29 @@ -260,9 +260,6 @@ * Processes keyboard input */ private void processKeyboard() { - Keyboard.poll(); - Mouse.poll(); - if (Mouse.getDX() != 0 || Mouse.getDY() != 0) { mouse_x += Mouse.getDX() / 2; mouse_y += Mouse.getDY() / 2; Index: MouseTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- MouseTest.java 26 Mar 2004 15:03:07 -0000 1.29 +++ MouseTest.java 26 Mar 2004 21:57:56 -0000 1.30 @@ -35,7 +35,6 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.Window; -import org.lwjgl.opengl.glu.GLU; import org.lwjgl.vector.Vector2f; import org.lwjgl.vector.Vector3f; @@ -95,11 +94,6 @@ /** Fullscreen or not */ public static final boolean FULLSCREEN = false; - /** Buffered mouse or not */ - public static final boolean BUFFERED_MOUSE = true; - - private int bufferSize; - /** Creates a new instance of MouseTest */ public MouseTest() { } @@ -108,8 +102,8 @@ // create display and opengl setupDisplay(); - createMouse(); - createKeyboard(); + setupMouse(); + setupKeyboard(); } /** @@ -137,7 +131,6 @@ */ private void initializeOpenGL() { GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - GLU.gluOrtho2D(0.0f, WINDOW_WIDTH, 0, WINDOW_HEIGHT); } /** @@ -148,43 +141,19 @@ runTest(); - Mouse.destroy(); - Keyboard.destroy(); Window.destroy(); } /** * Creates the mouse */ - private void createMouse() { - try { - Mouse.create(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(-1); - } - - // if compiled for buffered mode, enable that - if(BUFFERED_MOUSE) { - try { - Mouse.enableBuffer(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(-1); - } - } + private void setupMouse() { } /** * Creates the keyboard */ - private void createKeyboard() { - try { - Keyboard.create(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(-1); - } + private void setupKeyboard() { } /** @@ -245,23 +214,13 @@ * handles the mouse */ private void handleMouse() { - if(BUFFERED_MOUSE) { - readBufferedMouse(); - } else { - readUnbufferedMouse(); - } + readBufferedMouse(); } /** * reads a mouse in buffered mode */ private void readBufferedMouse() { - // poll for current values - Mouse.poll(); - - // read events - Mouse.read(); - // iterate all events, use the last button down while(Mouse.next()) { if(Mouse.getEventButtonState()) { @@ -271,23 +230,6 @@ updateState(); } - - /** - * Reads the mouse in unbuffered mode - */ - private void readUnbufferedMouse() { - // poll for current values - Mouse.poll(); - - // get last button down - for(int i=0;i<Mouse.getButtonCount(); i++) { - if(Mouse.isButtonDown(i)) { - lastButton = i; - } - } - - updateState(); - } /** * Updates our "model" @@ -300,7 +242,6 @@ if (Mouse.getDX() == Mouse.getDY() && Mouse.getDX() == 0 && Mouse.getDWheel() == 0) { return; } - // determine direction moved // ============================ if(Mouse.getDX() > 0) { @@ -371,8 +312,6 @@ * Handles the keyboard */ private void handleKeyboard() { - Keyboard.poll(); - // closing on ESCAPE if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { closing = true; |
|
From: Brian M. <ma...@us...> - 2004-03-26 22:08:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5804/input Modified Files: Keyboard.java Mouse.java Log Message: fixed tests according to new way cleaned up imports Index: Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- Keyboard.java 26 Mar 2004 21:11:20 -0000 1.39 +++ Keyboard.java 26 Mar 2004 21:57:56 -0000 1.40 @@ -35,12 +35,11 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.util.HashMap; import java.util.Map; -import org.lwjgl.Sys; import org.lwjgl.BufferUtils; +import org.lwjgl.Sys; import org.lwjgl.opengl.Window; /** Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- Mouse.java 26 Mar 2004 21:11:20 -0000 1.41 +++ Mouse.java 26 Mar 2004 21:57:56 -0000 1.42 @@ -33,12 +33,11 @@ package org.lwjgl.input; import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.util.HashMap; import java.util.Map; -import org.lwjgl.Sys; import org.lwjgl.BufferUtils; +import org.lwjgl.Sys; import org.lwjgl.opengl.Window; /** |
|
From: Brian M. <ma...@us...> - 2004-03-26 22:08:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5804/test Modified Files: WindowCreationTest.java Log Message: fixed tests according to new way cleaned up imports Index: WindowCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/WindowCreationTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- WindowCreationTest.java 15 Feb 2004 15:34:56 -0000 1.18 +++ WindowCreationTest.java 26 Mar 2004 21:57:56 -0000 1.19 @@ -33,6 +33,7 @@ import org.lwjgl.Display; import org.lwjgl.DisplayMode; +import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.Window; /** @@ -73,6 +74,10 @@ } catch (Exception e) { e.printStackTrace(); } + + if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { + break; + } } // nuke window and get out |
|
From: Elias N. <eli...@us...> - 2004-03-26 22:00:11
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3871/src/native/win32 Modified Files: org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp Log Message: Saved input events for win32 Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- org_lwjgl_input_Mouse.cpp 12 Jan 2004 17:24:47 -0000 1.44 +++ org_lwjgl_input_Mouse.cpp 26 Mar 2004 21:49:10 -0000 1.45 @@ -47,8 +47,6 @@ #include "common_tools.h" #include <dinput.h> -static BYTE readBuffer[EVENT_BUFFER_SIZE]; - static LPDIRECTINPUTDEVICE mDIDevice; // DI Device instance static int mButtoncount = 0; // Temporary buttoncount static bool mHaswheel; // Temporary wheel check @@ -145,9 +143,7 @@ } } -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv * env, jclass clazz) { - jobject newBuffer = env->NewDirectByteBuffer(&readBuffer, EVENT_BUFFER_SIZE); - return newBuffer; +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv * env, jclass clazz) { } static unsigned char mapButton(DWORD button_id) { @@ -164,17 +160,17 @@ } } -static int bufferButtons(int count, DIDEVICEOBJECTDATA *di_buffer) { +static int bufferButtons(int num_di_events, DIDEVICEOBJECTDATA *di_buffer, unsigned char *buffer, int buffer_size) { int buffer_index = 0; - for (int i = 0; i < count; i++) { + for (int i = 0; i < num_di_events; i++) { unsigned char button = mapButton(di_buffer[i].dwOfs); if (button >= 0 && button < mButtoncount) { unsigned char state = (unsigned char)di_buffer[i].dwData & 0x80; if (state != 0) state = 1; - readBuffer[buffer_index++] = button; - readBuffer[buffer_index++] = state; - if (buffer_index == EVENT_BUFFER_SIZE) + buffer[buffer_index++] = button; + buffer[buffer_index++] = state; + if (buffer_index == buffer_size) break; } } @@ -182,11 +178,11 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead - (JNIEnv * env, jclass clazz) + (JNIEnv * env, jclass clazz, jobject buffer_obj, jint buffer_position) { static DIDEVICEOBJECTDATA rgdod[EVENT_BUFFER_SIZE]; - DWORD bufsize = EVENT_BUFFER_SIZE; + DWORD num_di_events = EVENT_BUFFER_SIZE; HRESULT ret; @@ -197,11 +193,13 @@ ret = mDIDevice->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), rgdod, - &bufsize, + &num_di_events, 0); if (ret == DI_OK) { - return bufferButtons(bufsize, rgdod); + unsigned char *buffer_ptr = buffer_position + (unsigned char*)env->GetDirectBufferAddress(buffer_obj); + int buffer_size = (int)env->GetDirectBufferCapacity(buffer_obj) - buffer_position; + return bufferButtons(num_di_events, rgdod, buffer_ptr, buffer_size); } else if (ret == DI_BUFFEROVERFLOW) { printfDebug("Buffer overflowed\n"); } else if (ret == DIERR_INPUTLOST) { Index: org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- org_lwjgl_input_Keyboard.cpp 23 Mar 2004 07:47:39 -0000 1.29 +++ org_lwjgl_input_Keyboard.cpp 26 Mar 2004 21:49:10 -0000 1.30 @@ -45,14 +45,15 @@ #define DIRECTINPUT_VERSION 0x0300 #include <dinput.h> #include "org_lwjgl_input_Keyboard.h" -#include "Window.h" +#include "Window.h" + #include "common_tools.h" #define KEYBOARD_BUFFER_SIZE 50 -static BYTE readBuffer[KEYBOARD_BUFFER_SIZE*4]; static LPDIRECTINPUTDEVICE lpdiKeyboard = NULL; -static bool translationEnabled; +static bool translationEnabled; + static bool useUnicode; @@ -166,22 +167,22 @@ jlong buffer_size = env->GetDirectBufferCapacity(buffer); lpdiKeyboard->GetDeviceState((DWORD)buffer_size, keyboardBuffer); } - + + /* * Class: org_lwjgl_input_Keyboard * Method: nRead * Signature: (I)V */ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead - (JNIEnv * env, jclass clazz) + (JNIEnv * env, jclass clazz, jobject buffer_obj, jint buffer_position) { - static DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE]; wchar_t transBufUnicode[KEYBOARD_BUFFER_SIZE]; - WORD transBufAscii[KEYBOARD_BUFFER_SIZE]; + WORD transBufAscii[KEYBOARD_BUFFER_SIZE]; BYTE state[256]; - DWORD bufsize = KEYBOARD_BUFFER_SIZE; + DWORD num_di_events = KEYBOARD_BUFFER_SIZE; HRESULT ret; int num_chars; @@ -194,56 +195,63 @@ ret = lpdiKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), rgdod, - &bufsize, + &num_di_events, 0); if (ret == DI_OK) { - unsigned char * buf = readBuffer; - for (unsigned int i = 0; i < bufsize; i ++) { + unsigned char * buf = buffer_position + (unsigned char *)env->GetDirectBufferAddress(buffer_obj); + int buffer_size = (int)env->GetDirectBufferCapacity(buffer_obj) - buffer_position; + int index = 0; + int event_size = translationEnabled ? 4 : 2; + DWORD current_di_event = 0; + while (index + event_size <= buffer_size && current_di_event < num_di_events) { num_events++; - *buf++ = (unsigned char) rgdod[i].dwOfs; - *buf++ = (unsigned char) rgdod[i].dwData; + buf[index++] = (unsigned char) rgdod[current_di_event].dwOfs; + buf[index++] = (unsigned char) rgdod[current_di_event].dwData; if (translationEnabled) { - UINT virt_key = MapVirtualKey(rgdod[i].dwOfs, 1); + UINT virt_key = MapVirtualKey(rgdod[current_di_event].dwOfs, 1); if (virt_key != 0 && GetKeyboardState(state)) { - if (useUnicode) { - num_chars = ToUnicode(virt_key, - rgdod[i].dwOfs, - state, - transBufUnicode, - KEYBOARD_BUFFER_SIZE, 0); - } else { - num_chars = ToAscii(virt_key, - rgdod[i].dwOfs, - state, - transBufAscii, - 0); - } - if (num_chars > 0) { - for (int i = 0; i < num_chars; i++) { - if (i >= 1) { - num_events++; - *buf++ = 0; - *buf++ = 0; - } + if (useUnicode) { + num_chars = ToUnicode(virt_key, + rgdod[current_di_event].dwOfs, + state, + transBufUnicode, + KEYBOARD_BUFFER_SIZE, 0); + } else { + num_chars = ToAscii(virt_key, + rgdod[current_di_event].dwOfs, + state, + transBufAscii, + 0); + } + if (num_chars > 0) { + int current_char = 0; + do { + if (current_char >= 1) { + num_events++; + buf[index++] = 0; + buf[index++] = 0; + } if (useUnicode) { - wchar_t ch = transBufUnicode[i]; - *buf++ = (unsigned char) (ch & 0xff); - *buf++ = (unsigned char) ((ch & 0xff00) >> 8); - } else { - *buf++ = (unsigned char)transBufAscii[0]; - *buf++ = 0; - } - } + wchar_t ch = transBufUnicode[current_char]; + buf[index++] = (unsigned char) (ch & 0xff); + buf[index++] = (unsigned char) ((ch & 0xff00) >> 8); + } else { + buf[index++] = (unsigned char)transBufAscii[current_char]; + buf[index++] = 0; + } + current_char++; + } while (index + event_size <= buffer_size && current_char < num_chars); } else { - *buf++ = 0; - *buf++ = 0; + buf[index++] = 0; + buf[index++] = 0; } } else { - *buf++ = 0; - *buf++ = 0; + buf[index++] = 0; + buf[index++] = 0; } } + current_di_event++; } } else if (ret == DI_BUFFEROVERFLOW) { printfDebug("Keyboard buffer overflowed\n"); @@ -291,11 +299,9 @@ * Method: nEnableBuffer * Signature: ()I */ -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer (JNIEnv * env, jclass clazz) { - jobject newBuffer = env->NewDirectByteBuffer(&readBuffer, KEYBOARD_BUFFER_SIZE*4); - return newBuffer; } /* |
|
From: Elias N. <eli...@us...> - 2004-03-26 21:22:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27218/src/native/linux Modified Files: org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp Log Message: Save unread buffered input events between read()s Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- org_lwjgl_input_Mouse.cpp 20 Dec 2003 22:03:25 -0000 1.44 +++ org_lwjgl_input_Mouse.cpp 26 Mar 2004 21:11:20 -0000 1.45 @@ -393,12 +393,12 @@ warpPointer(); } -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv *env, jclass clazz) { - jobject newBuffer = env->NewDirectByteBuffer(getOutputList(&event_queue), getEventBufferSize(&event_queue)); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv *env, jclass clazz) { buffer_enabled = true; - return newBuffer; } -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz) { - return copyEvents(&event_queue, 2); +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz, jobject buffer, jint buffer_position) { + unsigned char* buffer_ptr = (unsigned char *)env->GetDirectBufferAddress(buffer); + int buffer_size = env->GetDirectBufferCapacity(buffer) - buffer_position; + return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, 2); } Index: org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- org_lwjgl_input_Keyboard.cpp 11 Oct 2003 16:29:40 -0000 1.29 +++ org_lwjgl_input_Keyboard.cpp 26 Mar 2004 21:11:20 -0000 1.30 @@ -249,25 +249,25 @@ memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); } -JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz) { +JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz, jobject buffer, jint buffer_position) { int event_size; if (translation_enabled) event_size = 4; else event_size = 2; - return copyEvents(&event_queue, event_size); + unsigned char* buffer_ptr = (unsigned char *)env->GetDirectBufferAddress(buffer); + int buffer_size = env->GetDirectBufferCapacity(buffer) - buffer_position; + return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, event_size); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation(JNIEnv *env, jclass clazz) { translation_enabled = true; } -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { - jobject newBuffer = env->NewDirectByteBuffer(getOutputList(&event_queue), getEventBufferSize(&event_queue)); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { buffer_enabled = true; - return newBuffer; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nisStateKeySet(JNIEnv *env, jclass clazz, jint key) { - return org_lwjgl_input_Keyboard_STATE_UNKNOWN; + return org_lwjgl_input_Keyboard_STATE_UNKNOWN; } |
|
From: Elias N. <eli...@us...> - 2004-03-26 21:22:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27218/src/java/org/lwjgl/input Modified Files: Keyboard.java Mouse.java Log Message: Save unread buffered input events between read()s Index: Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- Keyboard.java 26 Mar 2004 11:26:04 -0000 1.38 +++ Keyboard.java 26 Mar 2004 21:11:20 -0000 1.39 @@ -40,6 +40,7 @@ import java.util.Map; import org.lwjgl.Sys; +import org.lwjgl.BufferUtils; import org.lwjgl.opengl.Window; /** @@ -191,11 +192,14 @@ public static final int KEY_APPS = 0xDD; /* AppMenu key */ public static final int KEY_POWER = 0xDE; public static final int KEY_SLEEP = 0xDF; - - public static final int STATE_ON = 0; - public static final int STATE_OFF = 1; - public static final int STATE_UNKNOWN = 2; - + + public static final int STATE_ON = 0; + public static final int STATE_OFF = 1; + public static final int STATE_UNKNOWN = 2; + + /** Buffer size in events */ + private final static int BUFFER_SIZE = 50; + /** Key names */ private static final String[] keyName = new String[255]; private static final Map keyMap = new HashMap(253); @@ -243,9 +247,6 @@ /** True if translation is enabled */ private static boolean translationEnabled; - /** The number of events read in the last read() */ - private static int numEvents; - /** The current keyboard character being examined */ private static char eventCharacter; @@ -285,7 +286,7 @@ * @throws Exception if the keyboard could not be created for any reason */ public static void create() throws Exception { - assert Window.isCreated() : "Window must be created prior to creating keyboard"; + assert Window.isCreated() : "Window must be created prior to creating keyboard"; if (!initialized) initialize(); if (created) @@ -322,16 +323,16 @@ private static native void nDestroy(); /** - * Polls the keyboard for its current state. Access the polled values using the - * <code>isKeyDown</code> method. - * By using this method, it is possible to "miss" keyboard keys if you don't - * poll fast enough. To receive all events, enable buffering by calling - * <code>enableBuffer</code>, and read those events by calling <code>read</code> - * - * @see org.lwjgl.input.Keyboard#isKeyDown(int key) - * @see org.lwjgl.input.Keyboard#isStateKeySet(int key) - * @see org.lwjgl.input.Keyboard#enableBuffer() - * @see org.lwjgl.input.Keyboard#read() + * Polls the keyboard for its current state. Access the polled values using the + * <code>isKeyDown</code> method. + * By using this method, it is possible to "miss" keyboard keys if you don't + * poll fast enough. To receive all events, enable buffering by calling + * <code>enableBuffer</code>, and read those events by calling <code>read</code> + * + * @see org.lwjgl.input.Keyboard#isKeyDown(int key) + * @see org.lwjgl.input.Keyboard#isStateKeySet(int key) + * @see org.lwjgl.input.Keyboard#enableBuffer() + * @see org.lwjgl.input.Keyboard#read() */ public static void poll() { assert created : "The keyboard has not been created."; @@ -347,35 +348,36 @@ private static native void nPoll(ByteBuffer keyDownBuffer); /** - * Reads all keyboard events since last read. - * To use these values, you have to call <code>next</code> for each event you - * want to read. You can query which key caused the event by using - * <code>getEventKey</code>. To get the state of that key, for that event, use - * <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the - * character for that event. - * - * @see org.lwjgl.input.Keyboard#next() - * @see org.lwjgl.input.Keyboard#enableBuffer() - * @see org.lwjgl.input.Keyboard#getEventKey() - * @see org.lwjgl.input.Keyboard#getEventKeyState() - * @see org.lwjgl.input.Keyboard#getEventCharacter() + * Reads all keyboard events since last read. + * To use these values, you have to call <code>next</code> for each event you + * want to read. You can query which key caused the event by using + * <code>getEventKey</code>. To get the state of that key, for that event, use + * <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the + * character for that event. + * + * @see org.lwjgl.input.Keyboard#next() + * @see org.lwjgl.input.Keyboard#enableBuffer() + * @see org.lwjgl.input.Keyboard#getEventKey() + * @see org.lwjgl.input.Keyboard#getEventKeyState() + * @see org.lwjgl.input.Keyboard#getEventCharacter() */ public static void read() { assert created : "The keyboard has not been created."; assert readBuffer != null : "Keyboard buffering has not been enabled."; - numEvents = nRead(); - readBuffer.clear(); + readBuffer.compact(); + int numEvents = nRead(readBuffer, readBuffer.position()); if (translationEnabled) - readBuffer.limit(numEvents << 2); + readBuffer.position(readBuffer.position() + numEvents*4); else - readBuffer.limit(numEvents << 1); + readBuffer.position(readBuffer.position() + numEvents*2); + readBuffer.flip(); } /** * Native method to read the keyboard buffer * @return the total number of events read. */ - private static native int nRead(); + private static native int nRead(ByteBuffer buffer, int buffer_position); /** * Enable keyboard translation. Must be called after the keyboard is created, @@ -384,7 +386,6 @@ public static void enableTranslation() throws Exception { assert created : "The keyboard has not been created."; assert readBuffer != null : "Keyboard buffering has not been enabled."; - nEnableTranslation(); translationEnabled = true; } @@ -396,14 +397,12 @@ /** * Enable keyboard buffering. Must be called after the keyboard is created. - * @return the size of the keyboard buffer in events, or 0 if no buffering - * can be enabled for any reason */ - public static int enableBuffer() throws Exception { + public static void enableBuffer() throws Exception { assert created : "The keyboard has not been created."; - readBuffer = nEnableBuffer(); - readBuffer.order(ByteOrder.nativeOrder()); - return readBuffer.capacity()/2; + readBuffer = BufferUtils.createByteBuffer(4*BUFFER_SIZE); + readBuffer.limit(0); + nEnableBuffer(); } /** @@ -411,7 +410,7 @@ * @return the event buffer, * or null if no buffer can be allocated */ - private static native ByteBuffer nEnableBuffer() throws Exception; + private static native void nEnableBuffer() throws Exception; /** * Checks to see if a key is down. @@ -436,18 +435,18 @@ public static boolean isTranslationEnabled() { return translationEnabled; } - - /** - * Checks whether one of the state keys are "active" - * - * @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ) - * @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown - */ - public static int isStateKeySet(int key) { - assert created : "The keyboard has not been created."; - return nisStateKeySet(key); - } - private static native int nisStateKeySet(int key); + + /** + * Checks whether one of the state keys are "active" + * + * @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ) + * @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown + */ + public static int isStateKeySet(int key) { + assert created : "The keyboard has not been created."; + return nisStateKeySet(key); + } + private static native int nisStateKeySet(int key); /** * Gets a key's name @@ -463,7 +462,7 @@ * @param keyName The key name */ public static int getKeyIndex(String keyName) { - Integer ret = (Integer) keyMap.get(keyName); + Integer ret = (Integer) keyMap.get(keyName); if (ret == null) return KEY_NONE; else @@ -476,19 +475,22 @@ */ public static int getNumKeyboardEvents() { assert created : "The keyboard has not been created."; - return numEvents; + if (translationEnabled) + return readBuffer.remaining()/4; + else + return readBuffer.remaining()/2; } /** - * Gets the next keyboard event. You can query which key caused the event by using - * <code>getEventKey</code>. To get the state of that key, for that event, use - * <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the - * character for that event. - * - * @see org.lwjgl.input.Keyboard#getEventKey() - * @see org.lwjgl.input.Keyboard#getEventKeyState() - * @see org.lwjgl.input.Keyboard#getEventCharacter() - * @return true if a keyboard event was read, false otherwise + * Gets the next keyboard event. You can query which key caused the event by using + * <code>getEventKey</code>. To get the state of that key, for that event, use + * <code>getEventKeyState</code> - finally use <code>getEventCharacter</code> to get the + * character for that event. + * + * @see org.lwjgl.input.Keyboard#getEventKey() + * @see org.lwjgl.input.Keyboard#getEventKeyState() + * @see org.lwjgl.input.Keyboard#getEventCharacter() + * @return true if a keyboard event was read, false otherwise */ public static boolean next() { assert created : "The keyboard has not been created."; @@ -499,41 +501,41 @@ eventState = readBuffer.get() != 0; if (translationEnabled) { eventCharacter = readBuffer.getChar(); - } + } return true; } else { return false; - } + } } /** * @return Number of keys on this keyboard */ - public static int getKeyCount() { - return keyCount; - } + public static int getKeyCount() { + return keyCount; + } - /** - * @return The character from the current event - */ - public static char getEventCharacter() { - return eventCharacter; - } + /** + * @return The character from the current event + */ + public static char getEventCharacter() { + return eventCharacter; + } - /** - * @return The key from the current event - */ - public static int getEventKey() { - return eventKey; - } + /** + * @return The key from the current event + */ + public static int getEventKey() { + return eventKey; + } - /** - * Gets the state of the tkey that generated the - * current event - * - * @return True if key was down, or false if released - */ - public static boolean getEventKeyState() { - return eventState; - } -} \ No newline at end of file + /** + * Gets the state of the tkey that generated the + * current event + * + * @return True if key was down, or false if released + */ + public static boolean getEventKeyState() { + return eventState; + } +} Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- Mouse.java 26 Mar 2004 16:18:27 -0000 1.40 +++ Mouse.java 26 Mar 2004 21:11:20 -0000 1.41 @@ -38,6 +38,7 @@ import java.util.Map; import org.lwjgl.Sys; +import org.lwjgl.BufferUtils; import org.lwjgl.opengl.Window; /** @@ -57,15 +58,15 @@ * @version $Revision$ */ public class Mouse { - - /** 1 bit transparency for native cursor */ + + /** 1 bit transparency for native cursor */ public final static int CURSOR_ONE_BIT_TRANSPARENCY = 1; - - /** 8 bit alhpa native cursor */ + + /** 8 bit alhpa native cursor */ public final static int CURSOR_8_BIT_ALPHA = 2; - - /** animation native cursor */ - public final static int CURSOR_ANIMATION = 4; + + /** animation native cursor */ + public final static int CURSOR_ANIMATION = 4; /** Has the mouse been created? */ private static boolean created; @@ -73,12 +74,12 @@ /** The mouse buttons status from the last poll */ private static byte[] buttons; - /** X */ - private static int x; + /** X */ + private static int x; - /** Y */ - private static int y; - + /** Y */ + private static int y; + /** Delta X */ private static int dx; @@ -99,8 +100,8 @@ /** Button names. These are set upon create(), to names like BUTTON0, BUTTON1, etc. */ private static String[] buttonName; - - /** hashmap of button names, for fast lookup */ + + /** hashmap of button names, for fast lookup */ private static final Map buttonMap = new HashMap(16); /** Lazy initialization */ @@ -113,7 +114,10 @@ private static int eventButton; /** The current state of the button being examined in the event queue */ - private static boolean eventState; + private static boolean eventState; + + /** Buffer size in events */ + private final static int BUFFER_SIZE = 50; /** * Mouse cannot be constructed. @@ -161,7 +165,7 @@ * * @param cursor the native cursor object to bind. May be null. * @return The previous Cursor object set, or null. - * @throws Exception if the cursor could not be set for any reason + * @throws Exception if the cursor could not be set for any reason */ public static Cursor setNativeCursor(Cursor cursor) throws Exception { assert created && ((getNativeCursorCaps() | CURSOR_ONE_BIT_TRANSPARENCY) != 0); @@ -169,7 +173,7 @@ currentCursor = cursor; if (currentCursor != null) { nSetNativeCursor(currentCursor.getHandle()); - currentCursor.setTimeout(); + currentCursor.setTimeout(); } else { nSetNativeCursor(0); } @@ -235,9 +239,9 @@ * @throws Exception if the mouse could not be created for any reason */ public static void create() throws Exception { - + assert Window.isCreated() : "Window must be created prior to creating mouse"; - + if (!initialized) { initialize(); } @@ -254,10 +258,10 @@ buttons = new byte[buttonCount]; } - /** Native query of wheel support */ + /** Native query of wheel support */ private static native boolean nHasWheel(); - /** Native query of button count */ + /** Native query of button count */ private static native int nGetButtonCount(); /** @@ -309,43 +313,43 @@ /** * Polls the mouse for its current state. Access the polled values using the - * get<value> methods. - * By using this method, it is possible to "miss" mouse click events if you don't - * poll fast enough. To receive all button events, enable buffering by calling - * <code>enableBuffer</code>, and read those events by calling <code>read</code> - * - * @see org.lwjgl.input.Mouse#isButtonDown(int button) - * @see org.lwjgl.input.Mouse#getX() - * @see org.lwjgl.input.Mouse#getY() - * @see org.lwjgl.input.Mouse#getDX() - * @see org.lwjgl.input.Mouse#getDY() - * @see org.lwjgl.input.Mouse#getDWheel() - * @see org.lwjgl.input.Mouse#enableBuffer() - * @see org.lwjgl.input.Mouse#read() + * get<value> methods. + * By using this method, it is possible to "miss" mouse click events if you don't + * poll fast enough. To receive all button events, enable buffering by calling + * <code>enableBuffer</code>, and read those events by calling <code>read</code> + * + * @see org.lwjgl.input.Mouse#isButtonDown(int button) + * @see org.lwjgl.input.Mouse#getX() + * @see org.lwjgl.input.Mouse#getY() + * @see org.lwjgl.input.Mouse#getDX() + * @see org.lwjgl.input.Mouse#getDY() + * @see org.lwjgl.input.Mouse#getDWheel() + * @see org.lwjgl.input.Mouse#enableBuffer() + * @see org.lwjgl.input.Mouse#read() */ public static void poll() { assert created : "The mouse has not been created."; nPoll(); - - // set absolute position - x += dx; - y += dy; + + // set absolute position + x += dx; + y += dy; - // if window has been created, clamp to edges - if(Window.isCreated()) { - // clamp x, y - if (x < 0) { - x = 0; - } else if (x > Window.getWidth()) { - x = Window.getWidth(); - } - - if (y < 0) { - y = 0; - } else if (y > Window.getHeight()) { - y = Window.getHeight(); - } - } + // if window has been created, clamp to edges + if(Window.isCreated()) { + // clamp x, y + if (x < 0) { + x = 0; + } else if (x > Window.getWidth()) { + x = Window.getWidth(); + } + + if (y < 0) { + y = 0; + } else if (y > Window.getHeight()) { + y = Window.getHeight(); + } + } } /** @@ -362,9 +366,9 @@ public static boolean isButtonDown(int button) { assert created : "The mouse has not been created."; if (button >= buttonCount || button < 0) - return false; + return false; else - return buttons[button] == 1; + return buttons[button] == 1; } /** @@ -384,7 +388,7 @@ * @param buttonName The button name */ public static int getButtonIndex(String buttonName) { - Integer ret = (Integer) buttonMap.get(buttonName); + Integer ret = (Integer) buttonMap.get(buttonName); if (ret == null) return -1; else @@ -393,15 +397,12 @@ /** * Enable mouse button buffering. Must be called after the mouse is created. - * @return the size of the mouse buffer in events, or 0 if no buffering - * can be enabled for any reason */ - public static int enableBuffer() throws Exception { + public static void enableBuffer() throws Exception { assert created : "The mouse has not been created."; - readBuffer = nEnableBuffer(); - if (readBuffer != null) - readBuffer.order(ByteOrder.nativeOrder()); - return readBuffer.capacity()/2; + readBuffer = BufferUtils.createByteBuffer(2*BUFFER_SIZE); + readBuffer.limit(0); + nEnableBuffer(); } /** @@ -409,40 +410,41 @@ * @return the event buffer, * or null if no buffer can be allocated */ - private static native ByteBuffer nEnableBuffer() throws Exception; + private static native void nEnableBuffer() throws Exception; /** * Reads all button events since last read. - * To use these values, you have to call <code>next</code> for each event you - * want to read. You can query which button caused the event by using - * <code>getEventButton</code>. To get the state of that button, for that event, use - * <code>getEventButtonState</code>. - * - * @see org.lwjgl.input.Mouse#next() - * @see org.lwjgl.input.Mouse#enableBuffer() - * @see org.lwjgl.input.Mouse#getEventButton() - * @see org.lwjgl.input.Mouse#getEventButtonState() + * To use these values, you have to call <code>next</code> for each event you + * want to read. You can query which button caused the event by using + * <code>getEventButton</code>. To get the state of that button, for that event, use + * <code>getEventButtonState</code>. + * + * @see org.lwjgl.input.Mouse#next() + * @see org.lwjgl.input.Mouse#enableBuffer() + * @see org.lwjgl.input.Mouse#getEventButton() + * @see org.lwjgl.input.Mouse#getEventButtonState() */ public static void read() { assert created : "The mouse has not been created."; assert readBuffer != null : "Mouse buffering has not been enabled."; - int numEvents = nRead(); - readBuffer.clear(); - readBuffer.limit(numEvents << 1); + readBuffer.compact(); + int numEvents = nRead(readBuffer, readBuffer.position()); + readBuffer.position(readBuffer.position() + numEvents*2); + readBuffer.flip(); } /** * Native method to read the keyboard buffer * @return the total number of events read. */ - private static native int nRead(); + private static native int nRead(ByteBuffer buffer, int buffer_position); /** * Gets the next mouse event. You can query which button caused the event by using - * <code>getEventButton()</code>. To get the state of that key, for that event, use - * <code>getEventButtonState</code>. - * @see org.lwjgl.input.Mouse#getEventButton() - * @see org.lwjgl.input.Mouse#getEventButtonState() + * <code>getEventButton()</code>. To get the state of that key, for that event, use + * <code>getEventButtonState</code>. + * @see org.lwjgl.input.Mouse#getEventButton() + * @see org.lwjgl.input.Mouse#getEventButtonState() * @return true if a mouse event was read, false otherwise */ public static boolean next() { @@ -456,79 +458,79 @@ } else return false; } - - /** - * @return Current events button - */ - public static int getEventButton() { - return eventButton; - } - - /** - * @return Current events button state - */ - public static boolean getEventButtonState() { - return eventState; - } + + /** + * @return Current events button + */ + public static int getEventButton() { + return eventButton; + } + + /** + * @return Current events button state + */ + public static boolean getEventButtonState() { + return eventState; + } - /** - * Retrieves the absolute position. If the Window has been created - * x will be clamped to 0 - Window.getWidth(). - * - * @return Absolute x axis position of mouse - */ - public static int getX() { - return x; - } + /** + * Retrieves the absolute position. If the Window has been created + * x will be clamped to 0 - Window.getWidth(). + * + * @return Absolute x axis position of mouse + */ + public static int getX() { + return x; + } - /** - * Retrieves the absolute position. If the Window has been created - * y will be clamped to 0 - Window.getHeight(). - * - * @return Absolute y axis position of mouse - */ - public static int getY() { - return y; - } - - /** - * @return Movement on the x axis since last poll - */ - public static int getDX() { - return dx; - } + /** + * Retrieves the absolute position. If the Window has been created + * y will be clamped to 0 - Window.getHeight(). + * + * @return Absolute y axis position of mouse + */ + public static int getY() { + return y; + } + + /** + * @return Movement on the x axis since last poll + */ + public static int getDX() { + return dx; + } - /** - * @return Movement on the y axis since last poll - */ - public static int getDY() { - return dy; - } + /** + * @return Movement on the y axis since last poll + */ + public static int getDY() { + return dy; + } - /** - * @return Movement of the wheel since last poll - */ - public static int getDWheel() { - return dwheel; - } + /** + * @return Movement of the wheel since last poll + */ + public static int getDWheel() { + return dwheel; + } - /** - * @return Number of buttons on this mouse - */ - public static int getButtonCount() { - return buttonCount; - } + /** + * @return Number of buttons on this mouse + */ + public static int getButtonCount() { + return buttonCount; + } - /** - * @return Whether or not this mouse has wheel support - */ - public static boolean hasWheel() { - return hasWheel; - } + /** + * @return Whether or not this mouse has wheel support + */ + public static boolean hasWheel() { + return hasWheel; + } /** * Updates the cursor, so that animation can be changed if needed. - * This method is called automatically by the window on its update. + * This method is called automatically by the window on its update. */ public static void updateCursor() { if(currentCursor != null && currentCursor.hasTimedOut()) { |
|
From: Elias N. <eli...@us...> - 2004-03-26 21:22:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27218/src/native/macosx Modified Files: org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp Log Message: Save unread buffered input events between read()s Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- org_lwjgl_input_Mouse.cpp 20 Dec 2003 22:03:25 -0000 1.24 +++ org_lwjgl_input_Mouse.cpp 26 Mar 2004 21:11:20 -0000 1.25 @@ -249,12 +249,12 @@ resetDeltas(); } -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv *env, jclass clazz) { - jobject newBuffer = env->NewDirectByteBuffer(getOutputList(&event_queue), getEventBufferSize(&event_queue)); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv *env, jclass clazz) { buffer_enabled = true; - return newBuffer; } -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz) { - return copyEvents(&event_queue, 2); +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz, jobject buffer, jint buffer_position) { + unsigned char* buffer_ptr = (unsigned char *)env->GetDirectBufferAddress(buffer); + int buffer_size = env->GetDirectBufferCapacity(buffer) - buffer_position; + return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, 2); } Index: org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- org_lwjgl_input_Keyboard.cpp 20 Dec 2003 22:03:25 -0000 1.21 +++ org_lwjgl_input_Keyboard.cpp 26 Mar 2004 21:11:20 -0000 1.22 @@ -365,25 +365,23 @@ memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); } -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz) { - int num_events = 0; +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz, jobject buffer, jint buffer_position) { int event_size; if (translation_enabled) event_size = 4; else event_size = 2; - num_events = copyEvents(&event_queue, event_size); - return num_events; + unsigned char* buffer_ptr = (unsigned char *)env->GetDirectBufferAddress(buffer); + int buffer_size = env->GetDirectBufferCapacity(buffer) - buffer_position; + return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, event_size); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableTranslation(JNIEnv *env, jclass clazz) { translation_enabled = true; } -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { - jobject new_buffer = env->NewDirectByteBuffer(getOutputList(&event_queue), getEventBufferSize(&event_queue)); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer(JNIEnv * env, jclass clazz) { buffer_enabled = true; - return new_buffer; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nisStateKeySet(JNIEnv *env, jclass clazz, jint key) { |
|
From: Elias N. <eli...@us...> - 2004-03-26 21:22:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27218/src/native/common Modified Files: common_tools.cpp common_tools.h org_lwjgl_input_Keyboard.h org_lwjgl_input_Mouse.h Log Message: Save unread buffered input events between read()s Index: org_lwjgl_input_Keyboard.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Keyboard.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_input_Keyboard.h 26 Feb 2004 21:54:05 -0000 1.9 +++ org_lwjgl_input_Keyboard.h 26 Mar 2004 21:11:20 -0000 1.10 @@ -264,6 +264,8 @@ #define org_lwjgl_input_Keyboard_STATE_OFF 1L #undef org_lwjgl_input_Keyboard_STATE_UNKNOWN #define org_lwjgl_input_Keyboard_STATE_UNKNOWN 2L +#undef org_lwjgl_input_Keyboard_BUFFER_SIZE +#define org_lwjgl_input_Keyboard_BUFFER_SIZE 50L /* Inaccessible static: keyName */ /* Inaccessible static: keyMap */ /* Inaccessible static: counter */ @@ -272,13 +274,11 @@ /* Inaccessible static: keyDownBuffer */ /* Inaccessible static: readBuffer */ /* Inaccessible static: translationEnabled */ -/* Inaccessible static: numEvents */ /* Inaccessible static: eventCharacter */ /* Inaccessible static: eventKey */ /* Inaccessible static: eventState */ /* Inaccessible static: initialized */ -/* Inaccessible static: class_000240 */ -/* Inaccessible static: class_000241 */ +/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Keyboard */ /* * Class: org_lwjgl_input_Keyboard * Method: initIDs @@ -314,10 +314,10 @@ /* * Class: org_lwjgl_input_Keyboard * Method: nRead - * Signature: ()I + * Signature: (Ljava/nio/ByteBuffer;I)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead - (JNIEnv *, jclass); + (JNIEnv *, jclass, jobject, jint); /* * Class: org_lwjgl_input_Keyboard @@ -330,9 +330,9 @@ /* * Class: org_lwjgl_input_Keyboard * Method: nEnableBuffer - * Signature: ()Ljava/nio/ByteBuffer; + * Signature: ()V */ -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer +JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nEnableBuffer (JNIEnv *, jclass); /* Index: common_tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- common_tools.cpp 23 Mar 2004 10:19:20 -0000 1.13 +++ common_tools.cpp 26 Mar 2004 21:11:20 -0000 1.14 @@ -77,32 +77,29 @@ return queue->list_start != queue->list_end; } -static void copyEvent(event_queue_t *queue, int event_size, int event_index) { - int output_index = event_index*event_size; +static void copyEvent(event_queue_t *queue, unsigned char *output_event_buffer, int output_index, int event_size) { for (int i = 0; i < event_size; i++) { - queue->output_event_buffer[output_index] = queue->input_event_buffer[queue->list_start]; + output_event_buffer[output_index] = queue->input_event_buffer[queue->list_start]; incListStart(queue); output_index++; } } -int copyEvents(event_queue_t *event_queue, int event_size) { +int copyEvents(event_queue_t *event_queue, unsigned char *output_event_buffer, int buffer_size, int event_size) { int num_events = 0; - while (hasMoreEvents(event_queue)) { - copyEvent(event_queue, event_size, num_events); + int index = 0; + while (index + event_size <= buffer_size && hasMoreEvents(event_queue)) { + copyEvent(event_queue, output_event_buffer, index, event_size); num_events++; + index += event_size; } return num_events; } -unsigned char *getOutputList(event_queue_t *queue) { - return queue->output_event_buffer; -} - -int getEventBufferSize(event_queue_t *event_queue) { +/*int getEventBufferSize(event_queue_t *event_queue) { return EVENT_BUFFER_SIZE; } - +*/ static void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) { jclass cls = env->FindClass(exception_name); env->ThrowNew(cls, err); Index: org_lwjgl_input_Mouse.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Mouse.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_input_Mouse.h 26 Feb 2004 21:54:05 -0000 1.11 +++ org_lwjgl_input_Mouse.h 26 Mar 2004 21:11:20 -0000 1.12 @@ -30,7 +30,9 @@ /* Inaccessible static: readBuffer */ /* Inaccessible static: eventButton */ /* Inaccessible static: eventState */ -/* Inaccessible static: class_000240 */ +#undef org_lwjgl_input_Mouse_BUFFER_SIZE +#define org_lwjgl_input_Mouse_BUFFER_SIZE 50L +/* Inaccessible static: class_00024org_00024lwjgl_00024input_00024Mouse */ /* * Class: org_lwjgl_input_Mouse * Method: nGetNativeCursorCaps @@ -114,18 +116,18 @@ /* * Class: org_lwjgl_input_Mouse * Method: nEnableBuffer - * Signature: ()Ljava/nio/ByteBuffer; + * Signature: ()V */ -JNIEXPORT jobject JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer (JNIEnv *, jclass); /* * Class: org_lwjgl_input_Mouse * Method: nRead - * Signature: ()I + * Signature: (Ljava/nio/ByteBuffer;I)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead - (JNIEnv *, jclass); + (JNIEnv *, jclass, jobject, jint); #ifdef __cplusplus } Index: common_tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- common_tools.h 11 Mar 2004 21:30:48 -0000 1.12 +++ common_tools.h 26 Mar 2004 21:11:20 -0000 1.13 @@ -51,17 +51,16 @@ typedef struct { unsigned char input_event_buffer[EVENT_BUFFER_SIZE]; - unsigned char output_event_buffer[EVENT_BUFFER_SIZE]; int list_start; int list_end; } event_queue_t; extern void initEventQueue(event_queue_t *event_queue); -extern int copyEvents(event_queue_t *event_queue, int event_size); +extern int copyEvents(event_queue_t *event_queue, unsigned char *output_event_buffer, int buffer_size, int event_size); extern void putEventElement(event_queue_t *queue, unsigned char byte); extern unsigned char *getOutputList(event_queue_t *queue); -extern int getEventBufferSize(event_queue_t *event_queue); +//extern int getEventBufferSize(event_queue_t *event_queue); extern void throwException(JNIEnv *env, const char *msg); extern void throwOpenALException(JNIEnv * env, const char * err); extern void setDebugEnabled(bool enable); |
|
From: Elias N. <eli...@us...> - 2004-03-26 16:29:27
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30777/src/java/org/lwjgl/input Modified Files: Mouse.java Log Message: set native cursor to null at Mouse.destroy() Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- Mouse.java 26 Mar 2004 11:00:13 -0000 1.39 +++ Mouse.java 26 Mar 2004 16:18:27 -0000 1.40 @@ -282,11 +282,17 @@ } /** - * "Destroy" the mouse. Remember to reset the native cursor if - * setNativeCursor() has been called with anything else than null. + * "Destroy" the mouse. */ public static void destroy() { - assert currentCursor == null; + if (currentCursor != null) { + try { + setNativeCursor(null); + } catch (Exception e) { + if (Sys.DEBUG) + e.printStackTrace(); + } + } if (!created) return; created = false; @@ -530,6 +536,8 @@ try { setNativeCursor(currentCursor); } catch (Exception e) { + if (Sys.DEBUG) + e.printStackTrace(); } } } |
|
From: Brian M. <ma...@us...> - 2004-03-26 15:14:05
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15015/java/org/lwjgl/test/opengl Modified Files: VBOIndexTest.java VBOTest.java Log Message: removed Window.paint() references Index: VBOIndexTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/VBOIndexTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- VBOIndexTest.java 23 Feb 2004 16:30:48 -0000 1.14 +++ VBOIndexTest.java 26 Mar 2004 15:03:07 -0000 1.15 @@ -120,7 +120,6 @@ Keyboard.poll(); mainLoop(); render(); - Window.paint(); } } catch (Throwable t) { t.printStackTrace(); Index: VBOTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/VBOTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- VBOTest.java 23 Feb 2004 16:30:48 -0000 1.20 +++ VBOTest.java 26 Mar 2004 15:03:07 -0000 1.21 @@ -116,7 +116,6 @@ Keyboard.poll(); mainLoop(); render(); - Window.paint(); } } catch (Throwable t) { t.printStackTrace(); |
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15015/java/org/lwjgl/test/input Modified Files: ControllerCreationTest.java ControllerTest.java HWCursorTest.java KeyboardTest.java MouseCreationTest.java MouseTest.java Log Message: removed Window.paint() references Index: HWCursorTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/HWCursorTest.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- HWCursorTest.java 21 Mar 2004 21:54:55 -0000 1.27 +++ HWCursorTest.java 26 Mar 2004 15:03:07 -0000 1.28 @@ -216,15 +216,11 @@ processKeyboard(); render(); - - // paint window - Window.paint(); } else { // no need to render/paint if nothing has changed (ie. window dragged over) if (Window.isDirty()) { render(); - Window.paint(); } // don't waste cpu time, sleep more Index: ControllerTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- ControllerTest.java 15 Feb 2004 15:34:56 -0000 1.19 +++ ControllerTest.java 26 Mar 2004 15:03:07 -0000 1.20 @@ -197,7 +197,6 @@ if(Window.isMinimized()) { if(Window.isDirty()) { render(); - Window.paint(); } pause(100); continue; @@ -206,7 +205,6 @@ // render and flip logic(); render(); - Window.paint(); } Thread.yield(); } Index: MouseCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseCreationTest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- MouseCreationTest.java 15 Feb 2004 15:34:56 -0000 1.26 +++ MouseCreationTest.java 26 Mar 2004 15:03:07 -0000 1.27 @@ -180,8 +180,6 @@ render(); - Window.paint(); - if (Sys.getTime() - statustime > Sys.getTimerResolution()) { System.out.print("."); statustime = Sys.getTime(); Index: MouseTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- MouseTest.java 15 Feb 2004 15:34:56 -0000 1.28 +++ MouseTest.java 26 Mar 2004 15:03:07 -0000 1.29 @@ -207,7 +207,6 @@ if(Window.isMinimized()) { if(Window.isDirty()) { render(); - Window.paint(); } pause(100); continue; @@ -216,7 +215,6 @@ // render and flip logic(); render(); - Window.paint(); } Thread.yield(); } Index: ControllerCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/ControllerCreationTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- ControllerCreationTest.java 15 Feb 2004 15:34:56 -0000 1.22 +++ ControllerCreationTest.java 26 Mar 2004 15:03:07 -0000 1.23 @@ -178,8 +178,6 @@ render(); - Window.paint(); - if (Sys.getTime() - statustime > Sys.getTimerResolution()) { System.out.print("."); statustime = Sys.getTime(); Index: KeyboardTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- KeyboardTest.java 15 Feb 2004 15:34:56 -0000 1.21 +++ KeyboardTest.java 26 Mar 2004 15:03:07 -0000 1.22 @@ -185,8 +185,6 @@ render(); - Window.paint(); - try { Thread.sleep(0); } catch (Exception e) { |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:37:01
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1774/src/java/org/lwjgl Modified Files: BufferUtils.java Log Message: Simplification work Index: BufferUtils.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/BufferUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BufferUtils.java 1 Mar 2004 13:07:00 -0000 1.2 +++ BufferUtils.java 26 Mar 2004 11:26:03 -0000 1.3 @@ -32,6 +32,7 @@ package org.lwjgl; +import java.nio.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; @@ -88,4 +89,20 @@ return createByteBuffer(size << 2).asFloatBuffer(); } + /** + * A helper function which is used to get the byte offset in an arbitrary buffer + * based on its position + * @return the position of the buffer, in BYTES + */ + public static int getOffset(Buffer buffer) { + if (buffer instanceof FloatBuffer || buffer instanceof IntBuffer) + return buffer.position() << 2; + else if (buffer instanceof ShortBuffer || buffer instanceof CharBuffer) + return buffer.position() << 1; + else if (buffer instanceof DoubleBuffer || buffer instanceof LongBuffer) + return buffer.position() << 3; + else + return buffer.position(); + } + } |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:37:01
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1774/src/java/org/lwjgl/opengl Modified Files: Util.java ARBImaging.java VBOTracker.java Log Message: Simplification work Index: VBOTracker.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/VBOTracker.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- VBOTracker.java 23 Feb 2004 16:30:47 -0000 1.10 +++ VBOTracker.java 26 Mar 2004 11:26:03 -0000 1.11 @@ -48,7 +48,7 @@ private final StateStack attrib_stack; private VBOTracker() { - int stack_size = Util.getGLInteger(GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH); + int stack_size = Util.glGetInteger(GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH); vbo_array_stack = new StateStack(stack_size, 0); vbo_element_stack = new StateStack(stack_size, 0); attrib_stack = new StateStack(stack_size, 0); Index: Util.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Util.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Util.java 7 Mar 2004 16:01:44 -0000 1.10 +++ Util.java 26 Mar 2004 11:26:03 -0000 1.11 @@ -33,6 +33,8 @@ import java.nio.*; +import org.lwjgl.BufferUtils; + /** * Simple utility class. * @@ -40,34 +42,28 @@ * @version $Revision$ */ -abstract class Util { +public final class Util { - static final IntBuffer int_buffer = ByteBuffer.allocateDirect(64).order(ByteOrder.nativeOrder()).asIntBuffer(); + private static final IntBuffer int_buffer = BufferUtils.createIntBuffer(16); /** - * A helper function which is used to get the byte offset in an arbitrary buffer - * based on its position - * @return the position of the buffer, in BYTES + * No c'tor */ - static int getOffset(Buffer buffer) { - if (buffer instanceof FloatBuffer || buffer instanceof IntBuffer) - return buffer.position() << 2; - else if (buffer instanceof ShortBuffer || buffer instanceof CharBuffer) - return buffer.position() << 1; - else if (buffer instanceof DoubleBuffer || buffer instanceof LongBuffer) - return buffer.position() << 3; - else - return buffer.position(); - } - - static void checkGLError() { + private Util() {} + + public static void checkGLError() { int err = GL11.glGetError(); if (err != GL11.GL_NO_ERROR) { throw new OpenGLException(err); } } - - static int getGLInteger(int gl_enum) { + + /** + * Obtain a GL integer value from the driver + * @param gl_enum The GL value you want + * @return the integer value + */ + public static int glGetInteger(int gl_enum) { GL11.glGetInteger(gl_enum, int_buffer); return int_buffer.get(0); } Index: ARBImaging.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBImaging.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ARBImaging.java 18 Feb 2004 23:54:45 -0000 1.3 +++ ARBImaging.java 26 Mar 2004 11:26:03 -0000 1.4 @@ -39,6 +39,8 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; +import org.lwjgl.BufferUtils; + /** * $Id$ * @@ -321,12 +323,12 @@ private static native void nglGetConvolutionParameteriv(int target, int pname, IntBuffer params, int params_offset); public static void glSeparableFilter2D(int target, int internalformat, int width, int height, int format, int type, Buffer row, Buffer column) { // TODO: check buffer size valid - nglSeparableFilter2D(target, internalformat, width, height, format, type, row, Util.getOffset(row), column, Util.getOffset(column)); + nglSeparableFilter2D(target, internalformat, width, height, format, type, row, BufferUtils.getOffset(row), column, BufferUtils.getOffset(column)); } private static native void nglSeparableFilter2D(int target, int internalformat, int width, int height, int format, int type, Buffer row, int row_offset, Buffer column, int column_offset); public static void glGetSeparableFilter(int target, int format, int type, Buffer row, Buffer column, Buffer span) { // TODO: check buffer size valid - nglGetSeparableFilter(target, format, type, row, Util.getOffset(row), column, Util.getOffset(column), span, Util.getOffset(span)); + nglGetSeparableFilter(target, format, type, row, BufferUtils.getOffset(row), column, BufferUtils.getOffset(column), span, BufferUtils.getOffset(span)); } private static native void nglGetSeparableFilter(int target, int format, int type, Buffer row, int row_offset, Buffer column, int column_offset, Buffer span, int span_offset); } |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:37:01
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1774/src/java/org/lwjgl/input Modified Files: Keyboard.java Log Message: Simplification work Index: Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- Keyboard.java 26 Mar 2004 10:58:49 -0000 1.37 +++ Keyboard.java 26 Mar 2004 11:26:04 -0000 1.38 @@ -476,8 +476,6 @@ */ public static int getNumKeyboardEvents() { assert created : "The keyboard has not been created."; - assert readBuffer != null : "Keyboard buffering has not been enabled."; - return numEvents; } |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:37:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1774/src/java/org/lwjgl/test/opengl Modified Files: Grass.java Game.java PbufferTest.java Log Message: Simplification work Index: PbufferTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- PbufferTest.java 3 Mar 2004 10:06:18 -0000 1.28 +++ PbufferTest.java 26 Mar 2004 11:26:03 -0000 1.29 @@ -118,41 +118,33 @@ } } - /** - * Runs the main loop of the "test" - */ - private void mainLoop() { - while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) - && !Window.isCloseRequested()) { - // allow subsystem to get a chance to run too - Window.update(); - - if (!Window.isMinimized()) { - // check keyboard input - processKeyboard(); - - // do "game" logic, and render it - logic(); - render(); - - // paint window - Window.paint(); - } else { - - // no need to render/paint if nothing has changed (ie. window dragged over) - if (Window.isDirty()) { - render(); - Window.paint(); - } - - // don't waste cpu time, sleep more - try { - Thread.sleep(100); - } catch (InterruptedException inte) { - } - } - } - } + /** + * Runs the main loop of the "test" + */ + private void mainLoop() { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { + if (!Window.isMinimized()) { + // check keyboard input + processKeyboard(); + // do "game" logic, and render it + logic(); + render(); + } else { + // no need to render/paint if nothing has changed (ie. window + // dragged over) + if (Window.isDirty()) { + render(); + } + // don't waste cpu time, sleep more + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + // Update window + Window.update(); + } + } /** * Performs the logic Index: Game.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/Game.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Game.java 24 Feb 2004 14:31:37 -0000 1.30 +++ Game.java 26 Mar 2004 11:26:03 -0000 1.31 @@ -29,21 +29,16 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /** * $Id$ - * + * * Simple java test program. - * + * * @author elias_naur <eli...@us...> * @version $Revision$ */ - package org.lwjgl.test.opengl; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - import org.lwjgl.Display; import org.lwjgl.DisplayMode; import org.lwjgl.Sys; @@ -51,26 +46,24 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.Util; import org.lwjgl.opengl.Window; -import org.lwjgl.opengl.glu.GLU; public final class Game { static { try { - //find first display mode that allows us 640*480*16 + //find first display mode that allows us 640*480*16 int mode = -1; DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { - if (modes[i].width == 640 - && modes[i].height == 480 - && modes[i].bpp >= 16) { + if (modes[i].width == 640 && modes[i].height == 480 && modes[i].bpp >= 16) { mode = i; break; } } if (mode != -1) { //select above found displaymode - System.out.println("Setting display mode to "+modes[mode]); + System.out.println("Setting display mode to " + modes[mode]); Display.setDisplayMode(modes[mode]); System.out.println("Created display."); } @@ -78,132 +71,93 @@ System.err.println("Failed to create display due to " + e); } } - - static { - try { - Window.create("LWJGL Game Example", 16, 0, 0,0, 0); - System.out.println("Created OpenGL."); - } catch (Exception e) { - System.err.println("Failed to create OpenGL due to "+e); - System.exit(1); - } - } - - /** Is the game finished? */ - private static boolean finished; - - /** A rotating square! */ - private static float angle; - - /** - * No construction allowed - */ - private Game() { - } - - public static void main(String[] arguments) { - try { - init(); - while (!finished) { - Window.update(); - - if (Window.isMinimized()) - Thread.sleep(200); - else if (Window.isCloseRequested()) - System.exit(0); - - Keyboard.poll(); - mainLoop(); - render(); - Window.paint(); - } - } catch (Throwable t) { - t.printStackTrace(); - } finally { - cleanup(); - } - } - - /** - * All calculations are done in here - */ - private static void mainLoop() { - angle += 1f; - if (angle > 360.0f) - angle = 0.0f; - - Mouse.poll(); - if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0) - System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel()); - for (int i = 0; i < Mouse.getButtonCount(); i++) - if (Mouse.isButtonDown(i)) - System.out.println("Button " + i + " down"); -/* Keyboard.poll(); - if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) - finished = true;*/ - Keyboard.read(); - for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { - Keyboard.next(); - if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) - finished = true; - if (Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState()) - System.out.println("Current time: " + Sys.getTime()); - } - } - - /** - * All rendering is done in here - */ - private static void render() { - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - GL11.glPushMatrix(); - GL11.glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); - GL11.glRotatef(angle, 0, 0, 1.0f); - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex2i(-50, -50); - GL11.glVertex2i(50, -50); - GL11.glVertex2i(50, 50); - GL11.glVertex2i(-50, 50); - GL11.glEnd(); - GL11.glPopMatrix(); - } - - /** - * Initialize - */ - private static void init() throws Exception { - Keyboard.create(); - Keyboard.enableBuffer(); - Mouse.create(); - Sys.setTime(0); - Sys.setProcessPriority(Sys.HIGH_PRIORITY); - System.out.println("Timer resolution: " + Sys.getTimerResolution()); - // Go into orthographic projection mode. - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, Display.getWidth(), 0, Display.getHeight()); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); - ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(64); - num_tex_units_buf.order(ByteOrder.nativeOrder()); - GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, num_tex_units_buf.asIntBuffer()); - System.out.println("Number of texture units: " + num_tex_units_buf.getInt()); - // Fix the refresh rate to the display frequency. -// GL11.wglSwapIntervalEXT(1); - } - - /** - * Cleanup - */ - private static void cleanup() { - Keyboard.destroy(); - Mouse.destroy(); - Window.destroy(); - try { - Display.resetDisplayMode(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } + static { + try { + Window.create("LWJGL Game Example"); + System.out.println("Created OpenGL."); + } catch (Exception e) { + System.err.println("Failed to create OpenGL due to " + e); + System.exit(1); + } + } + /** Is the game finished? */ + private static boolean finished; + /** A rotating square! */ + private static float angle; + + /** + * No construction allowed + */ + private Game() { + } + public static void main(String[] arguments) { + try { + init(); + while (!finished) { + if (Window.isMinimized()) { + Thread.sleep(200); + } else if (Window.isCloseRequested()) { + finished = true; + } else { + mainLoop(); + render(); + } + Window.update(); + } + } catch (Throwable t) { + t.printStackTrace(); + } finally { + cleanup(); + } + } + /** + * All calculations are done in here + */ + private static void mainLoop() { + angle += 1f; + if (angle > 360.0f) angle = 0.0f; + if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0) + System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel()); + for (int i = 0; i < Mouse.getButtonCount(); i++) + if (Mouse.isButtonDown(i)) System.out.println("Button " + i + " down"); + for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { + Keyboard.next(); + if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) finished = true; + if (Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState()) + System.out.println("Current time: " + Sys.getTime()); + } + } + /** + * All rendering is done in here + */ + private static void render() { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glPushMatrix(); + GL11.glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f); + GL11.glRotatef(angle, 0, 0, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + GL11.glEnd(); + GL11.glPopMatrix(); + } + /** + * Initialize + */ + private static void init() + throws Exception { + Sys.setTime(0); + Sys.setProcessPriority(Sys.HIGH_PRIORITY); + System.out.println("Timer resolution: " + Sys.getTimerResolution()); + System.out.println("Number of texture units: " + Util.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS)); + } + /** + * Cleanup + */ + private static void cleanup() { + Window.destroy(); + Display.resetDisplayMode(); + } +} Index: Grass.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/Grass.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Grass.java 24 Feb 2004 14:31:35 -0000 1.30 +++ Grass.java 26 Mar 2004 11:26:03 -0000 1.31 @@ -49,6 +49,7 @@ import java.nio.IntBuffer; import java.util.Random; +import org.lwjgl.BufferUtils; import org.lwjgl.Display; import org.lwjgl.DisplayMode; import org.lwjgl.input.Keyboard; @@ -137,21 +138,18 @@ } public static void main(String[] args) { - ByteBuffer byte_buf = ByteBuffer.allocateDirect(4); - byte_buf.order(ByteOrder.nativeOrder()); System.out.println("Vertex program supported: " + GLContext.GL_NV_vertex_program); - NVVertexProgram.glGenProgramsNV(byte_buf.asIntBuffer()); - IntBuffer int_buf = byte_buf.asIntBuffer(); + IntBuffer int_buf = BufferUtils.createIntBuffer(1); + NVVertexProgram.glGenProgramsNV(int_buf); if (int_buf.get(0) == 0) throw new RuntimeException("Could not allocate new vertex program id!"); program_handle = int_buf.get(0); byte[] program = loadFile("cg_grass2.vp"); - ByteBuffer program_buf = ByteBuffer.allocateDirect(program.length); + ByteBuffer program_buf = BufferUtils.createByteBuffer(program.length); program_buf.order(ByteOrder.nativeOrder()); - program_buf.rewind(); program_buf.put(program); - program_buf.rewind(); + program_buf.flip(); NVVertexProgram.glLoadProgramNV( NVVertexProgram.GL_VERTEX_PROGRAM_NV, program_handle, @@ -163,18 +161,17 @@ float[] LightDiffuse = { 1.0f, 0.0f, 0.0f, 1.0f }; float[] LightPosition = { 1.0f, 1.0f, 1.0f, 0.0f }; - ByteBuffer light_buf = ByteBuffer.allocateDirect(4 * 4); - light_buf.order(ByteOrder.nativeOrder()); - FloatBuffer light_buf_f = light_buf.asFloatBuffer(); - light_buf_f.rewind(); + FloatBuffer light_buf_f = BufferUtils.createFloatBuffer(4); light_buf_f.put(LightDiffuse); + light_buf_f.flip(); GL11.glLightfv( GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_buf_f); - light_buf_f.rewind(); + light_buf_f.clear(); light_buf_f.put(LightPosition); + light_buf_f.flip(); GL11.glLightfv( GL11.GL_LIGHT0, GL11.GL_POSITION, @@ -196,23 +193,23 @@ aslod.count = 0.0f; while (!finished) { - Window.update(); - keyPoll(); - float degree = (1.0f + (aslod.value * 20.0f)) * 0.01745329f; - - degree *= (0.5 + myrand()); + if (Window.isCloseRequested()) { + finished = true; + } else if (!Window.isMinimized()) { + keyPoll(); + float degree = (1.0f + (aslod.value * 20.0f)) * 0.01745329f; - ptrAnimate(degree); - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + degree *= (0.5 + myrand()); - //ptrDraw(); + ptrAnimate(degree); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); - grsDraw(); + //ptrDraw(); - Window.paint(); + grsDraw(); + } + Window.update(); } - Mouse.destroy(); - Keyboard.destroy(); Window.destroy(); } @@ -448,7 +445,6 @@ } private static void keyPoll() { - Keyboard.read(); for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) { Keyboard.next(); if (!Keyboard.getEventKeyState()) |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:37:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1774/src/java/org/lwjgl/test/openal Modified Files: PositionTest.java Log Message: Simplification work Index: PositionTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/PositionTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- PositionTest.java 25 Mar 2004 22:44:31 -0000 1.15 +++ PositionTest.java 26 Mar 2004 11:26:03 -0000 1.16 @@ -242,7 +242,6 @@ // render and paint if !minimized and not dirty if(Window.isFocused() || Window.isDirty()) { render(); - Window.paint(); } else { // sleeeeeep pause(100); |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:20:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31411/src/java/org/lwjgl/opengl Modified Files: Window.java Log Message: Simplification work Index: Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Window.java 26 Mar 2004 11:01:34 -0000 1.30 +++ Window.java 26 Mar 2004 11:09:39 -0000 1.31 @@ -273,6 +273,7 @@ * Create a fullscreen window that matches the current display depth. Default common values are chosen * for common OpenGL rendering operations: you will get at least a 16-bit depth buffer, an 8 bit stencil * buffer, probably no alpha buffer, and probably no multisampling. + * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. * @param title * @throws Exception */ @@ -284,7 +285,7 @@ * Create a fullscreen window. If the underlying OS does not * support fullscreen mode, then a window will be created instead. If this * fails too then an Exception will be thrown. - * + * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. * @param title The title of the window * @param bpp Minimum bits per pixel * @param alpha Minimum bits per pixel in alpha buffer @@ -301,7 +302,7 @@ * Create a fullscreen window. If the underlying OS does not * support fullscreen mode, then a window will be created instead. If this * fails too then an Exception will be thrown. - * + * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. * @param title The title of the window * @param bpp Minimum bits per pixel * @param alpha Minimum bits per pixel in alpha buffer @@ -329,7 +330,7 @@ * display will be created instead. If this fails too then an Exception will be thrown. * If the window is created fullscreen, then its size may not match the specified size * here. - * + * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. * @param title The title of the window * @param x The position of the window on the x axis. May be ignored. * @param y The position of the window on the y axis. May be ignored. @@ -352,7 +353,7 @@ * display will be created instead. If this fails too then an Exception will be thrown. * If the window is created fullscreen, then its size may not match the specified size * here. - * + * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. * @param title The title of the window * @param x The position of the window on the x axis. May be ignored. * @param y The position of the window on the y axis. May be ignored. @@ -402,7 +403,16 @@ nCreate(title, x, y, width, height, fullscreen, bpp, alpha, depth, stencil, samples); context = new Window(); makeCurrent(); - + + // Put the window into orthographic projection mode with 1:1 pixel ratio. + // We haven't used GLU here to do this to avoid an unnecessary dependency. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0, (double) width, 0.0, (double) height, -1.0, 1.0); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, width, height); + // Automatically create mouse, keyboard and controller if (!Mouse.isCreated()) { try { |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:15:41
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30348/src/native/linux Modified Files: org_lwjgl_opengl_Window.cpp Log Message: Simplification work Index: org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_opengl_Window.cpp 21 Mar 2004 21:54:56 -0000 1.23 +++ org_lwjgl_opengl_Window.cpp 26 Mar 2004 11:04:44 -0000 1.24 @@ -257,7 +257,7 @@ /* * Class: org_lwjgl_Window - * Method: update + * Method: nUpdate * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nUpdate |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:13:43
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29926/src/java/org/lwjgl/test/opengl Modified Files: FullScreenWindowedTest.java Log Message: Simplification work Index: FullScreenWindowedTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- FullScreenWindowedTest.java 15 Feb 2004 15:34:57 -0000 1.26 +++ FullScreenWindowedTest.java 26 Mar 2004 11:02:45 -0000 1.27 @@ -41,293 +41,232 @@ /** * $Id$ - * + * * Tests switching between windowed and fullscreen - * + * * @author Brian Matzon <br...@ma...> * @version $Revision$ */ public class FullScreenWindowedTest { + /** Intended deiplay mode */ + private DisplayMode mode; + /** our quad moving around */ + private Vector2f quadPosition; + /** our quadVelocity */ + private Vector2f quadVelocity; + /** angle of quad */ + private float angle; + /** degrees to rotate per frame */ + private float angleRotation = 1.0f; + /** Max speed of all changable attributes */ + private static final float MAX_SPEED = 20.0f; - /** Intended deiplay mode */ - private DisplayMode mode; - - /** our quad moving around */ - private Vector2f quadPosition; - - /** our quadVelocity */ - private Vector2f quadVelocity; - - /** angle of quad */ - private float angle; - - /** degrees to rotate per frame */ - private float angleRotation = 1.0f; - - /** Max speed of all changable attributes */ - private static final float MAX_SPEED = 20.0f; - - /** - * Creates a FullScreenWindowedTest - */ - public FullScreenWindowedTest() { - } - - /** - * Executes the test - */ - public void execute() { - initialize(); - - mainLoop(); - - cleanup(); - } - - /** - * Initializes the test - */ - private void initialize() { - try { - //find displaymode - mode = findDisplayMode(800, 600, 16); - - // start of in windowed mode - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); - - glInit(); - - Keyboard.create(); - - quadPosition = new Vector2f(100f, 100f); - quadVelocity = new Vector2f(1.0f, 1.0f); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Runs the main loop of the "test" - */ - private void mainLoop() { - while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) - && !Window.isCloseRequested()) { - // allow subsystem to get a chance to run too - Window.update(); - - if (!Window.isMinimized()) { - // check keyboard input - processKeyboard(); - - // do "game" logic, and render it - logic(); - render(); - - // paint window - Window.paint(); - } else { - - // no need to render/paint if nothing has changed (ie. window dragged over) - if (Window.isDirty()) { - render(); - Window.paint(); - } - - // don't waste cpu time, sleep more - try { - Thread.sleep(100); - } catch (InterruptedException inte) { - } - } - } - Display.resetDisplayMode(); - } - - /** - * Performs the logic - */ - private void logic() { - angle += angleRotation; - if (angle > 90.0f) { - angle = 0.0f; - } - - quadPosition.x += quadVelocity.x; - quadPosition.y += quadVelocity.y; - - //check colision with vertical border border - if (quadPosition.x + 50 >= mode.width || quadPosition.x - 50 <= 0) { - quadVelocity.x *= -1; - } - - //check collision with horizontal border - if (quadPosition.y + 50 >= mode.height || quadPosition.y - 50 <= 0) { - quadVelocity.y *= -1; - } - } - - private void render() { - //clear background - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - - // draw white quad - GL11.glPushMatrix(); - { - GL11.glTranslatef(quadPosition.x, quadPosition.y, 0); - GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); - GL11.glColor3f(1.0f, 1.0f, 1.0f); - GL11.glBegin(GL11.GL_QUADS); - { - GL11.glVertex2i(-50, -50); - GL11.glVertex2i(50, -50); - GL11.glVertex2i(50, 50); - GL11.glVertex2i(-50, 50); - } - GL11.glEnd(); - } - GL11.glPopMatrix(); - } - - /** - * Processes keyboard input - */ - private void processKeyboard() { - Keyboard.poll(); - - //check for fullscreen key - if (Keyboard.isKeyDown(Keyboard.KEY_F)) { - - try { - Keyboard.destroy(); - Window.destroy(); - - Display.setDisplayMode(mode); - Window.create("Test", mode.bpp, 0, 0, 0, 0); - - glInit(); - - Keyboard.create(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - //check for window key - if (Keyboard.isKeyDown(Keyboard.KEY_W)) { - try { - Keyboard.destroy(); - Window.destroy(); - - Display.resetDisplayMode(); - Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); - - glInit(); - - Keyboard.create(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - //check for speed changes - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { - quadVelocity.y += 0.1f; - } - if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { - quadVelocity.y -= 0.1f; - } - if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { - quadVelocity.x += 0.1f; - } - if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { - quadVelocity.x -= 0.1f; - } - - if (Keyboard.isKeyDown(Keyboard.KEY_ADD)) { - angleRotation += 0.1f; - } - if (Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT)) { - angleRotation -= 0.1f; - } - - //throttle - if (quadVelocity.x < -MAX_SPEED) { - quadVelocity.x = -MAX_SPEED; - } - if (quadVelocity.x > MAX_SPEED) { - quadVelocity.x = MAX_SPEED; - } - if (quadVelocity.y < -MAX_SPEED) { - quadVelocity.y = -MAX_SPEED; - } - if (quadVelocity.y > MAX_SPEED) { - quadVelocity.y = MAX_SPEED; - } - - if (angleRotation < 0.0f) { - angleRotation = 0.0f; - } - if (angleRotation > MAX_SPEED) { - angleRotation = MAX_SPEED; - } - } - - /** - * Cleans up the test - */ - private void cleanup() { - Keyboard.destroy(); - Window.destroy(); - } - - /** - * Retrieves a displaymode, if one such is available - * - * @param width Required width - * @param height Required height - * @param bpp Minimum required bits per pixel - * @return - */ - private DisplayMode findDisplayMode(int width, int height, int bpp) { - DisplayMode[] modes = Display.getAvailableDisplayModes(); - for (int i = 0; i < modes.length; i++) { - if (modes[i].width == width - && modes[i].height == height - && modes[i].bpp >= bpp && modes[i].freq <= 60) { - return modes[i]; - } - } - return null; - } - - /** - * Initializes OGL - */ - private void glInit() { - // Go into orthographic projection mode. - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - GLU.gluOrtho2D(0, mode.width, 0, mode.height); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glViewport(0, 0, mode.width, mode.height); - - //set clear color to black - GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - - //sync frame (only works on windows) - Window.setVSyncEnabled(true); - } - - /** - * Test entry point - */ - public static void main(String[] args) { - System.out.println( - "Change between fullscreen and windowed mode, by pressing F and W respectively"); - System.out.println( - "Move quad using arrowkeys, and change rotation using +/-"); - FullScreenWindowedTest fswTest = new FullScreenWindowedTest(); - fswTest.execute(); - } + /** + * Creates a FullScreenWindowedTest + */ + public FullScreenWindowedTest() { + } + /** + * Executes the test + */ + public void execute() { + initialize(); + mainLoop(); + cleanup(); + } + /** + * Initializes the test + */ + private void initialize() { + try { + //find displaymode + mode = findDisplayMode(800, 600, 16); + // start of in windowed mode + Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); + glInit(); + quadPosition = new Vector2f(100f, 100f); + quadVelocity = new Vector2f(1.0f, 1.0f); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * Runs the main loop of the "test" + */ + private void mainLoop() { + while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) { + if (!Window.isMinimized()) { + // check keyboard input + processKeyboard(); + // do "game" logic, and render it + logic(); + render(); + } else { + // no need to render/paint if nothing has changed (ie. window + // dragged over) + if (Window.isDirty()) { + render(); + } + // don't waste cpu time, sleep more + try { + Thread.sleep(100); + } catch (InterruptedException inte) { + } + } + // Update window + Window.update(); + } + } + /** + * Performs the logic + */ + private void logic() { + angle += angleRotation; + if (angle > 90.0f) { + angle = 0.0f; + } + quadPosition.x += quadVelocity.x; + quadPosition.y += quadVelocity.y; + //check colision with vertical border border + if (quadPosition.x + 50 >= mode.width || quadPosition.x - 50 <= 0) { + quadVelocity.x *= -1; + } + //check collision with horizontal border + if (quadPosition.y + 50 >= mode.height || quadPosition.y - 50 <= 0) { + quadVelocity.y *= -1; + } + } + private void render() { + //clear background + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + // draw white quad + GL11.glPushMatrix(); + { + GL11.glTranslatef(quadPosition.x, quadPosition.y, 0); + GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); + GL11.glColor3f(1.0f, 1.0f, 1.0f); + GL11.glBegin(GL11.GL_QUADS); + { + GL11.glVertex2i(-50, -50); + GL11.glVertex2i(50, -50); + GL11.glVertex2i(50, 50); + GL11.glVertex2i(-50, 50); + } + GL11.glEnd(); + } + GL11.glPopMatrix(); + } + /** + * Processes keyboard input + */ + private void processKeyboard() { + //check for fullscreen key + if (Keyboard.isKeyDown(Keyboard.KEY_F)) { + try { + Display.setDisplayMode(mode); + Window.create("Test", mode.bpp, 0, 0, 0, 0); + glInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + //check for window key + if (Keyboard.isKeyDown(Keyboard.KEY_W)) { + try { + Display.resetDisplayMode(); + Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0); + glInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + //check for speed changes + if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { + quadVelocity.y += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { + quadVelocity.y -= 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + quadVelocity.x += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + quadVelocity.x -= 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_ADD)) { + angleRotation += 0.1f; + } + if (Keyboard.isKeyDown(Keyboard.KEY_SUBTRACT)) { + angleRotation -= 0.1f; + } + //throttle + if (quadVelocity.x < -MAX_SPEED) { + quadVelocity.x = -MAX_SPEED; + } + if (quadVelocity.x > MAX_SPEED) { + quadVelocity.x = MAX_SPEED; + } + if (quadVelocity.y < -MAX_SPEED) { + quadVelocity.y = -MAX_SPEED; + } + if (quadVelocity.y > MAX_SPEED) { + quadVelocity.y = MAX_SPEED; + } + if (angleRotation < 0.0f) { + angleRotation = 0.0f; + } + if (angleRotation > MAX_SPEED) { + angleRotation = MAX_SPEED; + } + } + /** + * Cleans up the test + */ + private void cleanup() { + } + /** + * Retrieves a displaymode, if one such is available + * + * @param width + * Required width + * @param height + * Required height + * @param bpp + * Minimum required bits per pixel + * @return + */ + private DisplayMode findDisplayMode(int width, int height, int bpp) { + DisplayMode[] modes = Display.getAvailableDisplayModes(); + for (int i = 0; i < modes.length; i++) { + if (modes[i].width == width && modes[i].height == height && modes[i].bpp >= bpp && modes[i].freq <= 60) { + return modes[i]; + } + } + return null; + } + /** + * Initializes OGL + */ + private void glInit() { + // Go into orthographic projection mode. + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GLU.gluOrtho2D(0, mode.width, 0, mode.height); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, mode.width, mode.height); + //set clear color to black + GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + //sync frame (only works on windows) + Window.setVSyncEnabled(true); + } + /** + * Test entry point + */ + public static void main(String[] args) { + System.out.println("Change between fullscreen and windowed mode, by pressing F and W respectively"); + System.out.println("Move quad using arrowkeys, and change rotation using +/-"); + FullScreenWindowedTest fswTest = new FullScreenWindowedTest(); + fswTest.execute(); + } } |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:13:32
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29893/src/native/win32 Modified Files: org_lwjgl_opengl_Window.cpp Log Message: Simplification work |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:12:55
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29789/src/native/common Modified Files: org_lwjgl_opengl_Window.h Log Message: Simplification work Index: org_lwjgl_opengl_Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Window.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_opengl_Window.h 21 Mar 2004 21:54:55 -0000 1.13 +++ org_lwjgl_opengl_Window.h 26 Mar 2004 11:01:57 -0000 1.14 @@ -108,7 +108,7 @@ /* * Class: org_lwjgl_opengl_Window - * Method: update + * Method: nUpdate * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nUpdate |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:12:31
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29656/src/java/org/lwjgl/opengl Modified Files: Window.java Log Message: Index: Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- Window.java 21 Mar 2004 21:54:55 -0000 1.29 +++ Window.java 26 Mar 2004 11:01:34 -0000 1.30 @@ -49,6 +49,8 @@ import org.lwjgl.Display; import org.lwjgl.Sys; +import org.lwjgl.input.Controller; +import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; public final class Window { @@ -86,6 +88,15 @@ /** A unique context object, so we can track different contexts between creates() and destroys() */ private static Window context; + + /** Whether we created the Mouse */ + private static boolean createdMouse; + + /** Whether we created the Keyboard */ + private static boolean createdKeyboard; + + /** Whether we created the Controller */ + private static boolean createdController; /** * Only constructed by ourselves @@ -206,12 +217,37 @@ private static native boolean nIsDirty(); /** - * Paint the window. This clears the dirty flag and swaps the buffers. + * Update the window. This processes operating system events, and if the window is visible + * clears the dirty flag and swaps the buffers. + * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() */ - public static void paint() { + public static void update() { assert isCreated() : "Cannot paint uncreated window"; - Util.checkGLError(); - swapBuffers(); + nUpdate(); + if ((isDirty() && !isMinimized()) || (isFocused() && !isMinimized())) { + Util.checkGLError(); + swapBuffers(); + } + // Poll the input devices while we're here + if (Mouse.isCreated()) { + Mouse.poll(); + if (Mouse.isBuffered()) { + Mouse.read(); + } + Mouse.updateCursor(); + } + if (Keyboard.isCreated()) { + Keyboard.poll(); + if (Keyboard.isBuffered()) { + Keyboard.read(); + } + } + if (Controller.isCreated()) { + Controller.poll(); + if (Controller.isBuffered()) { + Controller.read(); + } + } } /** @@ -232,6 +268,17 @@ * Make the window the current rendering context for GL calls. */ private static native void nMakeCurrent(); + + /** + * Create a fullscreen window that matches the current display depth. Default common values are chosen + * for common OpenGL rendering operations: you will get at least a 16-bit depth buffer, an 8 bit stencil + * buffer, probably no alpha buffer, and probably no multisampling. + * @param title + * @throws Exception + */ + public static void create(String title) throws Exception { + create(title, Display.getDepth(), 0, 16, 8, 0); + } /** * Create a fullscreen window. If the underlying OS does not @@ -243,6 +290,23 @@ * @param alpha Minimum bits per pixel in alpha buffer * @param depth Minimum bits per pixel in depth buffer * @param stencil Minimum bits per pixel in stencil buffer + * @throws Exception if the window could not be created for any reason; typically because + * the minimum requirements could not be met satisfactorily + */ + public static void create(String title, int bpp, int alpha, int depth, int stencil) throws Exception { + create(title, bpp, alpha, depth, stencil, 0); + } + + /** + * Create a fullscreen window. If the underlying OS does not + * support fullscreen mode, then a window will be created instead. If this + * fails too then an Exception will be thrown. + * + * @param title The title of the window + * @param bpp Minimum bits per pixel + * @param alpha Minimum bits per pixel in alpha buffer + * @param depth Minimum bits per pixel in depth buffer + * @param stencil Minimum bits per pixel in stencil buffer * @param samples Minimum samples in multisample buffer (corresponds to GL_SAMPLES_ARB in GL_ARB_multisample spec). Pass 0 to disable multisampling. This parameter is ignored if GL_ARB_multisample is not supported. * @throws Exception if the window could not be created for any reason; typically because @@ -274,6 +338,29 @@ * @param bpp Minimum bits per pixel * @param alpha Minimum bits per pixel in alpha buffer * @param depth Minimum bits per pixel in depth buffer + * @param samples Minimum samples in multisample buffer (corresponds to GL_SAMPLES_ARB in GL_ARB_multisample spec). + Pass 0 to disable multisampling. This parameter is ignored if GL_ARB_multisample is not supported. + * @throws Exception if the window could not be created for any reason; typically because + * the minimum requirements could not be met satisfactorily + */ + public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil) throws Exception { + create(title, x, y, width, height, bpp, alpha, depth, stencil, 0); + } + + /** + * Create a window. If the underlying OS does not have "floating" windows, then a fullscreen + * display will be created instead. If this fails too then an Exception will be thrown. + * If the window is created fullscreen, then its size may not match the specified size + * here. + * + * @param title The title of the window + * @param x The position of the window on the x axis. May be ignored. + * @param y The position of the window on the y axis. May be ignored. + * @param width The width of the window's client area + * @param height The height of the window's client area + * @param bpp Minimum bits per pixel + * @param alpha Minimum bits per pixel in alpha buffer + * @param depth Minimum bits per pixel in depth buffer * @param stencil Minimum bits per pixel in stencil buffer * @param samples Minimum samples in multisample buffer (corresponds to GL_SAMPLES_ARB in GL_ARB_multisample spec). Pass 0 to disable multisampling. This parameter is ignored if GL_ARB_multisample is not supported. @@ -315,6 +402,47 @@ nCreate(title, x, y, width, height, fullscreen, bpp, alpha, depth, stencil, samples); context = new Window(); makeCurrent(); + + // Automatically create mouse, keyboard and controller + if (!Mouse.isCreated()) { + try { + Mouse.create(); + createdMouse = true; + Mouse.enableBuffer(); + } catch (Exception e) { + if (Sys.DEBUG) { + e.printStackTrace(System.err); + } else { + Sys.log("Failed to create Mouse: "+e); + } + } + } + if (!Keyboard.isCreated()) { + try { + Keyboard.create(); + createdKeyboard = true; + Keyboard.enableBuffer(); + Keyboard.enableTranslation(); + } catch (Exception e) { + if (Sys.DEBUG) { + e.printStackTrace(System.err); + } else { + Sys.log("Failed to create Keyboard: "+e); + } + } + } + if (!Controller.isCreated()) { + try { + Controller.create(); + createdController = true; + } catch (Exception e) { + if (Sys.DEBUG) { + e.printStackTrace(System.err); + } else { + Sys.log("Failed to create Controller: "+e); + } + } + } } /** @@ -325,6 +453,21 @@ if (context == null) { return; } + + // Automatically destroy keyboard, mouse, and controller + if (createdMouse && Mouse.isCreated()) { + Mouse.destroy(); + createdMouse = false; + } + if (createdKeyboard && Keyboard.isCreated()) { + Keyboard.destroy(); + createdKeyboard = false; + } + if (createdController && Controller.isCreated()) { + Controller.destroy(); + createdController = false; + } + makeCurrent(); nDestroy(); context = null; @@ -353,15 +496,7 @@ * Updates the windows internal state. This must be called at least once per video frame * to handle window close requests, moves, paints, etc. */ - public static void update() { - nUpdate(); - - // notify Mouse that we've had an update, so that it may update its cursor if needed - if(Mouse.isCreated()) { - Mouse.updateCursor(); - } - } - public static native void nUpdate(); + private static native void nUpdate(); /** * Determines to the best of the platform's ability whether monitor vysnc is enabled on |
|
From: Caspian Rychlik-P. <ci...@us...> - 2004-03-26 11:11:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29435/src/java/org/lwjgl/input Modified Files: Mouse.java Log Message: Simplification work Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- Mouse.java 21 Mar 2004 21:54:55 -0000 1.38 +++ Mouse.java 26 Mar 2004 11:00:13 -0000 1.39 @@ -169,7 +169,7 @@ currentCursor = cursor; if (currentCursor != null) { nSetNativeCursor(currentCursor.getHandle()); - currentCursor.setTimeout(); + currentCursor.setTimeout(); } else { nSetNativeCursor(0); } @@ -273,6 +273,13 @@ public static boolean isCreated() { return created; } + + /** + * @return true if buffering is enabled + */ + public static boolean isBuffered() { + return readBuffer != null; + } /** * "Destroy" the mouse. Remember to reset the native cursor if @@ -515,7 +522,7 @@ /** * Updates the cursor, so that animation can be changed if needed. - * This method is called automatically by the window on its update. + * This method is called automatically by the window on its update. */ public static void updateCursor() { if(currentCursor != null && currentCursor.hasTimedOut()) { |