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
|
From: <eli...@us...> - 2007-04-28 20:10:36
|
Revision: 2808 http://svn.sourceforge.net/java-game-lib/?rev=2808&view=rev Author: elias_naur Date: 2007-04-28 13:10:21 -0700 (Sat, 28 Apr 2007) Log Message: ----------- Make sure the swap interval is reset in Display when switching Display modes and toggling fullscreen Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2007-04-26 07:13:02 UTC (rev 2807) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2007-04-28 20:10:21 UTC (rev 2808) @@ -223,7 +223,7 @@ if (fullscreen) switchDisplayMode(); createWindow(); - makeCurrent(); + makeCurrentAndSetSwapInterval(); } catch (LWJGLException e) { destroyContext(); destroyPeerInfo(); @@ -475,7 +475,7 @@ display_impl.resetDisplayMode(); } createWindow(); - makeCurrent(); + makeCurrentAndSetSwapInterval(); } catch (LWJGLException e) { destroyContext(); destroyPeerInfo(); @@ -744,7 +744,7 @@ try { context = new Context(peer_info, shared_drawable != null ? shared_drawable.getContext() : null); try { - makeCurrent(); + makeCurrentAndSetSwapInterval(); initContext(); } catch (LWJGLException e) { destroyContext(); @@ -765,8 +765,12 @@ } } + private static void makeCurrentAndSetSwapInterval() throws LWJGLException { + makeCurrent(); + setSwapInterval(swap_interval); + } + private static void initContext() { - setSwapInterval(swap_interval); // Put the window into orthographic projection mode with 1:1 pixel ratio. // We haven't used GLU here to do this to avoid an unnecessary dependency. GL11.glMatrixMode(GL11.GL_PROJECTION); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: lerrenzo G. <Gop...@ar...> - 2007-04-27 07:24:16
|
wide WATCH OJU.F TRADE LIKE CRAZY ON FRIDAY! THIS FRANKFURT STOCK IS GOING THROUGH THE ROOF! COMPANY: ORAMED PHARMA SYMBOL: OJU.F PRICE: 0.65 TARGET: 2.15 WKN : A0J3FG ISIN : US68403P1049 WE ARE PREDICTING AMAZING GAINS ON THIS ONE! BE PART OF IT! ADD IT TO YOUR PORTFOLIO! WATCH OJU.F ON FRIDAY APRIL 27TH! Selection Procedures Code Conduct Committee Form Contact |
From: <eli...@us...> - 2007-04-26 07:13:05
|
Revision: 2807 http://svn.sourceforge.net/java-game-lib/?rev=2807&view=rev Author: elias_naur Date: 2007-04-26 00:13:02 -0700 (Thu, 26 Apr 2007) Log Message: ----------- Reverted accidental build.xml change Modified Paths: -------------- trunk/LWJGL/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2007-04-26 06:55:55 UTC (rev 2806) +++ trunk/LWJGL/build.xml 2007-04-26 07:13:02 UTC (rev 2807) @@ -306,7 +306,7 @@ <target name="all" description="Creates the Java archives and the natives for the current platform" depends="jars, compile_native"/> <!-- Create ONLY the jar archives --> - <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, compile, -createjars"> + <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, generate-all, compile, -createjars"> <move todir="libs/"> <fileset dir="${lwjgl.temp}/jar"> <include name="*.jar"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-26 06:55:56
|
Revision: 2806 http://svn.sourceforge.net/java-game-lib/?rev=2806&view=rev Author: elias_naur Date: 2007-04-25 23:55:55 -0700 (Wed, 25 Apr 2007) Log Message: ----------- Added output of character code value to KeyboardTest Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java 2007-04-26 05:58:35 UTC (rev 2805) +++ trunk/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java 2007-04-26 06:55:55 UTC (rev 2806) @@ -147,8 +147,10 @@ int count = Keyboard.getNumKeyboardEvents(); while (Keyboard.next()) { + int character_code = ((int)Keyboard.getEventCharacter()) & 0xffff; System.out.println("Checking key:" + Keyboard.getKeyName(Keyboard.getEventKey())); System.out.println("Pressed:" + Keyboard.getEventKeyState()); + System.out.println("Key character code: " + character_code); System.out.println("Key character: " + Keyboard.getEventCharacter()); if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-26 05:58:37
|
Revision: 2805 http://svn.sourceforge.net/java-game-lib/?rev=2805&view=rev Author: elias_naur Date: 2007-04-25 22:58:35 -0700 (Wed, 25 Apr 2007) Log Message: ----------- Simplified ALC10.nalcOpenDevice Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2007-04-24 14:41:17 UTC (rev 2804) +++ trunk/LWJGL/build.xml 2007-04-26 05:58:35 UTC (rev 2805) @@ -306,7 +306,7 @@ <target name="all" description="Creates the Java archives and the natives for the current platform" depends="jars, compile_native"/> <!-- Create ONLY the jar archives --> - <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, generate-all, compile, -createjars"> + <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, compile, -createjars"> <move todir="libs/"> <fileset dir="${lwjgl.temp}/jar"> <include name="*.jar"/> Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2007-04-24 14:41:17 UTC (rev 2804) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2007-04-26 05:58:35 UTC (rev 2805) @@ -139,18 +139,10 @@ /* get device */ device = alcOpenDevice((ALubyte *) tokenstring); - /* if error - cleanup and get out */ - if(device == NULL) { - if(tokenstring != NULL) { - free(tokenstring); - } - return (jlong) NULL; + if(tokenstring != NULL) { + free(tokenstring); } - /* clean up */ - if (tokenstring != NULL) - free(tokenstring); - return (jlong)((intptr_t)device); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Phillippe K. <Ku...@al...> - 2007-04-25 08:08:08
|
Database |
From: <eli...@us...> - 2007-04-24 14:41:20
|
Revision: 2804 http://svn.sourceforge.net/java-game-lib/?rev=2804&view=rev Author: elias_naur Date: 2007-04-24 07:41:17 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Use TranslateMessage and WM_CHAR to receive character input instead of manual translation. This change fixes composed characters. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 14:13:42 UTC (rev 2803) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 14:41:17 UTC (rev 2804) @@ -62,8 +62,9 @@ private final static int WM_MOUSEWHEEL = 0x020A; private final static int WM_KEYDOWN = 256; private final static int WM_KEYUP = 257; - private final static int WM_SYSKEYUP = 261; - private final static int WM_SYSKEYDOWN = 260; + private final static int WM_SYSKEYUP = 261; + private final static int WM_SYSKEYDOWN = 260; + private final static int WM_CHAR = 258; private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; @@ -595,6 +596,15 @@ private static native void getClientRect(long hwnd, IntBuffer rect); + private void handleChar(long wParam, long lParam, long millis) { + byte previous_state = (byte)((lParam >>> 30) & 0x1); + byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); + if (state == previous_state) + return; // Auto-repeat message + if (keyboard != null) + keyboard.handleChar((int)(wParam & 0xFF), millis); + } + private void handleKeyButton(long wParam, long lParam, long millis) { byte previous_state = (byte)((lParam >>> 30) & 0x1); byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); @@ -682,6 +692,9 @@ case WM_MBUTTONUP: handleMouseButton(2, 0, millis); return true; + case WM_CHAR: + handleChar(wParam, lParam, millis); + return true; case WM_SYSKEYDOWN: /* Fall through */ case WM_SYSKEYUP: /* Fall through */ case WM_KEYUP: /* Fall through */ Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 14:13:42 UTC (rev 2803) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 14:41:17 UTC (rev 2804) @@ -55,24 +55,18 @@ private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); - private final boolean unicode; - private final CharBuffer unicode_buffer; - private final ByteBuffer ascii_buffer; private boolean grabbed; + private boolean has_retained_event; // Indicates if we're waiting for a WM_CHAR + private int retained_key_code; + private byte retained_state; + private int retained_char; + private long retained_millis; + public WindowsKeyboard(long hwnd) throws LWJGLException { this.hwnd = hwnd; keyboard_state = BufferUtils.createByteBuffer(256); - unicode = isWindowsNT(); - if (unicode) { - unicode_buffer = BufferUtils.createCharBuffer(BUFFER_SIZE); - ascii_buffer = null; - } else { - unicode_buffer = null; - // ToAscii returns at most 2 characters - ascii_buffer = BufferUtils.createByteBuffer(2); - } } private static native boolean isWindowsNT(); @@ -97,66 +91,15 @@ keyDownBuffer.position(old_position); } - private void translate(int virt_key, byte state, long nanos) { - int keycode = MapVirtualKey(virt_key, MAPVK_VK_TO_VSC); - if (state != 0) { - if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { - // Mark key down in the scan code - int key_down_code = keycode & 0x7fff; - int num_chars; - if (unicode) { - unicode_buffer.clear(); - num_chars = ToUnicode(virt_key, - key_down_code, - keyboard_state, - unicode_buffer, - unicode_buffer.capacity(), 0); - } else { - ascii_buffer.clear(); - num_chars = ToAscii(virt_key, - key_down_code, - keyboard_state, - ascii_buffer, - 0); - } - if (num_chars > 0) { - int current_char = 0; - do { - int char_int; - if (unicode) { - char_int = ((int)unicode_buffer.get()) & 0xFFFF; - } else { - char_int = ((int)ascii_buffer.get()) & 0xFF; - } - if (current_char >= 1) { - putEvent(0, (byte)0, char_int, nanos); - } else { - putEvent(virt_key, state, char_int, nanos); - } - current_char++; - } while (current_char < num_chars); - } else { - putEvent(virt_key, state, 0, nanos); - } - } else { - putEvent(virt_key, state, 0, nanos); - } - } else { - putEvent(virt_key, state, 0, nanos); - } - } private static native int MapVirtualKey(int uCode, int uMapType); private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags); private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags); private static native int GetKeyboardState(ByteBuffer lpKeyState); private static native int GetKeyState(int virt_key); - private void putEvent(int virt_key, byte state, int ch, long nanos) { - int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); - if (keycode < key_down_buffer.length) - key_down_buffer[keycode] = state; + private void putEvent(int keycode, byte state, int ch, long millis) { tmp_event.clear(); - tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(millis*1000000); tmp_event.flip(); event_queue.putEvent(tmp_event); } @@ -198,13 +141,36 @@ } } + private void flushRetained() { + if (has_retained_event) { + has_retained_event = false; + putEvent(retained_key_code, retained_state, retained_char, retained_millis); + } + } + public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis) { - if (isWindowsNT()) - virt_key = translateExtended(virt_key, scan_code, event_state, extended); - translate(virt_key, event_state, millis*1000000); + virt_key = translateExtended(virt_key, scan_code, event_state, extended); + flushRetained(); + has_retained_event = true; + int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); + if (keycode < key_down_buffer.length) + key_down_buffer[keycode] = event_state; + retained_key_code = keycode; + retained_state = event_state; + retained_millis = millis; + retained_char = 0; +// translate(virt_key, event_state, millis*1000000); } + public void handleChar(int event_char, long millis) { + if (!has_retained_event) { + putEvent(0, (byte)0, event_char, millis); + } else + retained_char = event_char; + } + public void read(ByteBuffer buffer) { + flushRetained(); event_queue.copyEvents(buffer); } } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-24 14:13:42 UTC (rev 2803) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-24 14:41:17 UTC (rev 2804) @@ -148,6 +148,7 @@ )) { DispatchMessage(&msg); + TranslateMessage(&msg); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 14:13:43
|
Revision: 2803 http://svn.sourceforge.net/java-game-lib/?rev=2803&view=rev Author: elias_naur Date: 2007-04-24 07:13:42 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Call default handler on key events Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 13:41:31 UTC (rev 2802) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 14:13:42 UTC (rev 2803) @@ -687,7 +687,7 @@ case WM_KEYUP: /* Fall through */ case WM_KEYDOWN: handleKeyButton(wParam, lParam, millis); - return true; + return false; case WM_QUIT: close_requested = true; return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 13:41:32
|
Revision: 2802 http://svn.sourceforge.net/java-game-lib/?rev=2802&view=rev Author: elias_naur Date: 2007-04-24 06:41:31 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Removed debug output Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2007-04-24 13:40:13 UTC (rev 2801) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2007-04-24 13:41:31 UTC (rev 2802) @@ -297,7 +297,7 @@ private static void switchDisplayMode() throws LWJGLException { if (!current_mode.isFullscreen()) { - System.out.println("Switching to "+initial_mode); + LWJGLUtil.log("Switching to "+initial_mode); setDisplayMode(initial_mode); } display_impl.switchDisplayMode(current_mode); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:40:13 UTC (rev 2801) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:41:31 UTC (rev 2802) @@ -153,7 +153,6 @@ private void putEvent(int virt_key, byte state, int ch, long nanos) { int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); -System.out.println("virt_key = " + Integer.toHexString(virt_key) + " = " + virt_key + " | keycode = " + Keyboard.getKeyName(keycode)); if (keycode < key_down_buffer.length) key_down_buffer[keycode] = state; tmp_event.clear(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 13:40:16
|
Revision: 2801 http://svn.sourceforge.net/java-game-lib/?rev=2801&view=rev Author: elias_naur Date: 2007-04-24 06:40:13 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Convert WindowsKeyboard to use windows messages instead of DirectInput. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 13:22:35 UTC (rev 2800) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 13:40:13 UTC (rev 2801) @@ -60,6 +60,10 @@ private final static int WM_MBUTTONUP = 0x0208; private final static int WM_MBUTTONDBLCLK = 0x0209; private final static int WM_MOUSEWHEEL = 0x020A; + private final static int WM_KEYDOWN = 256; + private final static int WM_KEYUP = 257; + private final static int WM_SYSKEYUP = 261; + private final static int WM_SYSKEYDOWN = 260; private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; @@ -174,6 +178,15 @@ rect.offset(offset_x, offset_y); } + static WindowsDirectInput createDirectInput() throws LWJGLException { + try { + return new WindowsDirectInput8(getDllInstance()); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3"); + return new WindowsDirectInput3(getDllInstance()); + } + } + static void setupCursorClipping(long hwnd) throws LWJGLException { cursor_clipped = true; getGlobalClientRect(hwnd, rect); @@ -453,7 +466,7 @@ /* Keyboard */ public void createKeyboard() throws LWJGLException { - keyboard = new WindowsKeyboard(createDirectInput(), getHwnd()); + keyboard = new WindowsKeyboard(getHwnd()); } public void destroyKeyboard() { @@ -582,6 +595,17 @@ private static native void getClientRect(long hwnd, IntBuffer rect); + private void handleKeyButton(long wParam, long lParam, long millis) { + byte previous_state = (byte)((lParam >>> 30) & 0x1); + byte state = (byte)(1 - ((lParam >>> 31) & 0x1)); + if (state == previous_state) + return; // Auto-repeat message + byte extended = (byte)((lParam >>> 24) & 0x1); + int scan_code = (int)((lParam >>> 16) & 0xFF); + if (keyboard != null) + keyboard.handleKey((int)wParam, scan_code, extended != 0, state, millis); + } + private static int transformY(long hwnd, int y) { getClientRect(hwnd, rect_buffer); rect.copyFromBuffer(rect_buffer); @@ -658,6 +682,12 @@ case WM_MBUTTONUP: handleMouseButton(2, 0, millis); return true; + case WM_SYSKEYDOWN: /* Fall through */ + case WM_SYSKEYUP: /* Fall through */ + case WM_KEYUP: /* Fall through */ + case WM_KEYDOWN: + handleKeyButton(wParam, lParam, millis); + return true; case WM_QUIT: close_requested = true; return true; @@ -683,15 +713,6 @@ } } - static WindowsDirectInput createDirectInput() throws LWJGLException { - try { - return new WindowsDirectInput8(getDllInstance()); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3"); - return new WindowsDirectInput3(getDllInstance()); - } - } - public int getWidth() { return Display.getDisplayMode().getWidth(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:22:35 UTC (rev 2800) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:40:13 UTC (rev 2801) @@ -43,40 +43,26 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.BufferUtils; +import org.lwjgl.input.Keyboard; final class WindowsKeyboard { + private final static int MAPVK_VK_TO_VSC = 0; + private final static int BUFFER_SIZE = 50; private final long hwnd; - private final WindowsDirectInput dinput; - private final WindowsDirectInputDevice keyboard; - private final IntBuffer temp_data_buffer; private final ByteBuffer keyboard_state; + private final byte[] key_down_buffer = new byte[Keyboard.KEYBOARD_SIZE]; + private final EventQueue event_queue = new EventQueue(Keyboard.EVENT_SIZE); + private final ByteBuffer tmp_event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); private final boolean unicode; private final CharBuffer unicode_buffer; private final ByteBuffer ascii_buffer; private boolean grabbed; - public WindowsKeyboard(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + public WindowsKeyboard(long hwnd) throws LWJGLException { this.hwnd = hwnd; - this.dinput = dinput; - try { - keyboard = dinput.createDevice(WindowsDirectInput.KEYBOARD_TYPE); - try { - keyboard.setDataFormat(WindowsDirectInput.KEYBOARD_TYPE); - keyboard.setBufferSize(BUFFER_SIZE); - acquireNonExclusive(); - } catch (LWJGLException e) { - keyboard.release(); - throw e; - } - } catch (LWJGLException e) { - dinput.release(); - throw e; - } - keyboard.acquire(); - temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); keyboard_state = BufferUtils.createByteBuffer(256); unicode = isWindowsNT(); if (unicode) { @@ -90,165 +76,136 @@ } private static native boolean isWindowsNT(); - private boolean acquire(int flags) { - try { - keyboard.setCooperateLevel(hwnd, flags); - keyboard.acquire(); - return true; - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to acquire keyboard: " + e); - return false; - } - } - - private boolean acquireNonExclusive() { - return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || - acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); - } - public void destroy() { - keyboard.unacquire(); - keyboard.release(); - dinput.release(); } public void grab(boolean grab) { if(grab) { if (!grabbed) { - flush(); grabbed = true; - keyboard.unacquire(); - if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) - LWJGLUtil.log("Failed to reset cooperative mode"); } } else { if (grabbed) { grabbed = false; - keyboard.unacquire(); - acquireNonExclusive(); } } } public void poll(ByteBuffer keyDownBuffer) { - int ret = keyboard.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - keyboard.poll(); - ret = keyboard.getDeviceState(keyDownBuffer); - switch (ret) { - case WindowsDirectInput.DI_OK: - break; - case WindowsDirectInput.DI_BUFFEROVERFLOW: - LWJGLUtil.log("Keyboard buffer overflow"); - break; - case WindowsDirectInput.DIERR_INPUTLOST: - break; - case WindowsDirectInput.DIERR_NOTACQUIRED: - break; - default: - LWJGLUtil.log("Failed to poll keyboard (0x" + Integer.toHexString(ret) + ")"); - break; - } + int old_position = keyDownBuffer.position(); + keyDownBuffer.put(key_down_buffer); + keyDownBuffer.position(old_position); } - private void translateData(IntBuffer src, ByteBuffer dst) { - while (dst.hasRemaining() && src.hasRemaining()) { - int dwOfs = src.get(); - dst.putInt(dwOfs); - byte dwData = (byte)src.get(); - boolean key_down = (dwData & 0x80) != 0; - dst.put(key_down ? (byte)1 : (byte)0); - long dwTimeStamp = ((long)src.get()) & 0xFFFFFFFF; - long nanos = dwTimeStamp*1000000; - if (key_down) { - int virt_key = MapVirtualKey(dwOfs, 1); - if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { - // Mark key down in the scan code - dwOfs = dwOfs & 0x7fff; - int num_chars; - if (unicode) { - unicode_buffer.clear(); - num_chars = ToUnicode(virt_key, - dwOfs, + private void translate(int virt_key, byte state, long nanos) { + int keycode = MapVirtualKey(virt_key, MAPVK_VK_TO_VSC); + if (state != 0) { + if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { + // Mark key down in the scan code + int key_down_code = keycode & 0x7fff; + int num_chars; + if (unicode) { + unicode_buffer.clear(); + num_chars = ToUnicode(virt_key, + key_down_code, keyboard_state, unicode_buffer, unicode_buffer.capacity(), 0); - } else { - ascii_buffer.clear(); - num_chars = ToAscii(virt_key, - dwOfs, + } else { + ascii_buffer.clear(); + num_chars = ToAscii(virt_key, + key_down_code, keyboard_state, ascii_buffer, 0); - } - if (num_chars > 0) { - int current_char = 0; - do { - if (current_char >= 1) { - dst.putInt(0); - dst.put((byte)0); - } - int char_int; - if (unicode) { - char_int = ((int)unicode_buffer.get()) & 0xFFFF; - } else { - char_int = ((int)ascii_buffer.get()) & 0xFF; - } - dst.putInt(char_int); - dst.putLong(nanos); - current_char++; - } while (dst.hasRemaining() && current_char < num_chars); - } else { - dst.putInt(0); - dst.putLong(nanos); - } + } + if (num_chars > 0) { + int current_char = 0; + do { + int char_int; + if (unicode) { + char_int = ((int)unicode_buffer.get()) & 0xFFFF; + } else { + char_int = ((int)ascii_buffer.get()) & 0xFF; + } + if (current_char >= 1) { + putEvent(0, (byte)0, char_int, nanos); + } else { + putEvent(virt_key, state, char_int, nanos); + } + current_char++; + } while (current_char < num_chars); } else { - dst.putInt(0); - dst.putLong(nanos); + putEvent(virt_key, state, 0, nanos); } } else { - dst.putInt(0); - dst.putLong(nanos); + putEvent(virt_key, state, 0, nanos); } + } else { + putEvent(virt_key, state, 0, nanos); } } private static native int MapVirtualKey(int uCode, int uMapType); private static native int ToUnicode(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, CharBuffer pwszBuff, int cchBuff, int flags); private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags); private static native int GetKeyboardState(ByteBuffer lpKeyState); + private static native int GetKeyState(int virt_key); - public void flush() { - processEvents(); - temp_data_buffer.clear(); + private void putEvent(int virt_key, byte state, int ch, long nanos) { + int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); +System.out.println("virt_key = " + Integer.toHexString(virt_key) + " = " + virt_key + " | keycode = " + Keyboard.getKeyName(keycode)); + if (keycode < key_down_buffer.length) + key_down_buffer[keycode] = state; + tmp_event.clear(); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos); + tmp_event.flip(); + event_queue.putEvent(tmp_event); } - private void processEvents() { - int ret = keyboard.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - keyboard.poll(); - temp_data_buffer.clear(); - ret = keyboard.getDeviceData(temp_data_buffer); - switch (ret) { - case WindowsDirectInput.DI_OK: - break; - case WindowsDirectInput.DI_BUFFEROVERFLOW: - LWJGLUtil.log("Keyboard buffer overflow"); - break; - case WindowsDirectInput.DIERR_INPUTLOST: - break; - case WindowsDirectInput.DIERR_NOTACQUIRED: - break; + private boolean checkShiftKey(int virt_key, byte state) { + int key_state = (GetKeyState(virt_key) >>> 15) & 0x1; + int lwjgl_code = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); + return (key_down_buffer[lwjgl_code] == 1 - state) && (key_state == state); + } + + private int translateShift(int scan_code, byte state) { + int state_mask = state != 0 ? 0x8000 : 0x0000; + if (checkShiftKey(WindowsKeycodes.VK_LSHIFT, state)) { + return WindowsKeycodes.VK_LSHIFT; + } else if (checkShiftKey(WindowsKeycodes.VK_RSHIFT, state)) { + return WindowsKeycodes.VK_RSHIFT; + } else { + if (scan_code== 0x2A) + return WindowsKeycodes.VK_LSHIFT; + else { + if (scan_code == 0x36) + return WindowsKeycodes.VK_RSHIFT; + else + return WindowsKeycodes.VK_LSHIFT; + } + } + } + + private int translateExtended(int virt_key, int scan_code, byte state, boolean extended) { + switch (virt_key) { + case WindowsKeycodes.VK_SHIFT: + return translateShift(scan_code, state); + case WindowsKeycodes.VK_CONTROL: + return extended ? WindowsKeycodes.VK_RCONTROL : WindowsKeycodes.VK_LCONTROL; + case WindowsKeycodes.VK_MENU: + return extended ? WindowsKeycodes.VK_RMENU : WindowsKeycodes.VK_LMENU; default: - LWJGLUtil.log("Failed to read keyboard (0x" + Integer.toHexString(ret) + ")"); - break; + return virt_key; } } + public void handleKey(int virt_key, int scan_code, boolean extended, byte event_state, long millis) { + if (isWindowsNT()) + virt_key = translateExtended(virt_key, scan_code, event_state, extended); + translate(virt_key, event_state, millis*1000000); + } + public void read(ByteBuffer buffer) { - processEvents(); - temp_data_buffer.flip(); - translateData(temp_data_buffer, buffer); + event_queue.copyEvents(buffer); } } Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java 2007-04-24 13:40:13 UTC (rev 2801) @@ -0,0 +1,577 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * 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.opengl; + +/** + * @author elias_naur + */ + +import org.lwjgl.input.Keyboard; + +final class WindowsKeycodes { + public final static int VK_LBUTTON = 0x01; + public final static int VK_RBUTTON = 0x02; + public final static int VK_CANCEL = 0x03; + public final static int VK_MBUTTON = 0x04; /* NOT contiguous with L & RBUTTON */ + + public final static int VK_XBUTTON1 = 0x05; /* NOT contiguous with L & RBUTTON */ + public final static int VK_XBUTTON2 = 0x06; /* NOT contiguous with L & RBUTTON */ + +/* + * 0x07 : unassigned + */ + + public final static int VK_BACK = 0x08; + public final static int VK_TAB = 0x09; + +/* + * 0x0A - 0x0B : reserved + */ + + public final static int VK_CLEAR = 0x0C; + public final static int VK_RETURN = 0x0D; + + public final static int VK_SHIFT = 0x10; + public final static int VK_CONTROL = 0x11; + public final static int VK_MENU = 0x12; + public final static int VK_PAUSE = 0x13; + public final static int VK_CAPITAL = 0x14; + + public final static int VK_KANA = 0x15; + public final static int VK_HANGEUL = 0x15; /* old name - should be here for compatibility */ + public final static int VK_HANGUL = 0x15; + public final static int VK_JUNJA = 0x17; + public final static int VK_FINAL = 0x18; + public final static int VK_HANJA = 0x19; + public final static int VK_KANJI = 0x19; + + public final static int VK_ESCAPE = 0x1B; + + public final static int VK_CONVERT = 0x1C; + public final static int VK_NONCONVERT = 0x1D; + public final static int VK_ACCEPT = 0x1E; + public final static int VK_MODECHANGE = 0x1F; + + public final static int VK_SPACE = 0x20; + public final static int VK_PRIOR = 0x21; + public final static int VK_NEXT = 0x22; + public final static int VK_END = 0x23; + public final static int VK_HOME = 0x24; + public final static int VK_LEFT = 0x25; + public final static int VK_UP = 0x26; + public final static int VK_RIGHT = 0x27; + public final static int VK_DOWN = 0x28; + public final static int VK_SELECT = 0x29; + public final static int VK_PRINT = 0x2A; + public final static int VK_EXECUTE = 0x2B; + public final static int VK_SNAPSHOT = 0x2C; + public final static int VK_INSERT = 0x2D; + public final static int VK_DELETE = 0x2E; + public final static int VK_HELP = 0x2F; +/* + * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39) + * 0x40 : unassigned + * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) + */ + public final static int VK_0 = 0x30; + public final static int VK_1 = 0x31; + public final static int VK_2 = 0x32; + public final static int VK_3 = 0x33; + public final static int VK_4 = 0x34; + public final static int VK_5 = 0x35; + public final static int VK_6 = 0x36; + public final static int VK_7 = 0x37; + public final static int VK_8 = 0x38; + public final static int VK_9 = 0x39; + + public final static int VK_A = 0x41; + public final static int VK_B = 0x42; + public final static int VK_C = 0x43; + public final static int VK_D = 0x44; + public final static int VK_E = 0x45; + public final static int VK_F = 0x46; + public final static int VK_G = 0x47; + public final static int VK_H = 0x48; + public final static int VK_I = 0x49; + public final static int VK_J = 0x4A; + public final static int VK_K = 0x4B; + public final static int VK_L = 0x4C; + public final static int VK_M = 0x4D; + public final static int VK_N = 0x4E; + public final static int VK_O = 0x4F; + public final static int VK_P = 0x50; + public final static int VK_Q = 0x51; + public final static int VK_R = 0x52; + public final static int VK_S = 0x53; + public final static int VK_T = 0x54; + public final static int VK_U = 0x55; + public final static int VK_V = 0x56; + public final static int VK_W = 0x57; + public final static int VK_X = 0x58; + public final static int VK_Y = 0x59; + public final static int VK_Z = 0x5A; + + public final static int VK_LWIN = 0x5B; + public final static int VK_RWIN = 0x5C; + public final static int VK_APPS = 0x5D; +/* + * 0x5E : reserved; + */ + + public final static int VK_SLEEP = 0x5F; + + public final static int VK_NUMPAD0 = 0x60; + public final static int VK_NUMPAD1 = 0x61; + public final static int VK_NUMPAD2 = 0x62; + public final static int VK_NUMPAD3 = 0x63; + public final static int VK_NUMPAD4 = 0x64; + public final static int VK_NUMPAD5 = 0x65; + public final static int VK_NUMPAD6 = 0x66; + public final static int VK_NUMPAD7 = 0x67; + public final static int VK_NUMPAD8 = 0x68; + public final static int VK_NUMPAD9 = 0x69; + public final static int VK_MULTIPLY = 0x6A; + public final static int VK_ADD = 0x6B; + public final static int VK_SEPARATOR = 0x6C; + public final static int VK_SUBTRACT = 0x6D; + public final static int VK_DECIMAL = 0x6E; + public final static int VK_DIVIDE = 0x6F; + public final static int VK_F1 = 0x70; + public final static int VK_F2 = 0x71; + public final static int VK_F3 = 0x72; + public final static int VK_F4 = 0x73; + public final static int VK_F5 = 0x74; + public final static int VK_F6 = 0x75; + public final static int VK_F7 = 0x76; + public final static int VK_F8 = 0x77; + public final static int VK_F9 = 0x78; + public final static int VK_F10 = 0x79; + public final static int VK_F11 = 0x7A; + public final static int VK_F12 = 0x7B; + public final static int VK_F13 = 0x7C; + public final static int VK_F14 = 0x7D; + public final static int VK_F15 = 0x7E; + public final static int VK_F16 = 0x7F; + public final static int VK_F17 = 0x80; + public final static int VK_F18 = 0x81; + public final static int VK_F19 = 0x82; + public final static int VK_F20 = 0x83; + public final static int VK_F21 = 0x84; + public final static int VK_F22 = 0x85; + public final static int VK_F23 = 0x86; + public final static int VK_F24 = 0x87; + +/* + * 0x88 - 0x8F : unassigned; + */ + + public final static int VK_NUMLOCK = 0x90; + public final static int VK_SCROLL = 0x91; + +/* + * NEC PC-9800 kbd definitions + */ + public final static int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad +/* + * Fujitsu/OASYS kbd definitions + */ + public final static int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key + public final static int VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key + public final static int VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key + public final static int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key + public final static int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key + +/* + * 0x97 - 0x9F : unassigned + */ + +/* + * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys. + * Used only as parameters to GetAsyncKeyState() and GetKeyState(). + * No other API or message will distinguish left and right keys in this way. + */ + public final static int VK_LSHIFT = 0xA0; + public final static int VK_RSHIFT = 0xA1; + public final static int VK_LCONTROL = 0xA2; + public final static int VK_RCONTROL = 0xA3; + public final static int VK_LMENU = 0xA4; + public final static int VK_RMENU = 0xA5; + + public final static int VK_BROWSER_BACK = 0xA6; + public final static int VK_BROWSER_FORWARD = 0xA7; + public final static int VK_BROWSER_REFRESH = 0xA8; + public final static int VK_BROWSER_STOP = 0xA9; + public final static int VK_BROWSER_SEARCH = 0xAA; + public final static int VK_BROWSER_FAVORITES = 0xAB; + public final static int VK_BROWSER_HOME = 0xAC; + + public final static int VK_VOLUME_MUTE = 0xAD; + public final static int VK_VOLUME_DOWN = 0xAE; + public final static int VK_VOLUME_UP = 0xAF; + public final static int VK_MEDIA_NEXT_TRACK = 0xB0; + public final static int VK_MEDIA_PREV_TRACK = 0xB1; + public final static int VK_MEDIA_STOP = 0xB2; + public final static int VK_MEDIA_PLAY_PAUSE = 0xB3; + public final static int VK_LAUNCH_MAIL = 0xB4; + public final static int VK_LAUNCH_MEDIA_SELECT = 0xB5; + public final static int VK_LAUNCH_APP1 = 0xB6; + public final static int VK_LAUNCH_APP2 = 0xB7; + +/* + * 0xB8 - 0xB9 : reserved + */ + + public final static int VK_OEM_1 = 0xBA; // ';:' for US + public final static int VK_OEM_PLUS = 0xBB; // '+' any country + public final static int VK_OEM_COMMA = 0xBC; // ',' any country + public final static int VK_OEM_MINUS = 0xBD; // '-' any country + public final static int VK_OEM_PERIOD = 0xBE; // '.' any country + public final static int VK_OEM_2 = 0xBF; // '/?' for US + public final static int VK_OEM_3 = 0xC0; // '`~' for US + +/* + * 0xC1 - 0xD7 : reserved + */ + +/* + * 0xD8 - 0xDA : unassigned + */ + + public final static int VK_OEM_4 = 0xDB; // '[{' for US + public final static int VK_OEM_5 = 0xDC; // '\|' for US + public final static int VK_OEM_6 = 0xDD; // ']}' for US + public final static int VK_OEM_7 = 0xDE; // ''"' for US + public final static int VK_OEM_8 = 0xDF; + +/* + * 0xE0 : reserved + */ + +/* + * Various extended or enhanced keyboards + */ + public final static int VK_OEM_AX = 0xE1; // 'AX' key on Japanese AX kbd + public final static int VK_OEM_102 = 0xE2; // "<>" or "\|" on RT 102-key kbd. + public final static int VK_ICO_HELP = 0xE3; // Help key on ICO + public final static int VK_ICO_00 = 0xE4; // 00 key on ICO + + public final static int VK_PROCESSKEY = 0xE5; + + public final static int VK_ICO_CLEAR = 0xE6; + + + public final static int VK_PACKET = 0xE7; + +/* + * 0xE8 : unassigned + */ + +/* + * Nokia/Ericsson definitions + */ + public final static int VK_OEM_RESET = 0xE9; + public final static int VK_OEM_JUMP = 0xEA; + public final static int VK_OEM_PA1 = 0xEB; + public final static int VK_OEM_PA2 = 0xEC; + public final static int VK_OEM_PA3 = 0xED; + public final static int VK_OEM_WSCTRL = 0xEE; + public final static int VK_OEM_CUSEL = 0xEF; + public final static int VK_OEM_ATTN = 0xF0; + public final static int VK_OEM_FINISH = 0xF1; + public final static int VK_OEM_COPY = 0xF2; + public final static int VK_OEM_AUTO = 0xF3; + public final static int VK_OEM_ENLW = 0xF4; + public final static int VK_OEM_BACKTAB = 0xF5; + + public final static int VK_ATTN = 0xF6; + public final static int VK_CRSEL = 0xF7; + public final static int VK_EXSEL = 0xF8; + public final static int VK_EREOF = 0xF9; + public final static int VK_PLAY = 0xFA; + public final static int VK_ZOOM = 0xFB; + public final static int VK_NONAME = 0xFC; + public final static int VK_PA1 = 0xFD; + public final static int VK_OEM_CLEAR = 0xFE; + + public static int mapVirtualKeyToLWJGLCode(int virt_key) { + switch (virt_key) { + case VK_ESCAPE: + return Keyboard.KEY_ESCAPE; + case VK_1: + return Keyboard.KEY_1; + case VK_2: + return Keyboard.KEY_2; + case VK_3: + return Keyboard.KEY_3; + case VK_4: + return Keyboard.KEY_4; + case VK_5: + return Keyboard.KEY_5; + case VK_6: + return Keyboard.KEY_6; + case VK_7: + return Keyboard.KEY_7; + case VK_8: + return Keyboard.KEY_8; + case VK_9: + return Keyboard.KEY_9; + case VK_0: + return Keyboard.KEY_0; + case VK_OEM_MINUS: + return Keyboard.KEY_MINUS; +/* case VK_EQUALS: + return Keyboard.KEY_EQUALS;*/ + case VK_BACK: + return Keyboard.KEY_BACK; + case VK_TAB: + return Keyboard.KEY_TAB; + case VK_Q: + return Keyboard.KEY_Q; + case VK_W: + return Keyboard.KEY_W; + case VK_E: + return Keyboard.KEY_E; + case VK_R: + return Keyboard.KEY_R; + case VK_T: + return Keyboard.KEY_T; + case VK_Y: + return Keyboard.KEY_Y; + case VK_U: + return Keyboard.KEY_U; + case VK_I: + return Keyboard.KEY_I; + case VK_O: + return Keyboard.KEY_O; + case VK_P: + return Keyboard.KEY_P; + case VK_OEM_4: + return Keyboard.KEY_LBRACKET; + case VK_OEM_6: + return Keyboard.KEY_RBRACKET; + case VK_RETURN: + return Keyboard.KEY_RETURN; + case VK_LCONTROL: + return Keyboard.KEY_LCONTROL; + case VK_A: + return Keyboard.KEY_A; + case VK_S: + return Keyboard.KEY_S; + case VK_D: + return Keyboard.KEY_D; + case VK_F: + return Keyboard.KEY_F; + case VK_G: + return Keyboard.KEY_G; + case VK_H: + return Keyboard.KEY_H; + case VK_J: + return Keyboard.KEY_J; + case VK_K: + return Keyboard.KEY_K; + case VK_L: + return Keyboard.KEY_L; + case VK_OEM_1: + return Keyboard.KEY_SEMICOLON; + case VK_OEM_7: + return Keyboard.KEY_APOSTROPHE; + case VK_OEM_3: + return Keyboard.KEY_GRAVE; + case VK_LSHIFT: + return Keyboard.KEY_LSHIFT; + case VK_OEM_5: + return Keyboard.KEY_BACKSLASH; + case VK_Z: + return Keyboard.KEY_Z; + case VK_X: + return Keyboard.KEY_X; + case VK_C: + return Keyboard.KEY_C; + case VK_V: + return Keyboard.KEY_V; + case VK_B: + return Keyboard.KEY_B; + case VK_N: + return Keyboard.KEY_N; + case VK_M: + return Keyboard.KEY_M; + case VK_OEM_COMMA: + return Keyboard.KEY_COMMA; + case VK_OEM_PERIOD: + return Keyboard.KEY_PERIOD; + case VK_OEM_2: + return Keyboard.KEY_SLASH; + case VK_RSHIFT: + return Keyboard.KEY_RSHIFT; + case VK_MULTIPLY: + return Keyboard.KEY_MULTIPLY; + case VK_LMENU: + return Keyboard.KEY_LMENU; + case VK_SPACE: + return Keyboard.KEY_SPACE; + case VK_CAPITAL: + return Keyboard.KEY_CAPITAL; + case VK_F1: + return Keyboard.KEY_F1; + case VK_F2: + return Keyboard.KEY_F2; + case VK_F3: + return Keyboard.KEY_F3; + case VK_F4: + return Keyboard.KEY_F4; + case VK_F5: + return Keyboard.KEY_F5; + case VK_F6: + return Keyboard.KEY_F6; + case VK_F7: + return Keyboard.KEY_F7; + case VK_F8: + return Keyboard.KEY_F8; + case VK_F9: + return Keyboard.KEY_F9; + case VK_F10: + return Keyboard.KEY_F10; + case VK_NUMLOCK: + return Keyboard.KEY_NUMLOCK; + case VK_SCROLL: + return Keyboard.KEY_SCROLL; + case VK_NUMPAD7: + return Keyboard.KEY_NUMPAD7; + case VK_NUMPAD8: + return Keyboard.KEY_NUMPAD8; + case VK_NUMPAD9: + return Keyboard.KEY_NUMPAD9; + case VK_SUBTRACT: + return Keyboard.KEY_SUBTRACT; + case VK_NUMPAD4: + return Keyboard.KEY_NUMPAD4; + case VK_NUMPAD5: + return Keyboard.KEY_NUMPAD5; + case VK_NUMPAD6: + return Keyboard.KEY_NUMPAD6; + case VK_ADD: + return Keyboard.KEY_ADD; + case VK_NUMPAD1: + return Keyboard.KEY_NUMPAD1; + case VK_NUMPAD2: + return Keyboard.KEY_NUMPAD2; + case VK_NUMPAD3: + return Keyboard.KEY_NUMPAD3; + case VK_NUMPAD0: + return Keyboard.KEY_NUMPAD0; + case VK_DECIMAL: + return Keyboard.KEY_DECIMAL; + case VK_F11: + return Keyboard.KEY_F11; + case VK_F12: + return Keyboard.KEY_F12; + case VK_F13: + return Keyboard.KEY_F13; + case VK_F14: + return Keyboard.KEY_F14; + case VK_F15: + return Keyboard.KEY_F15; + case VK_KANA: + return Keyboard.KEY_KANA; + case VK_CONVERT: + return Keyboard.KEY_CONVERT; + case VK_NONCONVERT: + return Keyboard.KEY_NOCONVERT; +/* case VK_YEN: + return Keyboard.KEY_YEN; + case VK_NUMPADEQUALS: + return Keyboard.KEY_NUMPADEQUALS; + case VK_CIRCUMFLEX: + return Keyboard.KEY_CIRCUMFLEX; + case VK_AT: + return Keyboard.KEY_AT; + case VK_COLON: + return Keyboard.KEY_COLON; + case VK_UNDERLINE: + return Keyboard.KEY_UNDERLINE;*/ + case VK_KANJI: + return Keyboard.KEY_KANJI; +/* case VK_STOP: + return Keyboard.KEY_STOP; + case VK_AX: + return Keyboard.KEY_AX; + case VK_UNLABELED: + return Keyboard.KEY_UNLABELED; + case VK_NUMPADENTER: + return Keyboard.KEY_NUMPADENTER;*/ + case VK_RCONTROL: + return Keyboard.KEY_RCONTROL; + case VK_SEPARATOR: + return Keyboard.KEY_NUMPADCOMMA; + case VK_DIVIDE: + return Keyboard.KEY_DIVIDE; + case VK_PRINT: + return Keyboard.KEY_SYSRQ; + case VK_RMENU: + return Keyboard.KEY_RMENU; + case VK_PAUSE: + return Keyboard.KEY_PAUSE; + case VK_HOME: + return Keyboard.KEY_HOME; + case VK_UP: + return Keyboard.KEY_UP; + case VK_PRIOR: + return Keyboard.KEY_PRIOR; + case VK_LEFT: + return Keyboard.KEY_LEFT; + case VK_RIGHT: + return Keyboard.KEY_RIGHT; + case VK_END: + return Keyboard.KEY_END; + case VK_DOWN: + return Keyboard.KEY_DOWN; + case VK_NEXT: + return Keyboard.KEY_NEXT; + case VK_INSERT: + return Keyboard.KEY_INSERT; + case VK_DELETE: + return Keyboard.KEY_DELETE; + case VK_LWIN: + return Keyboard.KEY_LWIN; + case VK_RWIN: + return Keyboard.KEY_RWIN; + case VK_APPS: + return Keyboard.KEY_APPS; +/* case VK_POWER: + return Keyboard.KEY_POWER;*/ + case VK_SLEEP: + return Keyboard.KEY_SLEEP; + default: + return Keyboard.KEY_NONE; + } + } +} Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java ___________________________________________________________________ Name: svn:executable + * Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c 2007-04-24 13:22:35 UTC (rev 2800) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsKeyboard.c 2007-04-24 13:40:13 UTC (rev 2801) @@ -41,6 +41,10 @@ #include <jni.h> #include "org_lwjgl_opengl_WindowsKeyboard.h" +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_GetKeyState(JNIEnv *env, jclass unused, jint virt_key) { + return GetKeyState(virt_key); +} + JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey(JNIEnv *env, jclass unused, jint uCode, jint uMapType) { return MapVirtualKey(uCode, uMapType); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 13:22:52
|
Revision: 2800 http://svn.sourceforge.net/java-game-lib/?rev=2800&view=rev Author: elias_naur Date: 2007-04-24 06:22:35 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Compile fix Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-04-24 09:30:03 UTC (rev 2799) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-04-24 13:22:35 UTC (rev 2800) @@ -105,7 +105,7 @@ * task bar and clicking on it. So we'll use ClipCursor to * contain it while the cursor is grabbed. */ - WindowsDisplay.setupCursorClipping(hwnd, true); // Just clip it to a fullscreen window + WindowsDisplay.setupCursorClipping(hwnd); // Just clip it to a fullscreen window if (getCanvas().getCursor() != blank_cursor) { cached_cursor = getCanvas().getCursor(); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 09:30:08
|
Revision: 2799 http://svn.sourceforge.net/java-game-lib/?rev=2799&view=rev Author: elias_naur Date: 2007-04-24 02:30:03 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Windows: Remove dependency on DirectInput for WindowsMouse used by WindowsDisplay. Keyboard conversion coming up. Reasons: 1. DirectInput is deprecated (http://en.wikipedia.org/wiki/DirectInput). Specifically, Microsoft recommends using regular windows messages for keyboard and mouse input. 2. Not using DirectInput enable us to use the Raw Input JInput plugin to access multiple mice (and keyboards). 3. We're already using windows messages for features DirectInput never supported, so by removing DirectInput dependency, we get rid of some special case code. 4. When we're only using windows messages for input, we're (theoretically) more compatible than with a dependency on a properly working DirectInput. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/common/common_tools.h trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -57,7 +57,7 @@ private static final String VERSION = "1.1"; /** Current version of the JNI library */ - static final int JNI_VERSION = 8; + static final int JNI_VERSION = 9; /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -53,7 +53,7 @@ private Cursor cached_cursor; private long cached_hwnd; - private WindowsMouse cached_mouse; + private WindowsDirectInputMouse cached_mouse; // private WindowsKeyboard cached_keyboard; private boolean has_grabbed; @@ -96,7 +96,7 @@ cached_keyboard.destroy(); }*/ WindowsDirectInput dinput = WindowsDisplay.createDirectInput(); - cached_mouse = new WindowsMouse(dinput, hwnd); + cached_mouse = new WindowsDirectInputMouse(dinput, hwnd); // cached_keyboard = new WindowsKeyboard(dinput, hwnd); } if (isGrabbed()) { @@ -105,7 +105,7 @@ * task bar and clicking on it. So we'll use ClipCursor to * contain it while the cursor is grabbed. */ - WindowsDisplay.setupCursorClipping(hwnd); + WindowsDisplay.setupCursorClipping(hwnd, true); // Just clip it to a fullscreen window if (getCanvas().getCursor() != blank_cursor) { cached_cursor = getCanvas().getCursor(); /** Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputMouse.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * 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.opengl; + +/** + * This is the Windows implementation of the Mouse. + * @author elias_naur + */ + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.CharBuffer; + +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; +import org.lwjgl.input.Mouse; + +final class WindowsDirectInputMouse { + private final static int BUFFER_SIZE = 50; + private final static int BUTTON_STATES_SIZE = 7; + + private final static int DIMOFS_X = 0; + private final static int DIMOFS_Y = 4; + private final static int DIMOFS_Z = 8; + private final static int DIMOFS_BUTTON0 = 12; + private final static int DIMOFS_BUTTON1 = 13; + private final static int DIMOFS_BUTTON2 = 14; + private final static int DIMOFS_BUTTON3 = 15; + + private final long hwnd; + private final WindowsDirectInput dinput; + private final WindowsDirectInputDevice mouse; + + private final int mouse_button_count; + private final boolean has_wheel; + + private final EventQueue event_queue = new EventQueue(Mouse.EVENT_SIZE); + /* Buffer to hold a DIMOUSESTATE */ + private final ByteBuffer mouse_state; + private final IntBuffer temp_data_buffer; + + private final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE); + + private boolean mouse_grabbed; + private byte[] win32_message_button_states = new byte[BUTTON_STATES_SIZE]; + private int accum_dwheel; + private int last_x; + private int last_y; + + public WindowsDirectInputMouse(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + this.hwnd = hwnd; + this.dinput = dinput; + try { + mouse = dinput.createDevice(WindowsDirectInput.MOUSE_TYPE); + try { + mouse.setDataFormat(WindowsDirectInput.MOUSE_TYPE); + mouse.setBufferSize(BUFFER_SIZE); + if (!acquireNonExclusive()) + throw new LWJGLException("Failed to acquire mouse non-exclusive"); + } catch (LWJGLException e) { + mouse.release(); + throw e; + } + } catch (LWJGLException e) { + dinput.release(); + throw e; + } + MouseEnumerator enumerator = new MouseEnumerator(); + mouse.enumObjects(enumerator); + this.mouse_button_count = Math.min(enumerator.getButtonCount(), 4); + this.has_wheel = enumerator.hasWheel(); + mouse_state = BufferUtils.createByteBuffer(3*4 + 4); + temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); + } + + public boolean hasWheel() { + return has_wheel; + } + + public int getButtonCount() { + return mouse_button_count; + } + + private boolean acquire(int flags) { + try { + mouse.setCooperateLevel(hwnd, flags); + mouse.acquire(); + return true; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to acquire mouse: " + e); + return false; + } + } + + private boolean acquireNonExclusive() { + return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || + acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); + } + + public void destroy() { + mouse.unacquire(); + mouse.release(); + dinput.release(); + } + + public void poll(IntBuffer coord_buffer, ByteBuffer buttons) { + int ret = mouse.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + mouse.poll(); + for (int i = 0; i < coord_buffer.remaining(); i++) + coord_buffer.put(coord_buffer.position() + i, 0); + mouse_state.clear(); + ret = mouse.getDeviceState(mouse_state); + int mouse_state_lx = mouse_state.getInt(); + int mouse_state_ly = mouse_state.getInt(); + int mouse_state_lz = mouse_state.getInt(); + int num_buttons = mouse_button_count; + if (mouse_grabbed || ret == WindowsDirectInput.DI_OK) { + if (ret != WindowsDirectInput.DI_OK) { + LWJGLUtil.log("Error getting mouse state: (0x" + Integer.toHexString(ret) + ")"); + return; + } + + coord_buffer.put(coord_buffer.position() + 2, mouse_state_lz); + if (num_buttons > buttons.remaining()) + num_buttons = buttons.remaining(); + for (int j = 0; j < num_buttons; j++) { + byte button_state = (mouse_state.get() & 0x80) != 0 ? (byte)1 : (byte)0; + buttons.put(buttons.position() + j, button_state); + // track the button state in the windows message buffer state array + // to get accurate button information when releasing a grab + win32_message_button_states[j] = button_state; + } + } else { + coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); + if (num_buttons > win32_message_button_states.length) + num_buttons = win32_message_button_states.length; + for (int j = 0; j < num_buttons; j++) { + buttons.put(buttons.position() + j, win32_message_button_states[j]); + } + } + accum_dwheel = 0; + if (mouse_grabbed) { + coord_buffer.put(coord_buffer.position() + 0, mouse_state_lx); + coord_buffer.put(coord_buffer.position() + 1, -mouse_state_ly); + } else { + coord_buffer.put(coord_buffer.position() + 0, last_x); + coord_buffer.put(coord_buffer.position() + 1, last_y); + } + } + + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + mouse_event.clear(); + mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); + mouse_event.flip(); + event_queue.putEvent(mouse_event); + } + + private void putMouseEvent(byte button, byte state, int dz, long nanos) { + if (mouse_grabbed) + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); + else + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); + } + + private void copyDXEvents(IntBuffer buffer) { + int buffer_index = 0; + int dx = 0, dy = 0, dwheel = 0; + byte button_state; + int i; + long nanos = 0; + while (buffer.hasRemaining()) { + int dwOfs = buffer.get(); + int dwData = buffer.get(); + long dwTimeStamp = ((long)buffer.get()) & 0xFFFFFFFF; + nanos = dwTimeStamp*1000000; + button_state = (dwData & 0x80) != 0 ? (byte)1 : (byte)0; + switch (dwOfs) { + case DIMOFS_BUTTON0: + putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON1: + putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON2: + putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON3: + putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel, nanos); + dx = dy = dwheel = 0; + break; + case DIMOFS_X: + dx += dwData; + break; + case DIMOFS_Y: + dy += dwData; + break; + case DIMOFS_Z: + dwheel += dwData; + break; + } + } + if (dx != 0 || dy != 0 || dwheel != 0) + putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel, nanos); + } + + private void readDXBuffer() { + int ret = mouse.acquire(); + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) + return; + mouse.poll(); + temp_data_buffer.clear(); + ret = mouse.getDeviceData(temp_data_buffer); + + switch (ret) { + case WindowsDirectInput.DI_OK: + break; + case WindowsDirectInput.DI_BUFFEROVERFLOW: + LWJGLUtil.log("Mouse buffer overflowed"); + break; + case WindowsDirectInput.DIERR_INPUTLOST: + LWJGLUtil.log("Mouse input lost"); + break; + case WindowsDirectInput.DIERR_NOTACQUIRED: + LWJGLUtil.log("Mouse not acquired"); + break; + default: + LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); + break; + } + } + + public final void flush() { + readDXBuffer(); + temp_data_buffer.clear(); + } + + public void read(ByteBuffer buffer) { + readDXBuffer(); + if (mouse_grabbed) { + temp_data_buffer.flip(); + copyDXEvents(temp_data_buffer); + } + event_queue.copyEvents(buffer); + } + + public void grab(boolean grab) { + if(grab) { + if (!mouse_grabbed) { + flush(); + mouse_grabbed = true; + mouse.unacquire(); + if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) + LWJGLUtil.log("Failed to reset cooperative mode"); + } + } else { + if (mouse_grabbed) { + mouse_grabbed = false; + mouse.unacquire(); + acquireNonExclusive(); + } + } + event_queue.clearEvents(); + } + + public void handleMouseScrolled(int event_dwheel, long millis) { + accum_dwheel += event_dwheel; + putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000); + } + + public void handleMouseMoved(int x, int y, long millis) { + int dx; + int dy; + dx = x - last_x; + dy = y - last_y; + last_x = x; + last_y = y; + long nanos = millis*1000000; + if (mouse_grabbed) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); + } + } + + public void handleMouseButton(byte button, byte state, long millis) { + putMouseEvent(button, state, 0, millis*1000000); + if (button < BUTTON_STATES_SIZE) + win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; + } + + private static class MouseEnumerator implements WindowsDirectInputDeviceObjectCallback { + private int button_count; + private boolean has_wheel; + + public int getButtonCount() { + return button_count; + } + + public boolean hasWheel() { + return has_wheel; + } + + public boolean nextObject(int type, String name) { + LWJGLUtil.log("Found mouse object: " + name); + switch (type) { + case WindowsDirectInputDevice.GUID_ZAxis: + has_wheel = true; + break; + case WindowsDirectInputDevice.GUID_Button: + button_count++; + break; + default: + break; + } + return true; + } + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -44,6 +44,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; import org.lwjgl.input.Cursor; final class WindowsDisplay implements DisplayImplementation { @@ -85,7 +86,10 @@ private final static int SC_CONTEXTHELP = 0xF180; private final static int SC_SEPARATOR = 0xF00F; - private final static int SM_CXCURSOR = 13; + final static int SM_CXCURSOR = 13; + final static int SM_CYCURSOR = 14; + final static int SM_CMOUSEBUTTONS = 43; + final static int SM_MOUSEWHEELPRESENT = 75; private final static int SIZE_RESTORED = 0; private final static int SIZE_MINIMIZED = 1; @@ -99,9 +103,14 @@ private final static int SW_SHOWDEFAULT = 10; private final static int SW_RESTORE = 9; + private final static IntBuffer rect_buffer = BufferUtils.createIntBuffer(4); + private final static Rect rect = new Rect(); + private final static Rect rect2 = new Rect(); private static WindowsDisplay current_display; + private static boolean cursor_clipped; private WindowsDisplayPeerInfo peer_info; + private Object current_cursor; private WindowsKeyboard keyboard; private WindowsMouse mouse; @@ -141,13 +150,38 @@ public void destroyWindow() { nDestroyWindow(); - if (isFullscreen) - resetCursorClipping(); + resetCursorClipping(); } private static native void nDestroyWindow(); - static native void resetCursorClipping(); - static native void setupCursorClipping(long hwnd) throws LWJGLException; + static void resetCursorClipping() { + if (cursor_clipped) { + try { + clipCursor(0, null); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset cursor clipping: " + e); + } + cursor_clipped = false; + } + } + private static void getGlobalClientRect(long hwnd, Rect rect) { + rect_buffer.put(0, 0).put(1, 0); + clientToScreen(hwnd, rect_buffer); + int offset_x = rect_buffer.get(0); + int offset_y = rect_buffer.get(1); + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + rect.offset(offset_x, offset_y); + } + + static void setupCursorClipping(long hwnd) throws LWJGLException { + cursor_clipped = true; + getGlobalClientRect(hwnd, rect); + rect.copyToBuffer(rect_buffer); + clipCursor(hwnd, rect_buffer); + } + private static native void clipCursor(long hwnd, IntBuffer rect) throws LWJGLException; + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { nSwitchDisplayMode(mode); current_mode = mode; @@ -330,11 +364,12 @@ } public void createMouse() throws LWJGLException { - mouse = new WindowsMouse(createDirectInput(), getHwnd()); + mouse = new WindowsMouse(getHwnd()); } public void destroyMouse() { - mouse.destroy(); + if (mouse != null) + mouse.destroy(); mouse = null; } @@ -349,7 +384,12 @@ } public void grabMouse(boolean grab) { - mouse.grab(grab); + mouse.grab(grab, shouldGrab()); + try { + updateCursor(); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to update cursor: " + e); + } } public int getNativeCursorCapabilities() { @@ -357,12 +397,27 @@ } public void setCursorPosition(int x, int y) { - nSetCursorPosition(x, y, isFullscreen); + getGlobalClientRect(getHwnd(), rect); + int transformed_x = rect.left + x; + int transformed_y = rect.bottom - 1 - y; + nSetCursorPosition(transformed_x, transformed_y); + setMousePosition(x, y); } - private static native void nSetCursorPosition(int x, int y, boolean fullscreen); + private static native void nSetCursorPosition(int x, int y); - public native void setNativeCursor(Object handle) throws LWJGLException; + public void setNativeCursor(Object handle) throws LWJGLException { + current_cursor = handle; + updateCursor(); + } + private void updateCursor() throws LWJGLException { + if (mouse != null && mouse.isGrabbed()) + nSetNativeCursor(getHwnd(), mouse.getBlankCursor()); + else + nSetNativeCursor(getHwnd(), current_cursor); + } + static native void nSetNativeCursor(long hwnd, Object handle) throws LWJGLException; + public int getMinCursorSize() { return getSystemMetrics(SM_CXCURSOR); } @@ -371,11 +426,31 @@ return getSystemMetrics(SM_CXCURSOR); } - public native int getSystemMetrics(int index); + static native int getSystemMetrics(int index); private static native long getDllInstance(); private static native long getHwnd(); + private static native long getDesktopWindow(); + static void centerCursor(long hwnd) { + getGlobalClientRect(getHwnd(), rect); + int local_offset_x = rect.left; + int local_offset_y = rect.top; + getGlobalClientRect(getDesktopWindow(), rect2); + Rect.intersect(rect, rect2, rect); + int center_x = (rect.left + rect.right)/2; + int center_y = (rect.top + rect.bottom)/2; + nSetCursorPosition(center_x, center_y); + int local_x = center_x - local_offset_x; + int local_y = center_y - local_offset_y; + if (current_display != null) + current_display.setMousePosition(local_x, transformY(getHwnd(), local_y)); + } + private void setMousePosition(int x, int y) { + if (mouse != null) + mouse.setPosition(x, y); + } + /* Keyboard */ public void createKeyboard() throws LWJGLException { keyboard = new WindowsKeyboard(createDirectInput(), getHwnd()); @@ -398,13 +473,21 @@ // public native int isStateKeySet(int key); - public native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; + public static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + return doCreateCursor(width, height, xHotspot, yHotspot, numImages, images, delays); + } + + static Object doCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1); } - public native void destroyCursor(Object cursorHandle); + public void destroyCursor(Object cursorHandle) { + doDestroyCursor(cursorHandle); + } + static native void doDestroyCursor(Object cursorHandle); + public int getPbufferCapabilities() { try { // Return the capabilities of a minimum pixel format @@ -483,9 +566,13 @@ mouse.handleMouseButton((byte)button, (byte)state, millis); } + private boolean shouldGrab() { + return !isMinimized && isFocused; + } + private void handleMouseMoved(int x, int y, long millis) { if (mouse != null) - mouse.handleMouseMoved(x, y, millis); + mouse.handleMouseMoved(x, y, millis, shouldGrab()); } private void handleMouseScrolled(int amount, long millis) { @@ -493,8 +580,16 @@ mouse.handleMouseScrolled(amount, millis); } - private static native int transformY(long hwnd, int y); + private static native void getClientRect(long hwnd, IntBuffer rect); + private static int transformY(long hwnd, int y) { + getClientRect(hwnd, rect_buffer); + rect.copyFromBuffer(rect_buffer); + return (rect.bottom - rect.top) - 1 - y; + } + + private static native void clientToScreen(long hwnd, IntBuffer point); + private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { if (current_display != null) return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); @@ -503,12 +598,14 @@ } private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { - if (isFullscreen && !isMinimized && isFocused) { + if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused) { try { setupCursorClipping(getHwnd()); } catch (LWJGLException e) { LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage()); } + } else { + resetCursorClipping(); } switch (msg) { // disable screen saver and monitor power down messages which wreak havoc @@ -602,4 +699,40 @@ public int getHeight() { return Display.getDisplayMode().getHeight(); } + + private static final class Rect { + public int top; + public int bottom; + public int left; + public int right; + + public void copyToBuffer(IntBuffer buffer) { + buffer.put(0, top).put(1, bottom).put(2, left).put(3, right); + } + + public void copyFromBuffer(IntBuffer buffer) { + top = buffer.get(0); + bottom = buffer.get(1); + left = buffer.get(2); + right = buffer.get(3); + } + + public void offset(int offset_x, int offset_y) { + left += offset_x; + right += offset_x; + top += offset_y; + bottom += offset_y; + } + + public static void intersect(Rect r1, Rect r2, Rect dst) { + dst.top = Math.max(r1.top, r2.top); + dst.bottom = Math.min(r1.bottom, r2.bottom); + dst.left = Math.max(r1.left, r2.left); + dst.right = Math.min(r1.right, r2.right); + } + + public String toString() { + return "Rect: top = " + top + " bottom = " + bottom + " left = " + left + " right = " + right; + } + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2007-04-24 09:30:03 UTC (rev 2799) @@ -44,65 +44,46 @@ import org.lwjgl.LWJGLUtil; import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; +import org.lwjgl.input.Cursor; final class WindowsMouse { - private final static int BUFFER_SIZE = 50; - private final static int BUTTON_STATES_SIZE = 7; - - private final static int DIMOFS_X = 0; - private final static int DIMOFS_Y = 4; - private final static int DIMOFS_Z = 8; - private final static int DIMOFS_BUTTON0 = 12; - private final static int DIMOFS_BUTTON1 = 13; - private final static int DIMOFS_BUTTON2 = 14; - private final static int DIMOFS_BUTTON3 = 15; - private final long hwnd; - private final WindowsDirectInput dinput; - private final WindowsDirectInputDevice mouse; private final int mouse_button_count; private final boolean has_wheel; private final EventQueue event_queue = new EventQueue(Mouse.EVENT_SIZE); - /* Buffer to hold a DIMOUSESTATE */ - private final ByteBuffer mouse_state; - private final IntBuffer temp_data_buffer; private final ByteBuffer mouse_event = ByteBuffer.allocate(Mouse.EVENT_SIZE); + private final Object blank_cursor; private boolean mouse_grabbed; - private byte[] win32_message_button_states = new byte[BUTTON_STATES_SIZE]; + private byte[] button_states; + private int accum_dx; + private int accum_dy; private int accum_dwheel; private int last_x; private int last_y; - public WindowsMouse(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + public WindowsMouse(long hwnd) throws LWJGLException { this.hwnd = hwnd; - this.dinput = dinput; - try { - mouse = dinput.createDevice(WindowsDirectInput.MOUSE_TYPE); - try { - mouse.setDataFormat(WindowsDirectInput.MOUSE_TYPE); - mouse.setBufferSize(BUFFER_SIZE); - if (!acquireNonExclusive()) - throw new LWJGLException("Failed to acquire mouse non-exclusive"); - } catch (LWJGLException e) { - mouse.release(); - throw e; - } - } catch (LWJGLException e) { - dinput.release(); - throw e; - } - MouseEnumerator enumerator = new MouseEnumerator(); - mouse.enumObjects(enumerator); - this.mouse_button_count = Math.min(enumerator.getButtonCount(), 4); - this.has_wheel = enumerator.hasWheel(); - mouse_state = BufferUtils.createByteBuffer(3*4 + 4); - temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); + this.mouse_button_count = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CMOUSEBUTTONS); + this.has_wheel = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_MOUSEWHEELPRESENT) != 0; + this.blank_cursor = createBlankCursor(); + this.button_states = new byte[mouse_button_count]; } + private Object createBlankCursor() throws LWJGLException { + int width = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CXCURSOR); + int height = WindowsDisplay.getSystemMetrics(WindowsDisplay.SM_CYCURSOR); + IntBuffer pixels = BufferUtils.createIntBuffer(width*height); + return WindowsDisplay.doCreateCursor(width, height, 0, 0, 1, pixels, null); + } + + public boolean isGrabbed() { + return mouse_grabbed; + } + public boolean hasWheel() { return has_wheel; } @@ -111,73 +92,24 @@ return mouse_button_count; } - private boolean acquire(int flags) { - try { - mouse.setCooperateLevel(hwnd, flags); - mouse.acquire(); - return true; - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to acquire mouse: " + e); - return false; - } - } - - private boolean acquireNonExclusive() { - return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || - acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); - } - - public void destroy() { - mouse.unacquire(); - mouse.release(); - dinput.release(); - } - public void poll(IntBuffer coord_buffer, ByteBuffer buttons) { - int ret = mouse.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - mouse.poll(); for (int i = 0; i < coord_buffer.remaining(); i++) coord_buffer.put(coord_buffer.position() + i, 0); - mouse_state.clear(); - ret = mouse.getDeviceState(mouse_state); - int mouse_state_lx = mouse_state.getInt(); - int mouse_state_ly = mouse_state.getInt(); - int mouse_state_lz = mouse_state.getInt(); int num_buttons = mouse_button_count; - if (mouse_grabbed || ret == WindowsDirectInput.DI_OK) { - if (ret != WindowsDirectInput.DI_OK) { - LWJGLUtil.log("Error getting mouse state: (0x" + Integer.toHexString(ret) + ")"); - return; - } - - coord_buffer.put(coord_buffer.position() + 2, mouse_state_lz); - if (num_buttons > buttons.remaining()) - num_buttons = buttons.remaining(); - for (int j = 0; j < num_buttons; j++) { - byte button_state = (mouse_state.get() & 0x80) != 0 ? (byte)1 : (byte)0; - buttons.put(buttons.position() + j, button_state); - // track the button state in the windows message buffer state array - // to get accurate button information when releasing a grab - win32_message_button_states[j] = button_state; - } - } else { - coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); - if (num_buttons > win32_message_button_states.length) - num_buttons = win32_message_button_states.length; - for (int j = 0; j < num_buttons; j++) { - buttons.put(buttons.position() + j, win32_message_button_states[j]); - } + coord_buffer.put(coord_buffer.position() + 2, accum_dwheel); + if (num_buttons > button_states.length) + num_buttons = button_states.length; + for (int j = 0; j < num_buttons; j++) { + buttons.put(buttons.position() + j, button_states[j]); } - accum_dwheel = 0; - if (mouse_grabbed) { - coord_buffer.put(coord_buffer.position() + 0, mouse_state_lx); - coord_buffer.put(coord_buffer.position() + 1, -mouse_state_ly); + if (isGrabbed()) { + coord_buffer.put(coord_buffer.position() + 0, accum_dx); + coord_buffer.put(coord_buffer.position() + 1, accum_dy); } else { coord_buffer.put(coord_buffer.position() + 0, last_x); coord_buffer.put(coord_buffer.position() + 1, last_y); } + accum_dx = accum_dy = accum_dwheel = 0; } private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { @@ -194,104 +126,30 @@ putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); } - private void copyDXEvents(IntBuffer buffer) { - int buffer_index = 0; - int dx = 0, dy = 0, dwheel = 0; - byte button_state; - int i; - long nanos = 0; - while (buffer.hasRemaining()) { - int dwOfs = buffer.get(); - int dwData = buffer.get(); - long dwTimeStamp = ((long)buffer.get()) & 0xFFFFFFFF; - nanos = dwTimeStamp*1000000; - button_state = (dwData & 0x80) != 0 ? (byte)1 : (byte)0; - switch (dwOfs) { - case DIMOFS_BUTTON0: - putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_BUTTON1: - putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_BUTTON2: - putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_BUTTON3: - putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel, nanos); - dx = dy = dwheel = 0; - break; - case DIMOFS_X: - dx += dwData; - break; - case DIMOFS_Y: - dy += dwData; - break; - case DIMOFS_Z: - dwheel += dwData; - break; - } - } - if (dx != 0 || dy != 0 || dwheel != 0) - putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel, nanos); + public void read(ByteBuffer buffer) { + event_queue.copyEvents(buffer); } - private void readDXBuffer() { - int ret = mouse.acquire(); - if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) - return; - mouse.poll(); - temp_data_buffer.clear(); - ret = mouse.getDeviceData(temp_data_buffer); - - switch (ret) { - case WindowsDirectInput.DI_OK: - break; - case WindowsDirectInput.DI_BUFFEROVERFLOW: - LWJGLUtil.log("Mouse buffer overflowed"); - break; - case WindowsDirectInput.DIERR_INPUTLOST: - LWJGLUtil.log("Mouse input lost"); - break; - case WindowsDirectInput.DIERR_NOTACQUIRED: - LWJGLUtil.log("Mouse not acquired"); - break; - default: - LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); - break; - } + public Object getBlankCursor() { + return blank_cursor; } - public final void flush() { - readDXBuffer(); - temp_data_buffer.clear(); - } - - public void read(ByteBuffer buffer) { - readDXBuffer(); - if (mouse_grabbed) { - temp_data_buffer.flip(); - copyDXEvents(temp_data_buffer); - } - event_queue.copyEvents(buffer); - } - - public void grab(boolean grab) { - if(grab) { + public void grab(boolean grab, boolean should_center) { + if (grab) { if (!mouse_grabbed) { - flush(); mouse_grabbed = true; - mouse.unacquire(); - if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) - LWJGLUtil.log("Failed to reset cooperative mode"); + try { + WindowsDisplay.setupCursorClipping(hwnd); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to setup cursor clipping: " + e); + } + if (should_center) + centerCursor(); } } else { if (mouse_grabbed) { mouse_grabbed = false; - mouse.unacquire(); - acquireNonExclusive(); + WindowsDisplay.resetCursorClipping(); } } event_queue.clearEvents(); @@ -302,52 +160,41 @@ putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000); } - public void handleMouseMoved(int x, int y, long millis) { - int dx; - int dy; - dx = x - last_x; - dy = y - last_y; - last_x = x; - last_y = y; - long nanos = millis*1000000; - if (mouse_grabbed) { - putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); - } else { - putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); - } + private void centerCursor() { + WindowsDisplay.centerCursor(hwnd); } - public void handleMouseButton(byte button, byte state, long millis) { - putMouseEvent(button, state, 0, millis*1000000); - if (button < BUTTON_STATES_SIZE) - win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; + public void setPosition(int x, int y) { + this.last_x = x; + this.last_y = y; } - private static class MouseEnumerator implements WindowsDirectInputDeviceObjectCallback { - private int button_count; - private boolean has_wheel; + public void destroy() { + WindowsDisplay.doDestroyCursor(blank_cursor); + } - public int getButtonCount() { - return button_count; - } - - public boolean hasWheel() { - return has_wheel; - } - - public boolean nextObject(int type, String name) { - LWJGLUtil.log("Found mouse object: " + name); - switch (type) { - case WindowsDirectInputDevice.GUID_ZAxis: - has_wheel = true; - break; - case WindowsDirectInputDevice.GUID_Button: - button_count++; - break; - default: - break; + public void handleMouseMoved(int x, int y, long millis, boolean should_center) { + int dx = x - last_x; + int dy = y - last_y; + if (dx != 0 || dy != 0) { + accum_dx += dx; + accum_dy += dy; + last_x = x; + last_y = y; + long nanos = millis*1000000; + if (mouse_grabbed) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + if (should_center) + centerCursor(); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); } - return true; } } + + public void handleMouseButton(byte button, byte state, long millis) { + putMouseEvent(button, state, 0, millis*1000000); + if (button < button_states.length) + button_states[button] = state != 0 ? (byte)1 : (byte)0; + } } Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/common/common_tools.c 2007-04-24 09:30:03 UTC (rev 2799) @@ -141,6 +141,13 @@ throwGeneralException(env, "org/lwjgl/fmod3/FMODException", err); } +void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...) { + va_list ap; + va_start(ap, format); + throwFormattedGeneralException(env, "java/lang/RuntimeException", format, ap); + va_end(ap); +} + void throwFormattedException(JNIEnv * env, const char *format, ...) { va_list ap; va_start(ap, format); Modified: trunk/LWJGL/src/native/common/common_tools.h =================================================================== --- trunk/LWJGL/src/native/common/common_tools.h 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/common/common_tools.h 2007-04-24 09:30:03 UTC (rev 2799) @@ -130,6 +130,7 @@ extern bool isDebugEnabled(void); extern jstring getVersionString(JNIEnv *env); extern void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err); +extern void throwFormattedRuntimeException(JNIEnv * env, const char *format, ...); extern void throwException(JNIEnv *env, const char *msg); extern void throwFormattedException(JNIEnv * env, const char *format, ...); extern void throwFMODException(JNIEnv * env, const char * err); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/windows/org_lwjgl_input_Cursor.c 2007-04-24 09:30:03 UTC (rev 2799) @@ -45,7 +45,7 @@ #include "common_tools.h" JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateCursor -(JNIEnv *env, jobject self, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) +(JNIEnv *env, jclass unused, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { unsigned char col0, col1, col2, col3, col4, col5, col6, col7; unsigned char mask; @@ -154,8 +154,8 @@ return handle_buffer; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_destroyCursor -(JNIEnv *env, jobject self, jobject handle_buffer) +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_doDestroyCursor +(JNIEnv *env, jclass unused, jobject handle_buffer) { HCURSOR *cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); DestroyCursor(*cursor_handle); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-23 20:50:44 UTC (rev 2798) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-24 09:30:03 UTC (rev 2799) @@ -210,19 +210,65 @@ freeSmallIcon(); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_resetCursorClipping(JNIEnv *env, jclass unused) { - ClipCursor(NULL); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + POINT point; + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 2) { + throwFormattedRuntimeException(env, "Buffer size < 2", size); + return; + } + point.x = buffer[0]; + point.y = buffer[1]; + ClientToScreen(hwnd, &point); + buffer[0] = point.x; + buffer[1] = point.y; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setupCursorClipping(JNIEnv *env, jclass unused, jlong hwnd_ptr) { - HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; - RECT hwnd_client; - if (hwnd != NULL && GetWindowRect(hwnd, &hwnd_client) != 0) { - if (ClipCursor(&hwnd_client) == 0) - throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDesktopWindow(JNIEnv *env, jclass unused) { + return (INT_PTR)GetDesktopWindow(); +} + +static void copyBufferToRect(JNIEnv *env, jobject buffer_handle, RECT *rect) { + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 4) { + throwFormattedRuntimeException(env, "Buffer size < 4", size); + return; } + rect->top = buffer[0]; + rect->bottom = buffer[1]; + rect->left = buffer[2]; + rect->right = buffer[3]; } +static void copyRectToBuffer(JNIEnv *env, RECT *rect, jobject buffer_handle) { + jint *buffer = (jint *)(*env)->GetDirectBufferAddress(env, buffer_handle); + jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle); + if (size < 4) { + throwFormattedRuntimeException(env, "Buffer size < 4", size); + return; + } + buffer[0] = rect->top; + buffer[1] = rect->bottom; + buffer[2] = rect->left; + buffer[3] = rect->right; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clipCursor(JNIEnv *env, jclass unused, jlong hwnd_ptr, jobject handle_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + RECT clip_rect; + LPRECT clip_rect_ptr; + if (handle_buffer != NULL) { + copyBufferToRect(env, handle_buffer, &clip_rect); + clip_rect_ptr = &clip_rect; + } else + clip_rect_ptr = NULL; + if (ClipCursor(clip_rect_ptr) == 0) + throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSwitchDisplayMode(JNIEnv *env, jobject self, jobject mode) { switchDisplayMode(env, mode); } @@ -452,64 +498,36 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition -(JNIEnv * env, jclass unused, jint x, jint y, jboolean fullscreen) { - DWORD windowflags, exstyle; - int transformed_x, transformed_y; - RECT window_rect; - RECT client_rect; - RECT adjusted_client_rect; - - int left_border_width; - int bottom_border_width; - - getWindowFlags(&windowflags, &exstyle, fullscreen, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); - if (!GetClientRect(getCurrentHWND(), &client_rect)) { - printfDebugJava(env, "GetClientRect failed"); - return; - } - - adjusted_client_rect = client_rect; - if (!AdjustWindowRectEx(&adjusted_client_rect, windowflags, FALSE, exstyle)) { - printfDebugJava(env, "AdjustWindowRectEx failed"); - return; - } - - if (!GetWindowRect(getCurrentHWND(), &window_rect)) { - printfDebugJava(env, "GetWindowRect failed"); - return; - } - left_border_width = -adjusted_client_rect.left; - bottom_border_width = adjusted_client_rect.bottom - client_rect.bottom; - - transformed_x = window_rect.left + left_border_width + x; - transformed_y = window_rect.bottom - bottom_border_width - 1 - y; - if (!SetCursorPos(transformed_x, transformed_y)) +(JNIEnv * env, jclass unused, jint x, jint y) { + if (!SetCursorPos(x, y)) printfDebugJava(env, "SetCursorPos failed"); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setNativeCursor - (JNIEnv *env, jobject self, jobject handle_buffer) +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect + (JNIEnv *env, jclass unused, jlong hwnd_int, jobject rect_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; + RECT clientRect; + GetClientRect(hwnd, &clientRect); + copyRectToBuffer(env, &clientRect, rect_buffer); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetNativeCursor + (JNIEnv *env, jclass unused, jlong hwnd_int, jobject handle_buffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_int; HCURSOR *cursor_handle; HCURSOR cursor; if (handle_buffer != NULL) { cursor_handle = (HCURSOR *)(*env)->GetDirectBufferAddress(env, handle_buffer); cursor = *cursor_handle; - SetClassLongPtr(getCurrentHWND(), GCL_HCURSOR, (LONG_PTR)cursor); + SetClassLongPtr(hwnd, GCL_HCURSOR, (LONG_PTR)cursor); SetCursor(cursor); } else { - SetClassLongPtr(getCurrentHWND(), GCL_HCURSOR, (LONG_PTR)NULL); + SetClassLongPtr(hwnd, GCL_HCURSOR, (LONG_PTR)NULL); SetCursor(LoadCursor(NULL, IDC_ARROW)); } } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_transformY(JNIEnv *env, jclass unused, jlong hwnd_int, jint y) { - HWND hwnd = (HWND)(INT_PTR)hwnd_int; - RECT clientRect; - GetClientRect(hwnd, &clientRect); - return (clientRect.bottom - clientRect.top) - 1 - y; -} - JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getSystemMetrics(JNIEnv *env, jclass unused, jint index) { return GetSystemMetrics(index); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-23 20:50:48
|
Revision: 2798 http://svn.sourceforge.net/java-game-lib/?rev=2798&view=rev Author: elias_naur Date: 2007-04-23 13:50:44 -0700 (Mon, 23 Apr 2007) Log Message: ----------- Windows: Fixed NULL check in native setupCursorClipping Modified Paths: -------------- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-23 20:17:42 UTC (rev 2797) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2007-04-23 20:50:44 UTC (rev 2798) @@ -217,7 +217,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setupCursorClipping(JNIEnv *env, jclass unused, jlong hwnd_ptr) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; RECT hwnd_client; - if (display_hwnd != NULL && GetWindowRect(hwnd, &hwnd_client) != 0) { + if (hwnd != NULL && GetWindowRect(hwnd, &hwnd_client) != 0) { if (ClipCursor(&hwnd_client) == 0) throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-23 20:17:47
|
Revision: 2797 http://svn.sourceforge.net/java-game-lib/?rev=2797&view=rev Author: elias_naur Date: 2007-04-23 13:17:42 -0700 (Mon, 23 Apr 2007) Log Message: ----------- Added support for non-direct in glGet* style functions Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL15.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_evaluators.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fence.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_fragment_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_gpu_program4.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_occlusion_query.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_program.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_register_combiners.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_register_combiners2.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_vertex_program.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java Modified: trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -67,6 +67,36 @@ return buffers; } + public static ByteBuffer wrapNoCopyBuffer(ByteBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static ShortBuffer wrapNoCopyBuffer(ShortBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static IntBuffer wrapNoCopyBuffer(IntBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static LongBuffer wrapNoCopyBuffer(LongBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static FloatBuffer wrapNoCopyBuffer(FloatBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + + public static DoubleBuffer wrapNoCopyBuffer(DoubleBuffer buf, int size) { + BufferChecks.checkBufferSize(buf, size); + return wrapNoCopyDirect(buf); + } + public static ByteBuffer wrapBuffer(ByteBuffer buf, int size) { BufferChecks.checkBufferSize(buf, size); return wrapDirect(buf); @@ -133,8 +163,138 @@ return buffer; } + public static ByteBuffer wrapNoCopyDirect(ByteBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static LongBuffer wrapNoCopyDirect(LongBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static DoubleBuffer wrapNoCopyDirect(DoubleBuffer buffer) { + if (!buffer.isDirect()) + return doNoCopyWrap(buffer); + return buffer; + } + + public static void copy(ByteBuffer src, ByteBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(ShortBuffer src, ShortBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(IntBuffer src, IntBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(FloatBuffer src, FloatBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(LongBuffer src, LongBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + public static void copy(DoubleBuffer src, DoubleBuffer dst) { + if (dst != null && !dst.isDirect()) { + int saved_position = dst.position(); + dst.put(src); + dst.position(saved_position); + } + } + + private static ByteBuffer doNoCopyWrap(ByteBuffer buffer) { + ByteBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) { + ShortBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static IntBuffer doNoCopyWrap(IntBuffer buffer) { + IntBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static FloatBuffer doNoCopyWrap(FloatBuffer buffer) { + FloatBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static LongBuffer doNoCopyWrap(LongBuffer buffer) { + LongBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) { + DoubleBuffer direct_buffer = lookupBuffer(buffer); + direct_buffer.limit(buffer.limit()); + direct_buffer.position(buffer.position()); + return direct_buffer; + } + + private static ByteBuffer lookupBuffer(ByteBuffer buffer) { + return getCachedBuffers(buffer.remaining()).byte_buffer; + } + private static ByteBuffer doWrap(ByteBuffer buffer) { - ByteBuffer direct_buffer = getCachedBuffers(buffer.remaining()).byte_buffer; + ByteBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -143,9 +303,13 @@ return direct_buffer; } + private static ShortBuffer lookupBuffer(ShortBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big; + } + private static ShortBuffer doWrap(ShortBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2); - ShortBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big; + ShortBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -154,9 +318,13 @@ return direct_buffer; } + private static FloatBuffer lookupBuffer(FloatBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big; + } + private static FloatBuffer doWrap(FloatBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); - FloatBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big; + FloatBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -165,9 +333,13 @@ return direct_buffer; } + private static IntBuffer lookupBuffer(IntBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big; + } + private static IntBuffer doWrap(IntBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4); - IntBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big; + IntBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -176,9 +348,13 @@ return direct_buffer; } + private static LongBuffer lookupBuffer(LongBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big; + } + private static LongBuffer doWrap(LongBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); - LongBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big; + LongBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); @@ -187,9 +363,13 @@ return direct_buffer; } + private static DoubleBuffer lookupBuffer(DoubleBuffer buffer) { + CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); + return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big; + } + private static DoubleBuffer doWrap(DoubleBuffer buffer) { - CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8); - DoubleBuffer direct_buffer = buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big; + DoubleBuffer direct_buffer = lookupBuffer(buffer); direct_buffer.clear(); int saved_position = buffer.position(); direct_buffer.put(buffer); Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -50,6 +50,8 @@ import java.nio.*; public class JavaMethodsGenerator { + private final static String SAVED_PARAMETER_POSTFIX = "_saved"; + public static void generateMethodsJava(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration interface_decl, boolean generate_error_checks, boolean context_specific) { for (MethodDeclaration method : interface_decl.getMethods()) generateMethodJava(env, type_map, writer, interface_decl, method, generate_error_checks, context_specific); @@ -197,7 +199,7 @@ if (code_annotation != null) writer.println(code_annotation.value()); printBufferObjectChecks(writer, method, mode); - printParameterChecks(writer, method, mode); + printParameterChecks(writer, method, typeinfos_instance, mode); printParameterCaching(writer, interface_decl, method, mode); writer.print("\t\t"); boolean has_result = !result_type.equals(env.getTypeUtils().getVoidType()); @@ -218,6 +220,7 @@ writer.println(");"); if (generate_error_checks && method.getAnnotation(NoErrorCheck.class) == null) writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); + printNondirectParameterCopies(writer, method, mode); if (has_result) writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); writer.println("\t}"); @@ -409,13 +412,29 @@ } } - private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Mode mode) { + private static void printNondirectParameterCopies(PrintWriter writer, MethodDeclaration method, Mode mode) { for (ParameterDeclaration param : method.getParameters()) { Class java_type = Utils.getJavaType(param.getType()); if (Utils.isAddressableType(java_type) && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && param.getAnnotation(Result.class) == null) { + if (Buffer.class.isAssignableFrom(java_type)) { + boolean out_parameter = param.getAnnotation(OutParameter.class) != null; + if (out_parameter) + writer.println("\t\tNondirectBufferWrapper.copy(" + param.getSimpleName() + ", " + param.getSimpleName() + SAVED_PARAMETER_POSTFIX + ");"); + } + } + } + } + + private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos, Mode mode) { + for (ParameterDeclaration param : method.getParameters()) { + Class java_type = Utils.getJavaType(param.getType()); + if (Utils.isAddressableType(java_type) && + (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && + (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && + param.getAnnotation(Result.class) == null) { String check_value = null; boolean can_be_null = false; Check check_annotation = param.getAnnotation(Check.class); @@ -426,7 +445,9 @@ boolean null_terminated = param.getAnnotation(NullTerminated.class) != null; if (Buffer.class.isAssignableFrom(java_type)) { boolean indirect_buffer_allowed = param.getAnnotation(CachedReference.class) == null; - printParameterCheck(writer, param.getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed); + boolean out_parameter = param.getAnnotation(OutParameter.class) != null; + TypeInfo typeinfo = typeinfos.get(param); + printParameterCheck(writer, param.getSimpleName(), typeinfo.getType().getSimpleName(), check_value, can_be_null, null_terminated, indirect_buffer_allowed, out_parameter); } else if (String.class.equals(java_type)) { if (!can_be_null) writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");"); @@ -434,17 +455,22 @@ } } if (method.getAnnotation(CachedResult.class) != null) - printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, true, false, false); + printParameterCheck(writer, Utils.CACHED_BUFFER_NAME, null, null, true, false, false, false); } - private static void printParameterCheck(PrintWriter writer, String name, String check_value, boolean can_be_null, boolean null_terminated, boolean indirect_buffer_allowed) { + private static void printParameterCheck(PrintWriter writer, String name, String type, String check_value, boolean can_be_null, boolean null_terminated, boolean indirect_buffer_allowed, boolean out_parameter) { + if (indirect_buffer_allowed && out_parameter) { + writer.println("\t\t" + type + " " + name + SAVED_PARAMETER_POSTFIX + " = " + name + ";"); + } if (can_be_null) { writer.println("\t\tif (" + name + " != null)"); writer.print("\t"); } - if (indirect_buffer_allowed) + if (indirect_buffer_allowed) { writer.print("\t\t" + name + " = NondirectBufferWrapper.wrap"); - else + if (out_parameter) + writer.print("NoCopy"); + } else writer.print("\t\tBufferChecks.check"); if (check_value != null && !"".equals(check_value) ) { writer.print("Buffer(" + name + ", " + check_value); Added: trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/OutParameter.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * 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.util.generator; + +/** + * This annotation indicates that a parameter is written, + * not read. + * + * @author elias_naur <eli...@us...> + * @version $Revision: 2286 $ + * $Id: Check.java 2286 2006-03-23 19:32:21Z matzon $ + */ + +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target(ElementType.PARAMETER) +public @interface OutParameter { +} Modified: trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/openal/AL10.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -480,7 +480,7 @@ */ @StripPostfix("data") @ALvoid - void alGetIntegerv(@ALenum int pname, @Check("1") IntBuffer data); + void alGetIntegerv(@ALenum int pname, @OutParameter @Check("1") IntBuffer data); /** * Like OpenGL, AL uses a simplified interface for querying global state. @@ -498,7 +498,7 @@ */ @StripPostfix("data") @ALvoid - void alGetFloatv(@ALenum int pname, @Check("1") FloatBuffer data); + void alGetFloatv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer data); /** * Like OpenGL, AL uses a simplified interface for querying global state. @@ -516,7 +516,7 @@ */ @StripPostfix("data") @ALvoid - void alGetDoublev(@ALenum int pname, @Check("1") DoubleBuffer data); + void alGetDoublev(@ALenum int pname, @OutParameter @Check("1") DoubleBuffer data); /** * The application can retrieve state information global to the current AL Context. @@ -711,7 +711,7 @@ // TODO: What's the real minimum number of elements? @StripPostfix("floatdata") @ALvoid - void alGetListenerfv(@ALenum int pname, @Check("1") FloatBuffer floatdata); + void alGetListenerfv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata); /** * The application requests a number of Sources using GenSources. @@ -827,7 +827,7 @@ // TODO: What's the correct minimum value? @StripPostfix("floatdata") @ALvoid - void alGetSourcefv(@ALuint int source, @ALenum int pname, @Check("1") FloatBuffer floatdata); + void alGetSourcefv(@ALuint int source, @ALenum int pname, @OutParameter @Check("1") FloatBuffer floatdata); /** * Play() applied to an AL_INITIAL Source will promote the Source to AL_PLAYING, thus Modified: trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/openal/AL11.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -100,7 +100,7 @@ // TODO: What's the real minimum number of elements? @StripPostfix("intdata") @ALvoid - void alGetListeneriv(@ALenum int pname, @Check("1") FloatBuffer intdata); + void alGetListeneriv(@ALenum int pname, @OutParameter @Check("1") FloatBuffer intdata); /** * Specifies the position and other properties as taken into account during @@ -229,7 +229,7 @@ // TODO: What's the correct minimum value? @StripPostfix("values") @ALvoid - void alGetBufferiv(@ALuint int buffer, @ALenum int pname, @Check("1") IntBuffer values); + void alGetBufferiv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") IntBuffer values); /** * This function retrieves a floating point property of a buffer. @@ -254,7 +254,7 @@ // TODO: What's the correct minimum value? @StripPostfix("values") @ALvoid - void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @Check("1") FloatBuffer values); + void alGetBufferfv(@ALuint int buffer, @ALenum int pname, @OutParameter @Check("1") FloatBuffer values); /** * <p> Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_buffer_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -94,6 +94,7 @@ @GLdouble Buffer data); void glGetBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size, + @OutParameter @Check @GLbyte @GLshort @@ -121,7 +122,7 @@ boolean glUnmapBufferARB(@GLenum int target); @StripPostfix("params") - void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("pointer") @AutoResultSize("GLChecks.getBufferObjectSizeARB(caps, target)") Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_imaging.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -150,6 +150,7 @@ void glCopyColorTable(@GLenum int target, @GLenum int internalformat, int x, int y, @GLsizei int width); void glGetColorTable(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @Check("256") @GLbyte @GLfloat @@ -170,6 +171,7 @@ void glResetHistogram(@GLenum int target); void glGetHistogram(@GLenum int target, boolean reset, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check("256") @GLbyte @@ -179,16 +181,17 @@ @GLdouble Buffer values); @StripPostfix("params") - void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @Check("256") FloatBuffer params); + void glGetHistogramParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") FloatBuffer params); @StripPostfix("params") - void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @Check("256") IntBuffer params); + void glGetHistogramParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("256") IntBuffer params); void glMinmax(@GLenum int target, @GLenum int internalformat, boolean sink); void glResetMinmax(@GLenum int target); void glGetMinmax(@GLenum int target, boolean reset, @GLenum int format, @GLenum int types, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check("4") @GLbyte @@ -198,10 +201,10 @@ @GLdouble Buffer values); @StripPostfix("params") - void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetMinmaxParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetMinmaxParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glConvolutionFilter1D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLenum int format, @GLenum int type, @BufferObject(BufferKind.UnpackPBO) @@ -237,6 +240,7 @@ // TODO: check buffer size valid void glGetConvolutionFilter(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check @GLbyte @@ -246,10 +250,10 @@ @GLdouble Buffer image); @StripPostfix("params") - void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetConvolutionParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetConvolutionParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); // TODO: check buffer size valid void glSeparableFilter2D(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height, @GLenum int format, @GLenum int type, @@ -272,6 +276,7 @@ // TODO: check buffer size valid void glGetSeparableFilter(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check @GLbyte @@ -291,4 +296,4 @@ @GLshort @GLint @GLdouble Buffer span); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_occlusion_query.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -67,11 +67,11 @@ void glEndQueryARB(@GLenum int target); @StripPostfix("params") - void glGetQueryivARB(@GLenum int target, @GLenum int pname, @Check("1") IntBuffer params); + void glGetQueryivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); @StripPostfix("params") - void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @Check("1") IntBuffer params); + void glGetQueryObjectivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); @StripPostfix("params") - void glGetQueryObjectuivARB(@GLuint int id, @GLenum int pname, @Check("1") IntBuffer params); -} \ No newline at end of file + void glGetQueryObjectuivARB(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") IntBuffer params); +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_program.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -155,21 +155,21 @@ void glProgramLocalParameter4dvARB(@GLenum int target, @GLuint int index, @Check("4") @Const DoubleBuffer params); @StripPostfix("params") - void glGetProgramEnvParameterfvARB(@GLenum int target, @GLuint int index, @Check("4") FloatBuffer params); + void glGetProgramEnvParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetProgramEnvParameterdvARB(@GLenum int target, @GLuint int index, @Check("4") DoubleBuffer params); + void glGetProgramEnvParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") - void glGetProgramLocalParameterfvARB(@GLenum int target, @GLuint int index, @Check("4") FloatBuffer params); + void glGetProgramLocalParameterfvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetProgramLocalParameterdvARB(@GLenum int target, @GLuint int index, @Check("4") DoubleBuffer params); + void glGetProgramLocalParameterdvARB(@GLenum int target, @GLuint int index, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") - void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @Check("4") IntBuffer params); + void glGetProgramivARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check("4") IntBuffer params); - void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @Check @GLbyte Buffer paramString); + void glGetProgramStringARB(@GLenum int target, @GLenum int parameterName, @OutParameter @Check @GLbyte Buffer paramString); boolean glIsProgramARB(@GLuint int program); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -177,17 +177,19 @@ void glUniformMatrix4fvARB(int location, @AutoSize(value = "matrices", expression = " >> 4") @GLsizei int count, boolean transpose, FloatBuffer matrices); @StripPostfix("params") - void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @Check FloatBuffer params); + void glGetObjectParameterfvARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @Check IntBuffer params); + void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params); void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @GLcharARB ByteBuffer infoLog); void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer count, @GLhandleARB IntBuffer obj); @@ -201,6 +203,7 @@ int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @Check("1") IntBuffer size, @@ -209,12 +212,13 @@ @GLcharARB ByteBuffer name); @StripPostfix("params") - void glGetUniformfvARB(@GLhandleARB int programObj, int location, @Check FloatBuffer params); + void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetUniformivARB(@GLhandleARB int programObj, int location, @Check IntBuffer params); + void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params); void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @GLcharARB ByteBuffer source); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_texture_compression.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -91,6 +91,7 @@ ByteBuffer pData); void glGetCompressedTexImageARB(@GLenum int target, int lod, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check @GLvoid Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_program.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -130,13 +130,13 @@ void glDisableVertexAttribArrayARB(@GLuint int index); @StripPostfix("params") - void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @Check FloatBuffer params); + void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @Check DoubleBuffer params); + void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check DoubleBuffer params); @StripPostfix("params") - void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @Check IntBuffer params); + void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check IntBuffer params); @StripPostfix("result") void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -144,23 +144,27 @@ void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, + @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @Check("1") @GLenum IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); int glGetAttribLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); @StripPostfix("params") - void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @Check FloatBuffer params); + void glGetVertexAttribfvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @Check DoubleBuffer params); + void glGetVertexAttribdvARB(@GLuint int index, @GLenum int pname, @OutParameter @Check DoubleBuffer params); @StripPostfix("params") - void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @Check IntBuffer params); + void glGetVertexAttribivARB(@GLuint int index, @GLenum int pname, @OutParameter @Check IntBuffer params); @StripPostfix("result") void glGetVertexAttribPointervARB(@GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer result); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_envmap_bumpmap.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -52,8 +52,8 @@ void glTexBumpParameterivATI(@GLenum int pname, @Check("4") @Const IntBuffer param); @StripPostfix("param") - void glGetTexBumpParameterfvATI(@GLenum int pname, @Check("4") FloatBuffer param); + void glGetTexBumpParameterfvATI(@GLenum int pname, @OutParameter @Check("4") FloatBuffer param); @StripPostfix("param") - void glGetTexBumpParameterivATI(@GLenum int pname, @Check("4") IntBuffer param); + void glGetTexBumpParameterivATI(@GLenum int pname, @OutParameter @Check("4") IntBuffer param); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_array_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -66,26 +66,26 @@ @GLdouble Buffer pPointer, @GLenum int preserve); @StripPostfix("params") - void glGetObjectBufferfvATI(@GLuint int buffer, @GLenum int pname, @Check FloatBuffer params); + void glGetObjectBufferfvATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check FloatBuffer params); @StripPostfix("params") - void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @Check IntBuffer params); + void glGetObjectBufferivATI(@GLuint int buffer, @GLenum int pname, @OutParameter @Check IntBuffer params); void glFreeObjectBufferATI(@GLuint int buffer); void glArrayObjectATI(@GLenum int array, int size, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); @StripPostfix("params") - void glGetArrayObjectfvATI(@GLenum int array, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetArrayObjectfvATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetArrayObjectivATI(@GLenum int array, @GLenum int pname, @Check("4") IntBuffer params); + void glGetArrayObjectivATI(@GLenum int array, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glVariantArrayObjectATI(@GLuint int id, @GLenum int type, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); @StripPostfix("params") - void glGetVariantArrayObjectfvATI(@GLuint int id, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetVariantArrayObjectfvATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetVariantArrayObjectivATI(@GLuint int id, @GLenum int pname, @Check("4") IntBuffer params); + void glGetVariantArrayObjectivATI(@GLuint int id, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ATI_vertex_attrib_array_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -39,8 +39,8 @@ void glVertexAttribArrayObjectATI(@GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLuint int buffer, @GLuint int offset); @StripPostfix("params") - void glGetVertexAttribArrayObjectfvATI(@GLuint int index, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetVertexAttribArrayObjectfvATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetVertexAttribArrayObjectivATI(@GLuint int index, @GLenum int pname, @Check("4") IntBuffer params); + void glGetVertexAttribArrayObjectivATI(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_draw_buffers2.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -41,10 +41,10 @@ void glColorMaskIndexedEXT(@GLuint int buf, boolean r, boolean g, boolean b, boolean a); @StripPostfix("data") - void glGetBooleanIndexedvEXT(@GLenum int value, @GLuint int index, @Check("4") @GLboolean ByteBuffer data); + void glGetBooleanIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") @GLboolean ByteBuffer data); @StripPostfix("data") - void glGetIntegerIndexedvEXT(@GLenum int value, @GLuint int index, @Check("4") IntBuffer data); + void glGetIntegerIndexedvEXT(@GLenum int value, @GLuint int index, @OutParameter @Check("4") IntBuffer data); void glEnableIndexedEXT(@GLenum int target, @GLuint int index); @@ -52,4 +52,4 @@ boolean glIsEnabledIndexedEXT(@GLenum int target, @GLuint int index); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_framebuffer_object.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -143,7 +143,7 @@ void glRenderbufferStorageEXT(@GLenum int target, @GLenum int internalformat, @GLsizei int width, @GLsizei int height); @StripPostfix("params") - void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetRenderbufferParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); boolean glIsFramebufferEXT(@GLuint int framebuffer); @@ -165,7 +165,7 @@ void glFramebufferRenderbufferEXT(@GLenum int target, @GLenum int attachment, @GLenum int renderbuffertarget, @GLuint int renderbuffer); @StripPostfix("params") - void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @Check("4") IntBuffer params); + void glGetFramebufferAttachmentParameterivEXT(@GLenum int target, @GLenum int attachment, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glGenerateMipmapEXT(@GLenum int target); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -148,10 +148,10 @@ @GLuint Buffer buffer); @StripPostfix("params") - void glGetVertexAttribIivEXT(@GLuint int index, @GLenum int pname, @Check("4")IntBuffer params); + void glGetVertexAttribIivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4")IntBuffer params); @StripPostfix("params") - void glGetVertexAttribIuivEXT(@GLuint int index, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + void glGetVertexAttribIuivEXT(@GLuint int index, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); void glUniform1uiEXT(int location, @GLuint int v0); @@ -174,10 +174,10 @@ void glUniform4uivEXT(int location, @AutoSize(value = "value", expression = " >> 2") @GLsizei int count, @Const @GLuint IntBuffer value); @StripPostfix("params") - void glGetUniformuivEXT(@GLuint int program, int location, @Check @GLuint IntBuffer params); + void glGetUniformuivEXT(@GLuint int program, int location, @OutParameter @Check @GLuint IntBuffer params); void glBindFragDataLocationEXT(@GLuint int program, @GLuint int colorNumber, @NullTerminated @Const @GLchar ByteBuffer name); int glGetFragDataLocationEXT(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_paletted_texture.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -85,6 +85,7 @@ @GLdouble Buffer data); void glGetColorTableEXT(@GLenum int target, @GLenum int format, @GLenum int type, + @OutParameter @Check @GLbyte @GLshort @@ -93,8 +94,8 @@ @GLdouble Buffer data); @StripPostfix("params") - void glGetColorTableParameterivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetColorTableParameterivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetColorTableParameterfvEXT(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetColorTableParameterfvEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_texture_integer.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -35,6 +35,7 @@ import org.lwjgl.util.generator.GLenum; import org.lwjgl.util.generator.GLuint; import org.lwjgl.util.generator.StripPostfix; +import org.lwjgl.util.generator.OutParameter; import java.nio.IntBuffer; @@ -113,15 +114,15 @@ void glClearColorIuiEXT(@GLuint int r, @GLuint int g, @GLuint int b, @GLuint int a); @StripPostfix("params") - void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4")IntBuffer params); + void glTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); @StripPostfix("params") void glTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); @StripPostfix("params") - void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @Check("4")IntBuffer params); + void glGetTexParameterIivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @Check("4") @GLuint IntBuffer params); + void glGetTexParameterIuivEXT(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") @GLuint IntBuffer params); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_timer_query.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -44,9 +44,9 @@ int GL_TIME_ELAPSED_EXT = 0x88BF; @StripPostfix("params") - void glGetQueryObjecti64vEXT(@GLuint int id, @GLenum int pname, @Check("1") @GLint64EXT LongBuffer params); + void glGetQueryObjecti64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLint64EXT LongBuffer params); @StripPostfix("params") - void glGetQueryObjectui64vEXT(@GLuint int id, @GLenum int pname, @Check("1") @GLuint64EXT LongBuffer params); + void glGetQueryObjectui64vEXT(@GLuint int id, @GLenum int pname, @OutParameter @Check("1") @GLuint64EXT LongBuffer params); -} \ No newline at end of file +} Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_vertex_shader.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -259,32 +259,32 @@ boolean glIsVariantEnabledEXT(@GLuint int id, @GLenum int cap); @StripPostfix("pbData") - void glGetVariantBooleanvEXT(@GLuint int id, @GLenum int value, @Check("4") ByteBuffer pbData); + void glGetVariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); @StripPostfix("pbData") - void glGetVariantIntegervEXT(@GLuint int id, @GLenum int value, @Check("4") IntBuffer pbData); + void glGetVariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); @StripPostfix("pbData") - void glGetVariantFloatvEXT(@GLuint int id, @GLenum int value, @Check("4") FloatBuffer pbData); + void glGetVariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); @StripPostfix("pbData") - void glGetVariantPointervEXT(@GLuint int id, @GLenum int value, @Result @GLvoid ByteBuffer pbData); + void glGetVariantPointervEXT(@GLuint int id, @GLenum int value, @OutParameter @Result @GLvoid ByteBuffer pbData); @StripPostfix("pbData") - void glGetInvariantBooleanvEXT(@GLuint int id, @GLenum int value, @Check("4") ByteBuffer pbData); + void glGetInvariantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); @StripPostfix("pbData") - void glGetInvariantIntegervEXT(@GLuint int id, @GLenum int value, @Check("4") IntBuffer pbData); + void glGetInvariantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); @StripPostfix("pbData") - void glGetInvariantFloatvEXT(@GLuint int id, @GLenum int value, @Check("4") FloatBuffer pbData); + void glGetInvariantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); @StripPostfix("pbData") - void glGetLocalConstantBooleanvEXT(@GLuint int id, @GLenum int value, @Check("4") ByteBuffer pbData); + void glGetLocalConstantBooleanvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") ByteBuffer pbData); @StripPostfix("pbData") - void glGetLocalConstantIntegervEXT(@GLuint int id, @GLenum int value, @Check("4") IntBuffer pbData); + void glGetLocalConstantIntegervEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") IntBuffer pbData); @StripPostfix("pbData") - void glGetLocalConstantFloatvEXT(@GLuint int id, @GLenum int value, @Check("4") FloatBuffer pbData); + void glGetLocalConstantFloatvEXT(@GLuint int id, @GLenum int value, @OutParameter @Check("4") FloatBuffer pbData); } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL11.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -886,51 +886,51 @@ void glFeedbackBuffer(@AutoSize("buffer") @GLsizei int size, @GLenum int type, FloatBuffer buffer); @StripPostfix("values") - void glGetPixelMapfv(@GLenum int map, @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values); + void glGetPixelMapfv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) FloatBuffer values); @StripPostfix("values") - void glGetPixelMapuiv(@GLenum int map, @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values); + void glGetPixelMapuiv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLuint IntBuffer values); @StripPostfix("values") - void glGetPixelMapusv(@GLenum int map, @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values); + void glGetPixelMapusv(@GLenum int map, @OutParameter @Check("256") @BufferObject(BufferKind.PackPBO) @GLushort ShortBuffer values); @StripPostfix("params") - void glGetMaterialfv(@GLenum int face, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetMaterialfv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetMaterialiv(@GLenum int face, @GLenum int pname, @Check("4") IntBuffer params); + void glGetMaterialiv(@GLenum int face, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("v") - void glGetMapfv(@GLenum int target, @GLenum int query, @Check("256") FloatBuffer v); + void glGetMapfv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") FloatBuffer v); @StripPostfix("v") - void glGetMapdv(@GLenum int target, @GLenum int query, @Check("256") DoubleBuffer v); + void glGetMapdv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") DoubleBuffer v); @StripPostfix("v") - void glGetMapiv(@GLenum int target, @GLenum int query, @Check("256") IntBuffer v); + void glGetMapiv(@GLenum int target, @GLenum int query, @OutParameter @Check("256") IntBuffer v); @StripPostfix("params") - void glGetLightfv(@GLenum int light, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetLightfv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetLightiv(@GLenum int light, @GLenum int pname, @Check("4") IntBuffer params); + void glGetLightiv(@GLenum int light, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @NoErrorCheck int glGetError(); - void glGetClipPlane(@GLenum int plane, @Check("4") DoubleBuffer equation); + void glGetClipPlane(@GLenum int plane, @OutParameter @Check("4") DoubleBuffer equation); @StripPostfix("params") - void glGetBooleanv(@GLenum int pname, @Check("16") @GLboolean ByteBuffer params); + void glGetBooleanv(@GLenum int pname, @OutParameter @Check("16") @GLboolean ByteBuffer params); @StripPostfix("params") - void glGetDoublev(@GLenum int pname, @Check("16") DoubleBuffer params); + void glGetDoublev(@GLenum int pname, @OutParameter @Check("16") DoubleBuffer params); @StripPostfix("params") - void glGetFloatv(@GLenum int pname, @Check("16") FloatBuffer params); + void glGetFloatv(@GLenum int pname, @OutParameter @Check("16") FloatBuffer params); @StripPostfix("params") - void glGetIntegerv(@GLenum int pname, @Check("16") IntBuffer params); + void glGetIntegerv(@GLenum int pname, @OutParameter @Check("16") IntBuffer params); void glGenTextures(@AutoSize("textures") @GLsizei int n, @GLuint IntBuffer textures); @@ -975,18 +975,19 @@ void glHint(@GLenum int target, @GLenum int mode); @StripPostfix("params") - void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexParameterfv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexParameteriv(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexLevelParameterfv(@GLenum int target, int level, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexLevelParameterfv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetTexLevelParameteriv(@GLenum int target, int level, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexLevelParameteriv(@GLenum int target, int level, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); void glGetTexImage(@GLenum int target, int level, @GLenum int format, @GLenum int type, + @OutParameter @BufferObject(BufferKind.PackPBO) @Check("GLChecks.calculateImageStorage(pixels, format, type, 1, 1, 1)") @GLbyte @@ -996,24 +997,24 @@ @GLdouble Buffer pixels); @StripPostfix("params") - void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexGeniv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexGenfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @StripPostfix("params") - void glGetTexGendv(@GLenum int coord, @GLenum int pname, @Check("4") DoubleBuffer params); + void glGetTexGendv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") DoubleBuffer params); @StripPostfix("params") - void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @Check("4") IntBuffer params); + void glGetTexEnviv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); @StripPostfix("params") - void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @Check("4") FloatBuffer params); + void glGetTexEnvfv(@GLenum int coord, @GLenum int pname, @OutParameter @Check("4") FloatBuffer params); @Const String glGetString(int name); - void glGetPolygonStipple(@BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); + void glGetPolygonStipple(@OutParameter @BufferObject(BufferKind.PackPBO) @Check("1024") @GLubyte ByteBuffer mask); boolean glIsList(@GLuint int list); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java 2007-04-23 16:47:25 UTC (rev 2796) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/GL13.java 2007-04-23 20:17:42 UTC (rev 2797) @@ -194,6 +194,7 @@ // TODO: check buffer size valid void glGetCompressedTexImage(@GLenum int target, int lod, + ... [truncated message content] |
From: <eli...@us...> - 2007-04-23 16:47:26
|
Revision: 2796 http://svn.sourceforge.net/java-game-lib/?rev=2796&view=rev Author: elias_naur Date: 2007-04-23 09:47:25 -0700 (Mon, 23 Apr 2007) Log Message: ----------- Added support for non-direct buffers to Cursor Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java Modified: trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2007-04-22 21:29:28 UTC (rev 2795) +++ trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2007-04-23 16:47:25 UTC (rev 2796) @@ -35,6 +35,7 @@ import org.lwjgl.BufferChecks; import org.lwjgl.BufferUtils; +import org.lwjgl.NondirectBufferWrapper; import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; import org.lwjgl.Sys; @@ -86,13 +87,13 @@ synchronized (OpenGLPackageAccess.global_lock) { if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0) throw new LWJGLException("Native cursors not supported"); - BufferChecks.checkBuffer(images, width*height*numImages); + images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages); + if (delays != null) + delays = NondirectBufferWrapper.wrapBuffer(delays, numImages); 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()) - BufferChecks.checkBuffer(delays, numImages); if (xHotspot >= width || xHotspot < 0) throw new IllegalArgumentException("xHotspot > width || xHotspot < 0"); if (yHotspot >= height || yHotspot < 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-22 21:29:29
|
Revision: 2795 http://svn.sourceforge.net/java-game-lib/?rev=2795&view=rev Author: elias_naur Date: 2007-04-22 14:29:28 -0700 (Sun, 22 Apr 2007) Log Message: ----------- Inline optimizations to state trackers by MatthiasM Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2007-04-19 23:13:52 UTC (rev 2794) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2007-04-22 21:29:28 UTC (rev 2795) @@ -40,23 +40,26 @@ } public void pushState() { - stack_pos++; - if (stack_pos == references_stack.length) { - References[] new_references_stack = new References[references_stack.length + 1]; - System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); - references_stack = new_references_stack; - references_stack[references_stack.length - 1] = new References(); + int pos = ++stack_pos; + if (pos == references_stack.length) { + growStack(); } - references_stack[stack_pos].copy(references_stack[stack_pos - 1]); + references_stack[pos].copy(references_stack[pos - 1]); } public References popState() { - References result = references_stack[stack_pos]; - references_stack[stack_pos].clear(); - stack_pos--; + References result = references_stack[stack_pos--]; + result.clear(); return result; } + private void growStack() { + References[] new_references_stack = new References[references_stack.length + 1]; + System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); + references_stack = new_references_stack; + references_stack[references_stack.length - 1] = new References(); + } + ReferencesStack() { references_stack = new References[1]; stack_pos = 0; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java 2007-04-19 23:13:52 UTC (rev 2794) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java 2007-04-22 21:29:28 UTC (rev 2795) @@ -39,26 +39,24 @@ return state_stack[stack_pos]; } - public void setState(int new_state) { - state_stack[stack_pos] = new_state; - } - - public void pushState() { - stack_pos++; - if (stack_pos == state_stack.length) { - int[] new_state_stack = new int[state_stack.length + 1]; - System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length); - state_stack = new_state_stack; + public void pushState(int new_state) { + int pos = ++stack_pos; + if (pos == state_stack.length) { + growState(); } - state_stack[stack_pos] = state_stack[stack_pos - 1]; + state_stack[pos] = new_state; } public int popState() { - int result = state_stack[stack_pos]; - stack_pos--; - return result; + return state_stack[stack_pos--]; } + public void growState() { + int[] new_state_stack = new int[state_stack.length + 1]; + System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length); + state_stack = new_state_stack; + } + StateStack(int initial_value) { state_stack = new int[1]; stack_pos = 0; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2007-04-19 23:13:52 UTC (rev 2794) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2007-04-22 21:29:28 UTC (rev 2795) @@ -49,14 +49,13 @@ references_stack.popState(); } } - + static void pushAttrib(ContextCapabilities caps, int mask) { caps.tracker.doPushAttrib(mask); } private void doPushAttrib(int mask) { - attrib_stack.pushState(); - attrib_stack.setState(mask); + attrib_stack.pushState(mask); if ((mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) { references_stack.pushState(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 23:13:54
|
Revision: 2794 http://svn.sourceforge.net/java-game-lib/?rev=2794&view=rev Author: matzon Date: 2007-04-19 16:13:52 -0700 (Thu, 19 Apr 2007) Log Message: ----------- fixing warnings Modified Paths: -------------- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2007-04-19 23:02:57 UTC (rev 2793) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC11.c 2007-04-19 23:13:52 UTC (rev 2794) @@ -68,10 +68,10 @@ dev_name = (ALubyte*) GetStringNativeChars(env, devicename); } - device = alcCaptureOpenDevice(dev_name, frequency, format, buffersize); + device = alcCaptureOpenDevice((const char *)dev_name, (unsigned int) frequency, format, buffersize); free(dev_name); - return (jlong) device; + return (jlong) ((intptr_t)device); } /* @@ -80,7 +80,7 @@ * Signature: (J)Z */ static jboolean JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureCloseDevice(JNIEnv *env, jclass clazz, jlong device) { - return (jboolean) alcCaptureCloseDevice((ALCdevice*) device); + return (jboolean) alcCaptureCloseDevice((ALCdevice*) ((intptr_t)device)); } /* @@ -89,7 +89,7 @@ * Signature: (J)V */ static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureStart(JNIEnv *env, jclass clazz, jlong device) { - alcCaptureStart((ALCdevice*) device); + alcCaptureStart((ALCdevice*) ((intptr_t)device)); } /* @@ -98,7 +98,7 @@ * Signature: (J)V */ static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureStop(JNIEnv * env, jclass clazz, jlong device) { - alcCaptureStop((ALCdevice*) device); + alcCaptureStop((ALCdevice*) ((intptr_t)device)); } /* @@ -108,7 +108,7 @@ */ static void JNICALL Java_org_lwjgl_openal_ALC11_nalcCaptureSamples(JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, jint samples) { ALuint *buffer_address = ((ALuint *)(*env)->GetDirectBufferAddress(env, buffer)) + position; - alcCaptureSamples((ALCdevice*) device, buffer_address, samples); + alcCaptureSamples((ALCdevice*) ((intptr_t)device), buffer_address, samples); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 23:02:58
|
Revision: 2793 http://svn.sourceforge.net/java-game-lib/?rev=2793&view=rev Author: matzon Date: 2007-04-19 16:02:57 -0700 (Thu, 19 Apr 2007) Log Message: ----------- fixing warnings Modified Paths: -------------- trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2007-04-19 22:58:13 UTC (rev 2792) +++ trunk/LWJGL/src/native/common/common_tools.c 2007-04-19 23:02:57 UTC (rev 2793) @@ -204,7 +204,6 @@ jmethodID jmethod_str; jstring result; jbyteArray bytes; - int len; if (str==NULL) { return NULL; } Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2007-04-19 22:58:13 UTC (rev 2792) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2007-04-19 23:02:57 UTC (rev 2793) @@ -190,7 +190,6 @@ */ static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent (JNIEnv *env, jclass clazz, jlong contextaddress) { ALCcontext* context = (ALCcontext*)((intptr_t)contextaddress); - ALCenum result; return alcMakeContextCurrent(context); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:58:15
|
Revision: 2792 http://svn.sourceforge.net/java-game-lib/?rev=2792&view=rev Author: matzon Date: 2007-04-19 15:58:13 -0700 (Thu, 19 Apr 2007) Log Message: ----------- removing ALC Removed Paths: ------------- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC.c Deleted: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC.c 2007-04-19 22:54:25 UTC (rev 2791) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC.c 2007-04-19 22:58:13 UTC (rev 2792) @@ -1,423 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * This is the actual JNI implementation of the OpenAL context/device library. - * - * @author Brian Matzon <br...@ma...> - * @version $Revision$ - */ - -/* OpenAL includes */ -#include "extal.h" - -//alc -typedef ALCubyte* (ALCAPIENTRY *alcGetStringPROC)(ALCdevice *device,ALCenum param); -typedef ALCvoid (ALCAPIENTRY *alcGetIntegervPROC)(ALCdevice *device,ALCenum param,ALCsizei size,ALCint *data); -typedef ALCdevice* (ALCAPIENTRY *alcOpenDevicePROC)(ALCubyte *deviceName); -typedef ALCvoid (ALCAPIENTRY *alcCloseDevicePROC)(ALCdevice *device); -typedef ALCcontext* (ALCAPIENTRY *alcCreateContextPROC)(ALCdevice *device,ALCint *attrList); -typedef ALCenum (ALCAPIENTRY *alcMakeContextCurrentPROC)(ALCcontext *context); -typedef ALCvoid (ALCAPIENTRY *alcProcessContextPROC)(ALCcontext *context); -typedef ALCdevice* (ALCAPIENTRY *alcGetContextsDevicePROC)(ALCcontext *context); -typedef ALCvoid (ALCAPIENTRY *alcSuspendContextPROC)(ALCcontext *context); -typedef ALCvoid (ALCAPIENTRY *alcDestroyContextPROC)(ALCcontext *context); -typedef ALCenum (ALCAPIENTRY *alcGetErrorPROC)(ALCdevice *device); -typedef ALCboolean (ALCAPIENTRY *alcIsExtensionPresentPROC)(ALCdevice *device,ALCubyte *extName); -//typedef ALCvoid* (ALCAPIENTRY *alcGetProcAddressPROC)(ALCdevice *device,ALCubyte *funcName); -typedef ALCenum (ALCAPIENTRY *alcGetEnumValuePROC)(ALCdevice *device,ALCubyte *enumName); -typedef ALCcontext* (ALCAPIENTRY *alcGetCurrentContextPROC)(ALCvoid); - -static alcGetCurrentContextPROC alcGetCurrentContext = NULL; -static alcGetStringPROC alcGetString; -static alcGetIntegervPROC alcGetIntegerv; -static alcOpenDevicePROC alcOpenDevice; -static alcCloseDevicePROC alcCloseDevice; -static alcCreateContextPROC alcCreateContext; -static alcMakeContextCurrentPROC alcMakeContextCurrent; -static alcProcessContextPROC alcProcessContext; -static alcGetContextsDevicePROC alcGetContextsDevice; -static alcSuspendContextPROC alcSuspendContext; -static alcDestroyContextPROC alcDestroyContext; -static alcGetErrorPROC alcGetError; -static alcIsExtensionPresentPROC alcIsExtensionPresent; -//static alcGetProcAddressPROC alcGetProcAddress; -static alcGetEnumValuePROC alcGetEnumValue; - -/** - * This function returns strings related to the context. - * - * C Specification: - * ALubyte * alcGetString(ALCdevice *device, ALenum token); - */ -static jstring JNICALL Java_org_lwjgl_openal_ALC_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) { - const char* alcString = (const char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token); - jstring string; - - if(alcString == NULL) { - return NULL; - } - - string = NewStringNative(env, alcString); - - return string; -} - -/** - * This function returns integers related to the context. - * - * C Specification: - * ALvoid alcGetIntegerv(ALCdevice *device, ALenum token, ALsizei size, ALint *dest); - */ -static void JNICALL Java_org_lwjgl_openal_ALC_nalcGetIntegerv (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token, jint size, jobject dest, jint offset) { - ALint* address = NULL; - if (dest != NULL) { - address = offset + (ALint*) (*env)->GetDirectBufferAddress(env, dest); - } - alcGetIntegerv((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token, (ALsizei) size, address); -} - -/** - * This function opens a device by name. - * - * C Specification: - * ALCdevice *alcOpenDevice( const ALubyte *tokstr ); - */ -static jobject JNICALL Java_org_lwjgl_openal_ALC_alcOpenDevice (JNIEnv *env, jclass clazz, jstring tokstr) { - char * tokenstring; - ALCdevice* device; - /* get ready to create ALCdevice instance */ - jobject alcDevice_object = NULL; - jclass alcDevice_class = NULL; - jmethodID alcDevice_method = NULL; - - if(tokstr != NULL) { - tokenstring = GetStringNativeChars(env, tokstr); - } else { - tokenstring = NULL; - } - - /* get device */ - device = alcOpenDevice((ALubyte *) tokenstring); - - /* if error - cleanup and get out */ - if(device == NULL) { - if(tokenstring != NULL) { - free(tokenstring); - } - return NULL; - } - - /* find class and constructor */ - alcDevice_class = (*env)->FindClass(env, "org/lwjgl/openal/ALCdevice"); - alcDevice_method = (*env)->GetMethodID(env, alcDevice_class, "<init>", "(J)V"); - - /* create instance */ - alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (jlong)((intptr_t)device)); - - /* clean up */ - if (tokenstring != NULL) - free(tokenstring); - - return alcDevice_object; -} - -/** - * This function closes a device by name. - * - * C Specification: - * void alcCloseDevice( ALCdevice *dev ); - */ -static void JNICALL Java_org_lwjgl_openal_ALC_alcCloseDevice (JNIEnv *env, jclass clazz, jlong deviceaddress) { - alcCloseDevice((ALCdevice*)((intptr_t)deviceaddress)); -} - -/** - * This function creates a context using a specified device. - * - * C Specification: - * ALCcontext* alcCreateContext( ALCdevice *dev, ALint* attrlist ); - */ -static jobject JNICALL Java_org_lwjgl_openal_ALC_nalcCreateContext (JNIEnv *env, jclass clazz, jlong deviceaddress, jobject attrlist) { - ALint* address = NULL; - ALCcontext* context; - /* get ready to create ALCcontext instance */ - jobject alcContext_object = NULL; - jclass alcContext_class = NULL; - jmethodID alcContext_method = NULL; - - if (attrlist != NULL) { - address = (ALint*) (*env)->GetDirectBufferAddress(env, attrlist); - } - context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address); - - /* if error - get out */ - if(context == NULL) { - return NULL; - } - - /* find class and constructor */ - alcContext_class = (*env)->FindClass(env, "org/lwjgl/openal/ALCcontext"); - alcContext_method = (*env)->GetMethodID(env, alcContext_class, "<init>", "(J)V"); - - /* create instance */ - alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, (jlong)((intptr_t)context)); - - return alcContext_object; -} - -/** - * This function makes a specified context the current context. - * - * C Specification: - * ALCboolean alcMakeContextCurrent(ALCcontext *context); - */ -static jint JNICALL Java_org_lwjgl_openal_ALC_alcMakeContextCurrent (JNIEnv *env, jclass clazz, jlong contextaddress) { - ALCcontext* context = (ALCcontext*)((intptr_t)contextaddress); - ALCenum result; - if(context == NULL) { - result = alcMakeContextCurrent(NULL); - } else { - result = alcMakeContextCurrent(context); - } - return result; -} - -/** - * This function tells a context to begin processing. - * - * C Specification: - * void alcProcessContext(ALCcontext *context); - */ -static void JNICALL Java_org_lwjgl_openal_ALC_nalcProcessContext (JNIEnv *env, jclass clazz, jlong contextaddress) { - alcProcessContext((ALCcontext*)((intptr_t)contextaddress)); -} - -/** - * This function retrieves the current context. - * - * C Specification: - * ALCcontext* alcGetCurrentContext( ALvoid ); - */ -static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetCurrentContext (JNIEnv *env, jclass clazz) { - ALCcontext* context = alcGetCurrentContext(); - - /* get ready to create ALCcontext instance */ - jobject alcContext_object = NULL; - jclass alcContext_class = NULL; - jmethodID alcContext_method = NULL; - - if(context == NULL) { - return NULL; - } - /* find class and constructor */ - alcContext_class = (*env)->FindClass(env, "org/lwjgl/openal/ALCcontext"); - alcContext_method = (*env)->GetMethodID(env, alcContext_class, "<init>", "(J)V"); - - /* create instance */ - alcContext_object = (*env)->NewObject(env, alcContext_class, alcContext_method, (jlong)((intptr_t)context)); - - return alcContext_object; -} - -/** - * This function retrieves the specified contexts device - * - * C Specification: - * ALCdevice* alcGetContextsDevice(ALCcontext *context); - */ -static jobject JNICALL Java_org_lwjgl_openal_ALC_alcGetContextsDevice (JNIEnv *env, jclass clazz, jlong contextaddress) { - ALCdevice* device = alcGetContextsDevice((ALCcontext*)((intptr_t)contextaddress)); - /* get ready to create ALCdevice instance */ - jobject alcDevice_object = NULL; - jclass alcDevice_class = NULL; - jmethodID alcDevice_method = NULL; - - if(device == NULL) { - return NULL; - } - - /* find class and constructor */ - alcDevice_class = (*env)->FindClass(env, "org/lwjgl/openal/ALCdevice"); - alcDevice_method = (*env)->GetMethodID(env, alcDevice_class, "<init>", "(J)V"); - - /* create instance */ - alcDevice_object = (*env)->NewObject(env, alcDevice_class, alcDevice_method, (jlong)((intptr_t)device)); - - return alcDevice_object; -} - -/** - * This function suspends processing on a specified context. - * - * C Specification: - * void alcSuspendContext(ALCcontext *context); - */ -static void JNICALL Java_org_lwjgl_openal_ALC_nalcSuspendContext (JNIEnv *env, jclass clazz, jlong contextaddress) { - alcSuspendContext((ALCcontext*)((intptr_t)contextaddress)); -} - -/** - * This function destroys a context. - * - * C Specification: - * void alcDestroyContext(ALCcontext *context); - */ -static void JNICALL Java_org_lwjgl_openal_ALC_alcDestroyContext (JNIEnv *env, jclass clazz, jlong contextaddress) { - alcDestroyContext((ALCcontext*)((intptr_t)contextaddress)); -} - -/** - * This function retrieves the specified devices context error state. - * - * C Specification: - * ALCenum alcGetError(ALCdevice *device); - */ -static jint JNICALL Java_org_lwjgl_openal_ALC_nalcGetError (JNIEnv *env, jclass clazz, jlong deviceaddress) { - jint result = alcGetError((ALCdevice*)((intptr_t)deviceaddress)); - return result; -} - -/** - * This function queries if a specified context extension is available. - * - * C Specification: - * ALboolean alcIsExtensionPresent(ALCdevice *device, ALubyte *extName); - */ -static jboolean JNICALL Java_org_lwjgl_openal_ALC_nalcIsExtensionPresent (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring extName) { - /* get extension */ - ALubyte* functionname = (ALubyte*) GetStringNativeChars(env, extName); - - jboolean result = (jboolean) alcIsExtensionPresent((ALCdevice*)((intptr_t)deviceaddress), functionname); - - free(functionname); - - return result; -} - -/** - * This function retrieves the enum value for a specified enumeration name. - * - * C Specification: - * ALenum alcGetEnumValue(ALCdevice *device, ALubyte *enumName); - */ -static jint JNICALL Java_org_lwjgl_openal_ALC_nalcGetEnumValue (JNIEnv *env, jclass clazz, jlong deviceaddress, jstring enumName) { - /* get extension */ - ALubyte* enumerationname = (ALubyte*) GetStringNativeChars(env, enumName); - - jint result = (jint) alcGetEnumValue((ALCdevice*)((intptr_t)deviceaddress), enumerationname); - - free(enumerationname); - - return result; -} - -JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_openal_ALC_ngetImplementations(JNIEnv *env, jclass clazz) { - jclass strcls; - jarray strarr = NULL; - jstring str; - - char *deviceList; - char *devices[12]; - int numDevices, i; - - // get device list - deviceList = (char *)alcGetString(NULL, 4100L); - - // build list - for (numDevices = 0; numDevices < 12; numDevices++) {devices[numDevices] = NULL;} - for (numDevices = 0; numDevices < 12; numDevices++) { - devices[numDevices] = deviceList; - deviceList += strlen(deviceList); - if (deviceList[0] == 0) { - if (deviceList[1] == 0) { - break; - } else { - deviceList += 1; - } - } - } - - // iterate found devices and add to java string array - if (devices[numDevices] != NULL) { - numDevices++; - strcls = (*env)->FindClass(env, "java/lang/String"); - strarr = (*env)->NewObjectArray(env, numDevices+1, strcls, 0); - - // add default - str = NewStringNative(env, "NULL Device (Default)"); - (*env)->SetObjectArrayElement(env, strarr, 0, str); - (*env)->DeleteLocalRef(env, str); - - for (i = 0; i < numDevices; i++) { - str = NewStringNative(env, devices[i]); - (*env)->SetObjectArrayElement(env, strarr, i+1, str); - (*env)->DeleteLocalRef(env, str); - } - - } - return strarr; -} - -/** - * Loads the context OpenAL functions - * - * @return true if all methods were loaded, false if one of the methods could not be loaded - */ -#ifdef __cplusplus -extern "C" { -#endif -JNIEXPORT void JNICALL Java_org_lwjgl_openal_ALC_initNativeStubs(JNIEnv *env, jclass clazz) { - JavaMethodAndExtFunction functions[] = { - {"nalcGetString", "(JI)Ljava/lang/String;", (void*)&Java_org_lwjgl_openal_ALC_nalcGetString, "alcGetString", (void*)&alcGetString}, - {"nalcGetIntegerv", "(JIILjava/nio/Buffer;I)V", (void*)&Java_org_lwjgl_openal_ALC_nalcGetIntegerv, "alcGetIntegerv", (void*)&alcGetIntegerv}, - {"alcOpenDevice", "(Ljava/lang/String;)Lorg/lwjgl/openal/ALCdevice;", (void*)&Java_org_lwjgl_openal_ALC_alcOpenDevice, "alcOpenDevice", (void*)&alcOpenDevice}, - {"alcCloseDevice", "(J)V", (void*)&Java_org_lwjgl_openal_ALC_alcCloseDevice, "alcCloseDevice", (void*)&alcCloseDevice}, - {"nalcCreateContext", "(JLjava/nio/IntBuffer;)Lorg/lwjgl/openal/ALCcontext;", (void*)&Java_org_lwjgl_openal_ALC_nalcCreateContext, "alcCreateContext", (void*)&alcCreateContext}, - {"alcMakeContextCurrent", "(J)I", (void*)&Java_org_lwjgl_openal_ALC_alcMakeContextCurrent, "alcMakeContextCurrent", (void*)&alcMakeContextCurrent}, - {"nalcProcessContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC_nalcProcessContext, "alcProcessContext", (void*)&alcProcessContext}, - {"alcGetCurrentContext", "()Lorg/lwjgl/openal/ALCcontext;", (void*)&Java_org_lwjgl_openal_ALC_alcGetCurrentContext, "alcGetCurrentContext", (void*)&alcGetCurrentContext}, - {"alcGetContextsDevice", "(J)Lorg/lwjgl/openal/ALCdevice;", (void*)&Java_org_lwjgl_openal_ALC_alcGetContextsDevice, "alcGetContextsDevice", (void*)&alcGetContextsDevice}, - {"nalcSuspendContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC_nalcSuspendContext, "alcSuspendContext", (void*)&alcSuspendContext}, - {"alcDestroyContext", "(J)V", (void*)&Java_org_lwjgl_openal_ALC_alcDestroyContext, "alcDestroyContext", (void*)&alcDestroyContext}, - {"nalcGetError", "(J)I", (void*)&Java_org_lwjgl_openal_ALC_nalcGetError, "alcGetError", (void*)&alcGetError}, - {"nalcIsExtensionPresent", "(JLjava/lang/String;)Z", (void*)&Java_org_lwjgl_openal_ALC_nalcIsExtensionPresent, "alcIsExtensionPresent", (void*)&alcIsExtensionPresent}, - {"nalcGetEnumValue", "(JLjava/lang/String;)I", (void*)&Java_org_lwjgl_openal_ALC_nalcGetEnumValue, "alcGetEnumValue", (void*)&alcGetEnumValue} - }; - int num_functions = NUMFUNCTIONS(functions); - extal_InitializeClass(env, clazz, num_functions, functions); -} -#ifdef __cplusplus -} -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:54:27
|
Revision: 2791 http://svn.sourceforge.net/java-game-lib/?rev=2791&view=rev Author: matzon Date: 2007-04-19 15:54:25 -0700 (Thu, 19 Apr 2007) Log Message: ----------- re-enabled missing ALC error check Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2007-04-19 22:53:32 UTC (rev 2790) +++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java 2007-04-19 22:54:25 UTC (rev 2791) @@ -158,7 +158,7 @@ public static String alcGetString(ALCdevice device, int pname) { String result; result = nalcGetString(getDevice(device), pname); - //Util.checkALCError(); + Util.checkALCError(); return result; } private native static String nalcGetString(long device, int pname); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:53:34
|
Revision: 2790 http://svn.sourceforge.net/java-game-lib/?rev=2790&view=rev Author: matzon Date: 2007-04-19 15:53:32 -0700 (Thu, 19 Apr 2007) Log Message: ----------- removed ALC from javah added AL11 to generate-openal Modified Paths: -------------- trunk/LWJGL/build.xml Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2007-04-19 22:49:49 UTC (rev 2789) +++ trunk/LWJGL/build.xml 2007-04-19 22:53:32 UTC (rev 2790) @@ -596,7 +596,6 @@ <class name="org.lwjgl.input.Keyboard" /> <class name="org.lwjgl.input.Mouse" /> - <class name="org.lwjgl.openal.ALC" /> <class name="org.lwjgl.openal.AL" /> <class name="org.lwjgl.opengl.GLContext" /> @@ -648,7 +647,7 @@ <arg path="${lwjgl.src.native}/generated"/> <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/> <arg value="-Ageneratechecks"/> - <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java"/> + <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java"/> </apply> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:49:51
|
Revision: 2789 http://svn.sourceforge.net/java-game-lib/?rev=2789&view=rev Author: matzon Date: 2007-04-19 15:49:49 -0700 (Thu, 19 Apr 2007) Log Message: ----------- removed some null checks Modified Paths: -------------- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c Modified: trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2007-04-19 22:44:07 UTC (rev 2788) +++ trunk/LWJGL/src/native/common/org_lwjgl_openal_ALC10.c 2007-04-19 22:49:49 UTC (rev 2789) @@ -179,11 +179,6 @@ } context = alcCreateContext((ALCdevice*)((intptr_t)deviceaddress), address); - /* if error - get out */ - if(context == NULL) { - return (jlong) NULL; - } - return (jlong)((intptr_t)context); } @@ -196,12 +191,7 @@ static jint JNICALL Java_org_lwjgl_openal_ALC10_nalcMakeContextCurrent (JNIEnv *env, jclass clazz, jlong contextaddress) { ALCcontext* context = (ALCcontext*)((intptr_t)contextaddress); ALCenum result; - if(context == NULL) { - result = alcMakeContextCurrent(NULL); - } else { - result = alcMakeContextCurrent(context); - } - return result; + return alcMakeContextCurrent(context); } /** @@ -222,10 +212,6 @@ */ static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcGetCurrentContext (JNIEnv *env, jclass clazz) { ALCcontext* context = alcGetCurrentContext(); - - if(context == NULL) { - return (jlong) NULL; - } return (jlong)((intptr_t)context); } @@ -237,11 +223,6 @@ */ static jlong JNICALL Java_org_lwjgl_openal_ALC10_nalcGetContextsDevice (JNIEnv *env, jclass clazz, jlong contextaddress) { ALCdevice* device = alcGetContextsDevice((ALCcontext*)((intptr_t)contextaddress)); - - if(device == NULL) { - return (jlong) NULL; - } - return (jlong)((intptr_t)device); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:44:09
|
Revision: 2788 http://svn.sourceforge.net/java-game-lib/?rev=2788&view=rev Author: matzon Date: 2007-04-19 15:44:07 -0700 (Thu, 19 Apr 2007) Log Message: ----------- output capture devices Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/test/openal/ALCCaptureTest.java Modified: trunk/LWJGL/src/java/org/lwjgl/test/openal/ALCCaptureTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/openal/ALCCaptureTest.java 2007-04-19 22:43:38 UTC (rev 2787) +++ trunk/LWJGL/src/java/org/lwjgl/test/openal/ALCCaptureTest.java 2007-04-19 22:44:07 UTC (rev 2788) @@ -80,16 +80,16 @@ } // get list of devices - String captureDevices = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER); - System.out.println("captureDevices: " + captureDevices); - + String[] captureDevices = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER).split("\0"); + System.out.println("Available Capture Devices: "); + for(int i=0; i<captureDevices.length; i++) { + System.out.println(i + ": " + captureDevices[i]); + } String defaultRecorder = ALC10.alcGetString(AL.getDevice(), ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); System.out.println("Default capture device: " + defaultRecorder); ALCdevice device = ALC11.alcCaptureOpenDevice(null, FREQ, FMT, SAMPS); - - if(device != null) { // record some sound This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:43:40
|
Revision: 2787 http://svn.sourceforge.net/java-game-lib/?rev=2787&view=rev Author: matzon Date: 2007-04-19 15:43:38 -0700 (Thu, 19 Apr 2007) Log Message: ----------- remove debug Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java Modified: trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2007-04-19 22:39:08 UTC (rev 2786) +++ trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java 2007-04-19 22:43:38 UTC (rev 2787) @@ -83,7 +83,6 @@ public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) { long device = nalcCaptureOpenDevice(devicename, frequency, format, buffersize); if(device > 0) { - System.out.println("new device: " + device + "/" + devicename); return new ALCdevice(device); } return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-04-19 22:39:10
|
Revision: 2786 http://svn.sourceforge.net/java-game-lib/?rev=2786&view=rev Author: matzon Date: 2007-04-19 15:39:08 -0700 (Thu, 19 Apr 2007) Log Message: ----------- using NewStringNativeWithLength Modified Paths: -------------- trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILU.c trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILUT.c trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMusic.c trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FSound.c Modified: trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c =================================================================== --- trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c 2007-04-19 22:26:19 UTC (rev 2785) +++ trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_IL.c 2007-04-19 22:39:08 UTC (rev 2786) @@ -517,7 +517,8 @@ * Signature: (I)Ljava/lang/String; */ static jstring JNICALL Java_org_lwjgl_devil_IL_ilGetString(JNIEnv *env, jclass clazz, jint stringName) { - return NewStringNative(env, ilGetString((ILenum)stringName)); + char * name = ilGetString((ILenum)stringName); + return NewStringNativeWithLength(env, name, strlen(name)); } /* Modified: trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILU.c =================================================================== --- trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILU.c 2007-04-19 22:26:19 UTC (rev 2785) +++ trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILU.c 2007-04-19 22:39:08 UTC (rev 2786) @@ -245,7 +245,8 @@ * Signature: (I)Ljava/lang/String; */ static jstring JNICALL Java_org_lwjgl_devil_ILU_iluErrorString(JNIEnv *env, jclass clazz, jint error) { - return NewStringNative(env, iluErrorString((ILenum)error)); + char * errorstring = iluErrorString((ILenum)error); + return NewStringNativeWithLength(env, errorstring, strlen(errorstring)); } /* @@ -366,7 +367,8 @@ * Signature: (I)Ljava/lang/String; */ static jstring JNICALL Java_org_lwjgl_devil_ILU_iluGetString(JNIEnv *env, jclass clazz, jint stringName) { - return NewStringNative(env, iluGetString((ILenum)stringName)); + char * name = iluGetString((ILenum)stringName); + return NewStringNativeWithLength(env, name, strlen(name)); } /* Modified: trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILUT.c =================================================================== --- trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILUT.c 2007-04-19 22:26:19 UTC (rev 2785) +++ trunk/LWJGL/src/native/common/devil/org_lwjgl_devil_ILUT.c 2007-04-19 22:39:08 UTC (rev 2786) @@ -120,7 +120,8 @@ * Signature: (I)Ljava/lang/String; */ static jstring JNICALL Java_org_lwjgl_devil_ILUT_ilutGetString(JNIEnv *env, jclass clazz, jint stringName){ - return NewStringNative(env, ilutGetString((ILenum)stringName)); + char * name = ilutGetString((ILenum)stringName); + return NewStringNativeWithLength(env, name, strlen(name)); } /* Modified: trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c =================================================================== --- trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c 2007-04-19 22:26:19 UTC (rev 2785) +++ trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c 2007-04-19 22:39:08 UTC (rev 2786) @@ -82,5 +82,6 @@ * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_lwjgl_fmod3_FMOD_FMOD_1ErrorString(JNIEnv *env, jclass clazz, jint errorcode) { - return NewStringNative(env, FMOD_ErrorString(errorcode)); + char * error = FMOD_ErrorString(errorcode); + return NewStringNativeWithLength(env, error, strlen(error)); } Modified: trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMusic.c =================================================================== --- trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMusic.c 2007-04-19 22:26:19 UTC (rev 2785) +++ trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMusic.c 2007-04-19 22:39:08 UTC (rev 2786) @@ -281,7 +281,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_fmod3_FMusic_nFMUSIC_1GetName (JNIEnv *env, jclass clazz, jlong module) { const char * name = fmod_instance->FMUSIC_GetName((FMUSIC_MODULE *) module); - return NewStringNative(env, name); + return NewStringNativeWithLength(env, name, strlen(name)); } /* Modified: trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FSound.c =================================================================== --- trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FSound.c 2007-04-19 22:26:19 UTC (rev 2785) +++ trunk/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FSound.c 2007-04-19 22:39:08 UTC (rev 2786) @@ -230,7 +230,8 @@ * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_lwjgl_fmod3_FSound_FSOUND_1GetDriverName(JNIEnv * env, jclass clazz, jint id) { - return NewStringNative(env, (const char *) fmod_instance->FSOUND_GetDriverName(id)); + char * driver = fmod_instance->FSOUND_GetDriverName(id); + return NewStringNativeWithLength(env, driver, strlen(driver)); } /* @@ -430,7 +431,8 @@ * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_lwjgl_fmod3_FSound_nFSOUND_1Sample_1GetName(JNIEnv * env, jclass clazz, jlong sptr) { - return NewStringNative(env, fmod_instance->FSOUND_Sample_GetName((FSOUND_SAMPLE *) sptr)); + char * name = fmod_instance->FSOUND_Sample_GetName((FSOUND_SAMPLE *) sptr); + return NewStringNativeWithLength(env, name, strlen(name)); } /* @@ -1203,7 +1205,7 @@ unsigned int * nPcmOffset = pcmOffsetPosition + (unsigned int *) (*env)->GetDirectBufferAddress(env, pcmOffset); char * result = fmod_instance->FSOUND_Stream_GetSyncPointInfo(nPoint, nPcmOffset); if(result != NULL) { - return NewStringNative(env, result); + return NewStringNativeWithLength(env, result, strlen(result)); } return NULL; } @@ -1221,7 +1223,7 @@ if(fmod_instance->FSOUND_Stream_GetTagField((FSOUND_STREAM*) stream, num, &type, &name, &value, &length)) { // create string instance of name - jstring nName = NewStringNative(env, name); + jstring nName = NewStringNativeWithLength(env, name, strlen(name)); // get set method and call it jclass cls = (*env)->GetObjectClass(env, tagField); @@ -1257,7 +1259,8 @@ * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_lwjgl_fmod3_FSound_FSOUND_1Stream_1Net_1GetLastServerStatus(JNIEnv * env, jclass clazz) { - return NewStringNative(env, fmod_instance->FSOUND_Stream_Net_GetLastServerStatus()); + char * serverstatus = fmod_instance->FSOUND_Stream_Net_GetLastServerStatus(); + return NewStringNativeWithLength(env, serverstatus, strlen(serverstatus)); } /* @@ -1777,7 +1780,8 @@ * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_lwjgl_fmod3_FSound_FSOUND_1Record_1GetDriverName(JNIEnv * env, jclass clazz, jint driver) { - return NewStringNative(env, (const char *)fmod_instance->FSOUND_Record_GetDriverName(driver)); + char * drivername = fmod_instance->FSOUND_Record_GetDriverName(driver); + return NewStringNativeWithLength(env, drivername, strlen(drivername)); } /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |