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: Elias N. <eli...@us...> - 2004-03-27 14:29:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27652/src/native/win32 Modified Files: org_lwjgl_Sys.cpp Log Message: Implemented version check to check for incompatible native libraries Index: org_lwjgl_Sys.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Sys.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- org_lwjgl_Sys.cpp 23 Feb 2004 23:42:57 -0000 1.22 +++ org_lwjgl_Sys.cpp 27 Mar 2004 14:09:55 -0000 1.23 @@ -65,6 +65,10 @@ setDebugEnabled(enabled == JNI_TRUE ? true : false); } +JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env, jclass clazz) { + return getVersionString(env); +} + /* * Class: org_lwjgl_Sys * Method: getTime |
|
From: Elias N. <eli...@us...> - 2004-03-27 14:00:41
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/eax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24895/src/java/org/lwjgl/openal/eax Modified Files: EAX.java EAXBufferProperties.java EAXListenerProperties.java Log Message: All classes use Sys.initialize now Index: EAX.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/eax/EAX.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- EAX.java 26 Feb 2004 21:51:57 -0000 1.7 +++ EAX.java 27 Mar 2004 13:48:58 -0000 1.8 @@ -29,7 +29,10 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - package org.lwjgl.openal.eax; + +package org.lwjgl.openal.eax; + +import org.lwjgl.Sys; /** * $Id$ @@ -40,65 +43,57 @@ * @version $Revision$ */ public class EAX { + /** Has the EAX object been created? */ + protected static boolean created; + + static { + Sys.initialize(); + } - /** Has the EAX object been created? */ - protected static boolean created; - - static { - initialize(); - } - - /** - * Static initialization - */ - private static void initialize() { - System.loadLibrary(org.lwjgl.Sys.getLibraryName()); - } - - /** - * Loads the EAX functions - * - * @throws Exception if the EAX extensions couldn't be loaded - */ - public static void create() throws Exception { - if (created) { - return; - } + /** + * Loads the EAX functions + * + * @throws Exception if the EAX extensions couldn't be loaded + */ + public static void create() throws Exception { + if (created) { + return; + } - if (!nCreate()) { - throw new Exception("EAX instance could not be created."); - } - EAX20.init(); - created = true; - } + if (!nCreate()) { + throw new Exception("EAX instance could not be created."); + } + EAX20.init(); + created = true; + } - /** - * Native method to create EAX instance - * - * @return true if the EAX extensions could be found - */ - protected static native boolean nCreate(); + /** + * Native method to create EAX instance + * + * @return true if the EAX extensions could be found + */ + protected static native boolean nCreate(); - /** - * "Destroy" the EAX object - */ - public static void destroy() { - if (!created) { - return; - } - created = false; - nDestroy(); - } + /** + * "Destroy" the EAX object + */ + public static void destroy() { + if (!created) { + return; + } + created = false; + nDestroy(); + } - /** - * Native method the destroy the EAX - */ - protected static native void nDestroy(); - - /** - * @return true if EAX has been created - */ - public static boolean isCreated() { - return created; - } -} \ No newline at end of file + /** + * Native method the destroy the EAX + */ + protected static native void nDestroy(); + + /** + * @return true if EAX has been created + */ + public static boolean isCreated() { + return created; + } +} Index: EAXListenerProperties.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/eax/EAXListenerProperties.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- EAXListenerProperties.java 26 Feb 2004 21:51:57 -0000 1.11 +++ EAXListenerProperties.java 27 Mar 2004 13:48:58 -0000 1.12 @@ -34,6 +34,8 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; +import org.lwjgl.Sys; + /** * $Id$ * @@ -43,647 +45,647 @@ * @version $Revision$ */ [...1193 lines suppressed...] - /** - * Retrieves the size of the EAXLISTENERPROPERTIES - */ - protected static native int sizeOfEaxListenerProperties(); + /** + * Retrieves the size of the EAXLISTENERPROPERTIES + */ + protected static native int sizeOfEaxListenerProperties(); - /** - * Sets the offsets to the fields - */ - protected static native void assignOffsets(); -} \ No newline at end of file + /** + * Sets the offsets to the fields + */ + protected static native void assignOffsets(); +} Index: EAXBufferProperties.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/eax/EAXBufferProperties.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- EAXBufferProperties.java 26 Feb 2004 21:51:57 -0000 1.12 +++ EAXBufferProperties.java 27 Mar 2004 13:48:58 -0000 1.13 @@ -34,6 +34,8 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; +import org.lwjgl.Sys; + /** * $Id$ * @@ -45,594 +47,594 @@ * @version $Revision$ */ [...1099 lines suppressed...] + } + + // -------------------------------------------------------------------------- + + /** + * Retrieves the size of the EAXBUFFERPROPERTIES + */ + protected static native int sizeOfEaxBufferProperties(); - /** - * Sets the offsets to the fields - */ - protected static native void assignOffsets(); -} \ No newline at end of file + /** + * Sets the offsets to the fields + */ + protected static native void assignOffsets(); +} |
|
From: Elias N. <eli...@us...> - 2004-03-27 14:00:39
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24895/src/java/org/lwjgl/opengl Modified Files: GLContext.java Pbuffer.java Window.java Log Message: All classes use Sys.initialize now Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Pbuffer.java 7 Mar 2004 16:01:44 -0000 1.12 +++ Pbuffer.java 27 Mar 2004 13:48:58 -0000 1.13 @@ -155,7 +155,7 @@ private final int height; static { - System.loadLibrary(Sys.getLibraryName()); + Sys.initialize(); } /** Index: Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- Window.java 27 Mar 2004 11:55:07 -0000 1.32 +++ Window.java 27 Mar 2004 13:48:58 -0000 1.33 @@ -56,7 +56,7 @@ public final class Window { static { - System.loadLibrary(Sys.getLibraryName()); + Sys.initialize(); } /** X coordinate of the window */ Index: GLContext.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLContext.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- GLContext.java 18 Mar 2004 22:00:09 -0000 1.7 +++ GLContext.java 27 Mar 2004 13:48:58 -0000 1.8 @@ -167,7 +167,7 @@ public static boolean OpenGL15; static { - System.loadLibrary(Sys.getLibraryName()); + Sys.initialize(); } /** |
|
From: Elias N. <eli...@us...> - 2004-03-27 14:00:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24895/src/java/org/lwjgl/input Modified Files: Controller.java Cursor.java Keyboard.java Mouse.java Log Message: All classes use Sys.initialize now Index: Controller.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Controller.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Controller.java 27 Mar 2004 11:55:06 -0000 1.13 +++ Controller.java 27 Mar 2004 13:48:57 -0000 1.14 @@ -146,7 +146,9 @@ * Static initialization */ private static void initialize() { - System.loadLibrary(Sys.getLibraryName()); + if (initialized) + return; + Sys.initialize(); initIDs(); // Assign names to all the buttons @@ -166,9 +168,7 @@ public static void create() throws Exception { if (!Window.isCreated()) throw new IllegalStateException("Window must be created before you can create Controller"); - if (!initialized) { - initialize(); - } + initialize(); if (created) { return; Index: Cursor.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Cursor.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Cursor.java 27 Mar 2004 11:55:06 -0000 1.17 +++ Cursor.java 27 Mar 2004 13:48:57 -0000 1.18 @@ -49,10 +49,6 @@ */ public class Cursor { - - /** Lazy initialization */ - private static boolean initialized = false; - /** First element to display */ private CursorElement[] cursors = null; @@ -86,10 +82,7 @@ if (yHotspot >= height || yHotspot < 0) throw new IllegalArgumentException("yHotspot > height || yHotspot < 0"); - // initialize - if (!initialized) { - initialize(); - } + Sys.initialize(); // Hmm yHotspot = height - 1 - yHotspot; @@ -99,14 +92,6 @@ } /** - * Initializes the cursor class - */ - private static void initialize() { - System.loadLibrary(Sys.getLibraryName()); - initialized = true; - } - - /** * Creates the actual cursor, using a platform specific class */ private void createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception { Index: Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- Keyboard.java 27 Mar 2004 11:55:06 -0000 1.41 +++ Keyboard.java 27 Mar 2004 13:48:57 -0000 1.42 @@ -268,7 +268,9 @@ * Static initialization */ private static void initialize() { - System.loadLibrary(Sys.getLibraryName()); + if (initialized) + return; + Sys.initialize(); initIDs(); initialized = true; } Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- Mouse.java 27 Mar 2004 11:55:06 -0000 1.43 +++ Mouse.java 27 Mar 2004 13:48:57 -0000 1.44 @@ -217,7 +217,7 @@ * Static initialization */ private static void initialize() { - System.loadLibrary(Sys.getLibraryName()); + Sys.initialize(); initIDs(); // Assign names to all the buttons @@ -245,9 +245,7 @@ if (!Window.isCreated()) throw new IllegalStateException("Window must be created prior to creating mouse"); - if (!initialized) { - initialize(); - } + initialize(); if (created) { return; } |
|
From: Elias N. <eli...@us...> - 2004-03-27 14:00:34
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24895/src/java/org/lwjgl/openal Modified Files: AL.java ALC.java Log Message: All classes use Sys.initialize now Index: AL.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/AL.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- AL.java 8 Mar 2004 15:21:10 -0000 1.18 +++ AL.java 27 Mar 2004 13:48:58 -0000 1.19 @@ -77,14 +77,7 @@ protected static boolean created; static { - initialize(); - } - - /** - * Static initialization - */ - private static void initialize() { - System.loadLibrary(org.lwjgl.Sys.getLibraryName()); + Sys.initialize(); } /** Index: ALC.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/ALC.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- ALC.java 9 Mar 2004 11:03:08 -0000 1.14 +++ ALC.java 27 Mar 2004 13:48:58 -0000 1.15 @@ -34,6 +34,8 @@ import java.nio.Buffer; import java.nio.IntBuffer; +import org.lwjgl.Sys; + /** * $Id$ * @@ -140,7 +142,7 @@ public static final int ALC_OUT_OF_MEMORY = 0xA005; static { - initialize(); + Sys.initialize(); } /** Creates a new instance of ALC */ @@ -154,13 +156,6 @@ } /** - * Static initialization - */ - private static void initialize() { - System.loadLibrary(org.lwjgl.Sys.getLibraryName()); - } - - /** * Creates the ALC instance * * @throws Exception if a failiure occured in the ALC creation process |
|
From: Elias N. <eli...@us...> - 2004-03-27 14:00:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24895/src/java/org/lwjgl Modified Files: Display.java Sys.java Log Message: All classes use Sys.initialize now Index: Display.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Display.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- Display.java 27 Mar 2004 11:55:05 -0000 1.41 +++ Display.java 27 Mar 2004 13:48:57 -0000 1.42 @@ -75,7 +75,7 @@ public static final int PLATFORM_AGL = 2; static { - System.loadLibrary(Sys.getLibraryName()); + Sys.initialize(); init(); Sys.log("Adapter: "+getAdapter()+" Version: "+getVersion()); } Index: Sys.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Sys.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- Sys.java 7 Mar 2004 15:20:28 -0000 1.42 +++ Sys.java 27 Mar 2004 13:48:57 -0000 1.43 @@ -87,6 +87,8 @@ */ public static final boolean DEBUG = Boolean.getBoolean("org.lwjgl.Sys.debug"); + private static boolean initialized = false; + static { initialize(); @@ -123,7 +125,10 @@ /** * Initialization. */ - private static void initialize() { + public static void initialize() { + if (initialized) + return; + initialized = true; System.loadLibrary(LIBRARY_NAME); setDebug(DEBUG); setTime(0); |
|
From: Elias N. <eli...@us...> - 2004-03-27 12:06:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6869/src/java/org/lwjgl/input Modified Files: Controller.java Cursor.java Keyboard.java Mouse.java Log Message: Replaced asserts with proper runtime exceptions Index: Controller.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Controller.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Controller.java 26 Mar 2004 10:58:49 -0000 1.12 +++ Controller.java 27 Mar 2004 11:55:06 -0000 1.13 @@ -164,9 +164,8 @@ * @throws Exception if the controller could not be created for any reason */ public static void create() throws Exception { - - assert Window.isCreated() : "Window must be created prior to creating controller"; - + if (!Window.isCreated()) + throw new IllegalStateException("Window must be created before you can create Controller"); if (!initialized) { initialize(); } @@ -203,7 +202,8 @@ * Polls the controller. */ public static void poll() { - assert created : "The controller has not been created."; + if (!created) + throw new IllegalStateException("Controller must be created before you can poll the device"); nPoll(); } @@ -215,7 +215,8 @@ * @see #buttonCount */ public static boolean isButtonDown(int button) { - assert created : "The controller has not been created."; + if (!created) + throw new IllegalStateException("Controller must be created before you can query button state"); return buttons[button]; } @@ -231,7 +232,7 @@ * it always throws a RuntimeException. */ public static void read() { - throw new RuntimeException("Buffering is not implemented for Controllers."); + throw new UnsupportedOperationException("Buffering is not implemented for Controllers."); } /** Index: Cursor.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Cursor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Cursor.java 21 Mar 2004 21:54:55 -0000 1.16 +++ Cursor.java 27 Mar 2004 11:55:06 -0000 1.17 @@ -50,185 +50,190 @@ public class Cursor { - /** Lazy initialization */ - private static boolean initialized = false; - - /** First element to display */ - private CursorElement[] cursors = null; - - /** Index into list of cursors */ - private int index = -1; - - /** - * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create - * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported. - * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values. - * The constructor will copy the images and delays, so there's no need to keep them around. - * - * @param width cursor image width - * @param height cursor image height - * @param xHotspot the x coordinate of the cursor hotspot - * @param yHotspot the y coordinate of the cursor hotspot - * @param numImages number of cursor images specified. Must be 1 if animations are not supported. - * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL. - * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null - * @throws Exception if the cursor could not be created for any reason - */ - public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception { - assert Mouse.isCreated(); - assert width*height*numImages <= images.remaining() : "width*height*numImages > images.remaining()"; - assert delays == null || numImages <= delays.remaining() : "delays != null && numImages > delays.remaining()"; - assert xHotspot < width && xHotspot >= 0 : "xHotspot > width || xHotspot < 0"; - assert yHotspot < height && yHotspot >= 0 : "yHotspot > height || yHotspot < 0"; - - // initialize - if (!initialized) { - initialize(); - } - - // Hmm - yHotspot = height - 1 - yHotspot; - - // create cursor (or cursors if multiple images supplied) - createCursors(width, height, xHotspot, yHotspot, numImages, images, delays); - } - - /** - * Initializes the cursor class - */ - private static void initialize() { - System.loadLibrary(Sys.getLibraryName()); - initialized = true; - } + /** Lazy initialization */ + private static boolean initialized = false; + + /** First element to display */ + private CursorElement[] cursors = null; + + /** Index into list of cursors */ + private int index = -1; + + /** + * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create + * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported. + * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values. + * The constructor will copy the images and delays, so there's no need to keep them around. + * + * @param width cursor image width + * @param height cursor image height + * @param xHotspot the x coordinate of the cursor hotspot + * @param yHotspot the y coordinate of the cursor hotspot + * @param numImages number of cursor images specified. Must be 1 if animations are not supported. + * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL. + * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null + * @throws Exception if the cursor could not be created for any reason + */ + public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception { + if (!Mouse.isCreated()) + throw new IllegalStateException("Mouse must be created before creating cursor objects"); + if (width*height*numImages > images.remaining()) + throw new IllegalArgumentException("width*height*numImages > images.remaining()"); + if (delays != null && numImages > delays.remaining()) + throw new IllegalArgumentException("delays != null && numImages > delays.remaining()"); + if (xHotspot >= width || xHotspot < 0) + throw new IllegalArgumentException("xHotspot > width || xHotspot < 0"); + if (yHotspot >= height || yHotspot < 0) + throw new IllegalArgumentException("yHotspot > height || yHotspot < 0"); + + // initialize + if (!initialized) { + initialize(); + } + + // Hmm + yHotspot = height - 1 - yHotspot; + + // create cursor (or cursors if multiple images supplied) + createCursors(width, height, xHotspot, yHotspot, numImages, images, delays); + } + + /** + * Initializes the cursor class + */ + private static void initialize() { + System.loadLibrary(Sys.getLibraryName()); + initialized = true; + } - /** - * Creates the actual cursor, using a platform specific class - */ - private void createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception { - // create copy and flip images to match ogl - IntBuffer images_copy = ByteBuffer.allocateDirect(images.remaining()*4).order(ByteOrder.nativeOrder()).asIntBuffer(); - flipImages(width, height, numImages, images, images_copy); - - // create our cursor elements - cursors = new CursorElement[numImages]; - for(int i=0; i<numImages; i++) { - cursors[i] = new CursorElement(); - cursors[i].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, 1, images_copy, images_copy.position()); - cursors[i].delay = (delays != null) ? delays.get(i) : 0; - cursors[i].timeout = System.currentTimeMillis(); - - // offset to next image - images_copy.position(width*height*(i+1)); - } - - // set index - index = 0; - } + /** + * Creates the actual cursor, using a platform specific class + */ + private void createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception { + // create copy and flip images to match ogl + IntBuffer images_copy = ByteBuffer.allocateDirect(images.remaining()*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + flipImages(width, height, numImages, images, images_copy); + + // create our cursor elements + cursors = new CursorElement[numImages]; + for(int i=0; i<numImages; i++) { + cursors[i] = new CursorElement(); + cursors[i].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, 1, images_copy, images_copy.position()); + cursors[i].delay = (delays != null) ? delays.get(i) : 0; + cursors[i].timeout = System.currentTimeMillis(); + + // offset to next image + images_copy.position(width*height*(i+1)); + } + + // set index + index = 0; + } - - /** - * Flips the images so they're oriented according to opengl - * - * @param width Width of image - * @param height Height of images - * @param numImages How many images to flip - * @param images Source images - * @param images_copy Destination images - */ - private static void flipImages(int width, int height, int numImages, IntBuffer images, IntBuffer images_copy) { - for (int i = 0; i < numImages; i++) { - int start_index = i*width*height; - flipImage(width, height, start_index, images, images_copy); - } - } + + /** + * Flips the images so they're oriented according to opengl + * + * @param width Width of image + * @param height Height of images + * @param numImages How many images to flip + * @param images Source images + * @param images_copy Destination images + */ + private static void flipImages(int width, int height, int numImages, IntBuffer images, IntBuffer images_copy) { + for (int i = 0; i < numImages; i++) { + int start_index = i*width*height; + flipImage(width, height, start_index, images, images_copy); + } + } - /** - * @param width Width of image - * @param height Height of images - * @param start_index index into source buffer to copy to - * @param images Source images - * @param images_copy Destination images - */ - private static void flipImage(int width, int height, int start_index, IntBuffer images, IntBuffer images_copy) { - for (int y = 0; y < height>>1; y++) { - int index_y_1 = y*width + start_index; - int index_y_2 = (height - y - 1)*width + start_index; - for (int x = 0; x < width; x++) { - int index1 = index_y_1 + x; - int index2 = index_y_2 + x; - int temp_pixel = images.get(index1 + images.position()); - images_copy.put(index1, images.get(index2 + images.position())); - images_copy.put(index2, temp_pixel); - } - } - } - - /** - * Gets the native handle associated with the cursor object. - */ - public long getHandle() { - return cursors[index].cursorHandle; - } - - /** - * Destroy the native cursor. Cursor must not be current. - */ - public void destroy() { + /** + * @param width Width of image + * @param height Height of images + * @param start_index index into source buffer to copy to + * @param images Source images + * @param images_copy Destination images + */ + private static void flipImage(int width, int height, int start_index, IntBuffer images, IntBuffer images_copy) { + for (int y = 0; y < height>>1; y++) { + int index_y_1 = y*width + start_index; + int index_y_2 = (height - y - 1)*width + start_index; + for (int x = 0; x < width; x++) { + int index1 = index_y_1 + x; + int index2 = index_y_2 + x; + int temp_pixel = images.get(index1 + images.position()); + images_copy.put(index1, images.get(index2 + images.position())); + images_copy.put(index2, temp_pixel); + } + } + } + + /** + * Gets the native handle associated with the cursor object. + */ + public long getHandle() { + return cursors[index].cursorHandle; + } + + /** + * Destroy the native cursor. Cursor must not be current. + */ + public void destroy() { for(int i=0; i<cursors.length; i++) { - nDestroyCursor(cursors[i].cursorHandle); - } - } + nDestroyCursor(cursors[i].cursorHandle); + } + } - /** - * Sets the timout property to the time it should be changed - */ - protected void setTimeout() { - cursors[index].timeout = System.currentTimeMillis() + cursors[index].delay; - } + /** + * Sets the timout property to the time it should be changed + */ + protected void setTimeout() { + cursors[index].timeout = System.currentTimeMillis() + cursors[index].delay; + } - /** - * Determines whether this cursor has timed out - * @return true if the this cursor has timed out, false if not - */ - protected boolean hasTimedOut() { - return cursors.length > 1 && cursors[index].timeout < System.currentTimeMillis(); - } + /** + * Determines whether this cursor has timed out + * @return true if the this cursor has timed out, false if not + */ + protected boolean hasTimedOut() { + return cursors.length > 1 && cursors[index].timeout < System.currentTimeMillis(); + } - /** - * Changes to the next cursor - */ - protected void nextCursor() { - index = ++index % cursors.length; - } + /** + * Changes to the next cursor + */ + protected void nextCursor() { + index = ++index % cursors.length; + } - /** - * Resets the index of the cursor animation to the first in the list. - */ - public void resetAnimation() { - index = 0; - } - - /** - * Native method to create a native cursor - */ - private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset); + /** + * Resets the index of the cursor animation to the first in the list. + */ + public void resetAnimation() { + index = 0; + } + + /** + * Native method to create a native cursor + */ + private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset); - /** - * Native method to destroy a native cursor - */ - private static native void nDestroyCursor(long cursorHandle); - - /** - * A single cursor element, used when animating - */ - protected class CursorElement { - /** Handle to cursor */ - long cursorHandle; - - /** How long a delay this element should have */ - long delay; - - /** Absolute time this element times out */ - long timeout; - } + /** + * Native method to destroy a native cursor + */ + private static native void nDestroyCursor(long cursorHandle); + + /** + * A single cursor element, used when animating + */ + protected class CursorElement { + /** Handle to cursor */ + long cursorHandle; + + /** How long a delay this element should have */ + long delay; + + /** Absolute time this element times out */ + long timeout; + } } Index: Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- Keyboard.java 26 Mar 2004 21:57:56 -0000 1.40 +++ Keyboard.java 27 Mar 2004 11:55:06 -0000 1.41 @@ -285,7 +285,8 @@ * @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"; + if (!Window.isCreated()) + throw new IllegalStateException("Window must be created before you can create Keyboard"); if (!initialized) initialize(); if (created) @@ -334,7 +335,8 @@ * @see org.lwjgl.input.Keyboard#read() */ public static void poll() { - assert created : "The keyboard has not been created."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can poll the device"); nPoll(keyDownBuffer); } @@ -361,8 +363,10 @@ * @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."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can read events"); + if (readBuffer == null) + throw new IllegalStateException("Event buffering must be enabled before you can read events"); readBuffer.compact(); int numEvents = nRead(readBuffer, readBuffer.position()); if (translationEnabled) @@ -383,8 +387,10 @@ * and keyboard buffering must be enabled. */ public static void enableTranslation() throws Exception { - assert created : "The keyboard has not been created."; - assert readBuffer != null : "Keyboard buffering has not been enabled."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can read events"); + if (readBuffer == null) + throw new IllegalStateException("Event buffering must be enabled before you can read events"); nEnableTranslation(); translationEnabled = true; } @@ -398,7 +404,8 @@ * Enable keyboard buffering. Must be called after the keyboard is created. */ public static void enableBuffer() throws Exception { - assert created : "The keyboard has not been created."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can enable buffering"); readBuffer = BufferUtils.createByteBuffer(4*BUFFER_SIZE); readBuffer.limit(0); nEnableBuffer(); @@ -417,7 +424,8 @@ * @return true if the key is down according to the last poll() */ public static boolean isKeyDown(int key) { - assert created : "The keyboard has not been created."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can query key state"); return keyDownBuffer.get(key) != 0; } @@ -442,7 +450,8 @@ * @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."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can query key state"); return nisStateKeySet(key); } private static native int nisStateKeySet(int key); @@ -473,7 +482,8 @@ * @return the number of keyboard events */ public static int getNumKeyboardEvents() { - assert created : "The keyboard has not been created."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can read events"); if (translationEnabled) return readBuffer.remaining()/4; else @@ -492,8 +502,10 @@ * @return true if a keyboard event was read, false otherwise */ public static boolean next() { - assert created : "The keyboard has not been created."; - assert readBuffer != null : "Keyboard buffering has not been enabled."; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can read events"); + if (readBuffer == null) + throw new IllegalStateException("Event buffering must be enabled before you can read events"); if (readBuffer.hasRemaining()) { eventKey = readBuffer.get() & 0xFF; Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- Mouse.java 26 Mar 2004 21:57:56 -0000 1.42 +++ Mouse.java 27 Mar 2004 11:55:06 -0000 1.43 @@ -167,7 +167,10 @@ * @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); + if (!created) + throw new IllegalStateException("Create the Mouse before setting the native cursor"); + if ((getNativeCursorCaps() & CURSOR_ONE_BIT_TRANSPARENCY) == 0) + throw new IllegalStateException("Mouse doesn't support native cursors"); Cursor oldCursor = currentCursor; currentCursor = cursor; if (currentCursor != null) { @@ -239,7 +242,8 @@ */ public static void create() throws Exception { - assert Window.isCreated() : "Window must be created prior to creating mouse"; + if (!Window.isCreated()) + throw new IllegalStateException("Window must be created prior to creating mouse"); if (!initialized) { initialize(); @@ -327,7 +331,8 @@ * @see org.lwjgl.input.Mouse#read() */ public static void poll() { - assert created : "The mouse has not been created."; + if (!created) + throw new IllegalStateException("Mouse must be created before you can poll it"); nPoll(); // set absolute position @@ -363,7 +368,8 @@ * @return true if the specified button is down */ public static boolean isButtonDown(int button) { - assert created : "The mouse has not been created."; + if (!created) + throw new IllegalStateException("Mouse must be created before you can poll the button state"); if (button >= buttonCount || button < 0) return false; else @@ -398,7 +404,8 @@ * Enable mouse button buffering. Must be called after the mouse is created. */ public static void enableBuffer() throws Exception { - assert created : "The mouse has not been created."; + if (!created) + throw new IllegalStateException("Mouse must be created before you can enable buffering"); readBuffer = BufferUtils.createByteBuffer(2*BUFFER_SIZE); readBuffer.limit(0); nEnableBuffer(); @@ -424,8 +431,10 @@ * @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."; + if (!created) + throw new IllegalStateException("Mouse must be created before you can read events"); + if (readBuffer == null) + throw new IllegalStateException("Event buffering must be enabled before you can read events"); readBuffer.compact(); int numEvents = nRead(readBuffer, readBuffer.position()); readBuffer.position(readBuffer.position() + numEvents*2); @@ -447,8 +456,10 @@ * @return true if a mouse event was read, false otherwise */ public static boolean next() { - assert created : "The mouse has not been created."; - assert readBuffer != null : "Mouse buffering has not been enabled."; + if (!created) + throw new IllegalStateException("Mouse must be created before you can read events"); + if (readBuffer == null) + throw new IllegalStateException("Event buffering must be enabled before you can read events"); if (readBuffer.hasRemaining()) { eventButton = readBuffer.get() & 0xFF; |
|
From: Elias N. <eli...@us...> - 2004-03-27 12:06:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6869/src/java/org/lwjgl/opengl Modified Files: ARBVertexBufferObject.java ARBVertexShader.java ATIDrawBuffers.java GL15.java Window.java Log Message: Replaced asserts with proper runtime exceptions Index: Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Window.java 26 Mar 2004 11:09:39 -0000 1.31 +++ Window.java 27 Mar 2004 11:55:07 -0000 1.32 @@ -108,7 +108,8 @@ * @return the width of the window */ public static int getWidth() { - assert isCreated() : "Cannot get width on uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot get width on uncreated window"); return width; } @@ -116,7 +117,8 @@ * @return the height of the window */ public static int getHeight() { - assert isCreated() : "Cannot get height on uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot get height on uncreated window"); return height; } @@ -124,15 +126,17 @@ * @return the title of the window */ public static String getTitle() { - assert isCreated() : "Cannot get title on uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot get title on uncreated window"); return title; } - + /** * @return whether this window is in fullscreen mode */ public static boolean isFullscreen() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine fullscreen state of uncreated window"); return fullscreen; } @@ -141,7 +145,8 @@ * @param newTitle The new window title */ public static void setTitle(String newTitle) { - assert isCreated() : "Cannot set title of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot set title on uncreated window"); title = newTitle; nSetTitle(title); } @@ -156,7 +161,8 @@ * @return true if the user or operating system has asked the window to close */ public static boolean isCloseRequested() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine close requested state of uncreated window"); return nIsCloseRequested(); } @@ -166,7 +172,8 @@ * @return true if the window is minimized or otherwise not visible */ public static boolean isMinimized() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine minimized state of uncreated window"); return nIsMinimized(); } @@ -176,7 +183,8 @@ * @return true if window is focused */ public static boolean isFocused() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine focused state of uncreated window"); return nIsFocused(); } @@ -210,7 +218,8 @@ * and needs to repaint itself */ public static boolean isDirty() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine dirty state of uncreated window"); return nIsDirty(); } @@ -222,7 +231,8 @@ * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() */ public static void update() { - assert isCreated() : "Cannot paint uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine update uncreated window"); nUpdate(); if ((isDirty() && !isMinimized()) || (isFocused() && !isMinimized())) { Util.checkGLError(); @@ -259,7 +269,8 @@ * Make the Window the current rendering context for GL calls. */ public static synchronized void makeCurrent() { - assert isCreated() : "No window has been created."; + if (!isCreated()) + throw new IllegalStateException("No window created to make current"); nMakeCurrent(); GLContext.useContext(context); } @@ -315,7 +326,7 @@ */ public static void create(String title, int bpp, int alpha, int depth, int stencil, int samples) throws Exception { if (isCreated()) - throw new Exception("Only one LWJGL window may be instantiated at any one time."); + throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time."); Window.fullscreen = true; Window.x = 0; Window.y = 0; @@ -371,7 +382,7 @@ public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil, int samples) throws Exception { if (isCreated()) - throw new Exception("Only one LWJGL window may be instantiated at any one time."); + throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time."); Window.fullscreen = false; Window.x = x; Window.y = y; @@ -518,7 +529,8 @@ * @return boolean */ public static boolean isVSyncEnabled() { - assert isCreated() : "Cannot determine sync of uncreated window"; + if (isCreated()) + throw new IllegalStateException("Cannot determine vsync state of uncreated window"); return nIsVSyncEnabled(); } @@ -531,11 +543,10 @@ * @param sync true to synchronize; false to ignore synchronization */ public static void setVSyncEnabled(boolean sync) { - assert isCreated() : "Cannot set sync of uncreated window"; + if (isCreated()) + throw new IllegalStateException("Cannot set vsync state of uncreated window"); nSetVSyncEnabled(sync); } private static native void nSetVSyncEnabled(boolean sync); - - } Index: ARBVertexShader.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBVertexShader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ARBVertexShader.java 15 Mar 2004 16:31:09 -0000 1.4 +++ ARBVertexShader.java 27 Mar 2004 11:55:07 -0000 1.5 @@ -67,7 +67,7 @@ // --------------------------- public static void glBindAttribLocationARB(int programObj, int index, ByteBuffer name) { if ( name.get(name.limit() - 1) != 0 ) { - throw new RuntimeException("<name> must be a null-terminated string."); + throw new IllegalArgumentException("<name> must be a null-terminated string."); } nglBindAttribLocationARB(programObj, index, name, name.position()); } @@ -99,7 +99,7 @@ // --------------------------- public static int glGetAttribLocationARB(int programObj, ByteBuffer name) { if ( name.get(name.limit() - 1) != 0 ) { - throw new RuntimeException("<name> must be a null-terminated string."); + throw new IllegalArgumentException("<name> must be a null-terminated string."); } return nglGetAttribLocationARB(programObj, name, name.position()); } @@ -107,4 +107,4 @@ private static native int nglGetAttribLocationARB(int programObj, ByteBuffer name, int nameOffset); // --------------------------- -} \ No newline at end of file +} Index: ATIDrawBuffers.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ATIDrawBuffers.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ATIDrawBuffers.java 18 Feb 2004 23:54:45 -0000 1.3 +++ ATIDrawBuffers.java 27 Mar 2004 11:55:07 -0000 1.4 @@ -68,7 +68,7 @@ // --------------------------- public static void glDrawBuffersATI(IntBuffer buffers) { if (buffers.remaining() == 0) { - throw new RuntimeException("<buffers> must have at least 1 integer available."); + throw new IllegalArgumentException("<buffers> must have at least 1 integer available."); } nglDrawBuffersATI(buffers.remaining(), buffers, buffers.position()); } @@ -76,4 +76,4 @@ private static native void nglDrawBuffersATI(int size, IntBuffer buffers, int buffersOffset); // --------------------------- -} \ No newline at end of file +} Index: GL15.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GL15.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- GL15.java 18 Feb 2004 23:54:46 -0000 1.3 +++ GL15.java 27 Mar 2004 11:55:07 -0000 1.4 @@ -87,7 +87,7 @@ VBOTracker.getVBOArrayStack().setState(buffer); break; default: - assert false: "Unsupported VBO target " + target; + throw new IllegalArgumentException("Unsupported VBO target " + target); } nglBindBuffer(target, buffer); } @@ -296,4 +296,4 @@ int paramsOffset); // --------------------------- -} \ No newline at end of file +} Index: ARBVertexBufferObject.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBVertexBufferObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ARBVertexBufferObject.java 18 Feb 2004 23:54:45 -0000 1.3 +++ ARBVertexBufferObject.java 27 Mar 2004 11:55:07 -0000 1.4 @@ -89,7 +89,7 @@ case GL_ARRAY_BUFFER_ARB: VBOTracker.getVBOArrayStack().setState(buffer); break; - default: assert false: "Unsupported VBO target " + target; + default: throw new IllegalArgumentException("Unsupported VBO target " + target); } nglBindBufferARB(target, buffer); } |
|
From: Elias N. <eli...@us...> - 2004-03-27 12:06:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6869/src/java/org/lwjgl/openal Modified Files: AL10.java Log Message: Replaced asserts with proper runtime exceptions Index: AL10.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/AL10.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AL10.java 9 Mar 2004 11:03:08 -0000 1.2 +++ AL10.java 27 Mar 2004 11:55:06 -0000 1.3 @@ -44,321 +44,321 @@ * @version $Revision$ */ public final class AL10 { - - /** Bad value */ - public static final int AL_INVALID = -1; + + /** Bad value */ + public static final int AL_INVALID = -1; - /** Disable value */ [...1756 lines suppressed...] + * abs(vs) is greater or equal VD. + * </p> + * <p> + * There are two API calls global to the current context that provide control of the two + * related parameters. + * </p> + * <p> + * AL_DOPPLER_VELOCITY allows the application to change the reference (propagation) + * velocity used in the Doppler Effect calculation. This permits the application to use a + * velocity scale appropriate to its purposes. + * </p> + * <p> + * A negative or zero value will result in an AL_INVALID_VALUE error, the command is + * then ignored. The default value is 1. The current setting can be queried using + * GetFloatv and AL_DOPPLER_VELOCITY. + * </p> + * * @param value Doppler velocity value to set */ public static native void alDopplerVelocity(float value); |
|
From: Elias N. <eli...@us...> - 2004-03-27 12:06:16
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6869/src/java/org/lwjgl Modified Files: Display.java Log Message: Replaced asserts with proper runtime exceptions Index: Display.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Display.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- Display.java 15 Feb 2004 21:45:03 -0000 1.40 +++ Display.java 27 Mar 2004 11:55:05 -0000 1.41 @@ -196,8 +196,10 @@ * @param contrast The contrast, larger than 0.0. */ public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws Exception { - assert brightness >= -1.0f && brightness <= 1.0f; - assert contrast >= 0.0f; + if (brightness < -1.0f || brightness > 1.0f) + throw new IllegalArgumentException("Invalid brightness value"); + if (contrast < 0.0f) + throw new IllegalArgumentException("Invalid contrast value"); int rampSize = getGammaRampLength(); if (rampSize == 0) { throw new Exception("Display configuration not supported"); |
|
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); } |