You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
|
2
|
3
(5) |
4
|
|
5
(1) |
6
(16) |
7
(3) |
8
(3) |
9
(4) |
10
(13) |
11
(5) |
|
12
(1) |
13
(1) |
14
|
15
(7) |
16
(4) |
17
(1) |
18
(1) |
|
19
(3) |
20
|
21
(1) |
22
(16) |
23
|
24
(2) |
25
|
|
26
(1) |
27
(4) |
28
(6) |
29
(3) |
30
(1) |
|
|
|
From: Elias N. <eli...@us...> - 2004-09-22 17:54:40
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27053/src/native/win32 Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Fix native mouse issues Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- org_lwjgl_input_Mouse.cpp 22 Sep 2004 15:06:27 -0000 1.62 +++ org_lwjgl_input_Mouse.cpp 22 Sep 2004 17:54:27 -0000 1.63 @@ -58,10 +58,10 @@ static bool mouse_grabbed; static int mouseMask = DISCL_NONEXCLUSIVE | DISCL_FOREGROUND; -/* These deltas track the cursor position from Windows messages */ -static int dx; -static int dy; -static int dwheel; +/* These accumulated deltas track the cursor position from Windows messages */ +static int accum_dx; +static int accum_dy; +static int accum_dwheel; static int last_x; static int last_y; @@ -82,7 +82,7 @@ putEventElement(&event_queue, button); putEventElement(&event_queue, state); putEventElement(&event_queue, dx); - putEventElement(&event_queue, dy); + putEventElement(&event_queue, -dy); putEventElement(&event_queue, dz); } } @@ -93,6 +93,7 @@ GetClientRect(getCurrentHWND(), &clientRect); last_x = (clientRect.left + clientRect.right)/2; last_y = clientRect.bottom - 1 - (clientRect.bottom - clientRect.top)/2; + accum_dx = accum_dy = 0; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { @@ -111,7 +112,7 @@ initEventQueue(&event_queue); - last_x = last_y = dx = dy = dwheel = 0; + last_x = last_y = accum_dx = accum_dy = accum_dwheel = 0; buffer_enabled = false; // Create input @@ -154,16 +155,16 @@ } void handleMouseScrolled(int event_dwheel) { - dwheel += event_dwheel; + accum_dwheel += event_dwheel; putEvent(-1, 0, 0, 0, event_dwheel); } void handleMouseMoved(int x, int y) { int event_dx = x - last_x; int event_dy = y - last_y; - dx += event_dx; - dy += event_dy; - putEvent(-1, 0, event_dx, -event_dy, 0); + accum_dx += event_dx; + accum_dy += event_dy; + putEvent(-1, 0, event_dx, event_dy, 0); last_x = x; last_y = y; } @@ -206,7 +207,7 @@ } } if (dx != 0 || dy != 0 || dwheel != 0) - putEvent(-1, 0, dx, -dy, dwheel); + putEvent(-1, 0, dx, dy, dwheel); } static void readDXBuffer() @@ -435,27 +436,6 @@ return val; } -/*static void getGDICursorDelta(int* return_dx, int* return_dy) { - - int dx; - int dy; - - POINT newCursorPos; - RECT clientRect; - GetCursorPos(&newCursorPos); - ScreenToClient(getCurrentHWND(), &newCursorPos); - GetClientRect(getCurrentHWND(), &clientRect); - // Clip the position to the client rect - newCursorPos.x = cap(newCursorPos.x, clientRect.left, clientRect.right - 1); - newCursorPos.y = cap(newCursorPos.y, clientRect.top, clientRect.bottom - 1); - dx = newCursorPos.x - cursorPos.x; - dy = newCursorPos.y - cursorPos.y; - cursorPos.x += dx; - cursorPos.y += dy; - *return_dx = dx; - *return_dy = dy; -} -*/ /** * Updates the fields on the Mouse */ @@ -498,10 +478,10 @@ coords[1] = -diMouseState.lY; coords[2] = diMouseState.lZ; } else { - coords[0] = dx; - coords[1] = -dy; - coords[2] = dwheel; - dx = dy = dwheel = 0; + coords[0] = accum_dx; + coords[1] = -accum_dy; + coords[2] = accum_dwheel; + accum_dx = accum_dy = accum_dwheel = 0; } for (int i = 0; i < mButtoncount; i++) { |
|
From: Elias N. <eli...@us...> - 2004-09-22 17:54:37
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27053/src/native/linux Modified Files: org_lwjgl_input_Mouse.c Log Message: Fix native mouse issues Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_input_Mouse.c 22 Sep 2004 15:06:26 -0000 1.10 +++ org_lwjgl_input_Mouse.c 22 Sep 2004 17:54:26 -0000 1.11 @@ -60,9 +60,9 @@ static bool pointer_grabbed; static bool created; -static int dx; -static int dy; -static int dz; +static int accum_dx; +static int accum_dy; +static int accum_dz; static int last_x; static int last_y; static jbyte buttons[NUM_BUTTONS]; @@ -77,7 +77,7 @@ putEventElement(&event_queue, button); putEventElement(&event_queue, state); putEventElement(&event_queue, dx); - putEventElement(&event_queue, dy); + putEventElement(&event_queue, -dy); putEventElement(&event_queue, dz); } } @@ -85,11 +85,11 @@ static void setCursorPos(int x, int y) { jint event_dx = x - last_x; jint event_dy = y - last_y; - dx += event_dx; - dy += event_dy; + accum_dx += event_dx; + accum_dy += event_dy; last_x = x; last_y = y; - putEvent(-1, 0, event_dx, -event_dy, 0); + putEvent(-1, 0, event_dx, event_dy, 0); } static int transformY(int y) { @@ -242,7 +242,7 @@ if (disp == NULL) return; int i; - last_y = last_x = dx = dy = dz = 0; + last_y = last_x = accum_dx = accum_dy = accum_dz = 0; for (i = 0; i < NUM_BUTTONS; i++) buttons[i] = 0; if (!blankCursor()) { @@ -357,12 +357,10 @@ printfDebug("ERROR: Not enough space in coords array: %d < 3\n", coords_length); return; } - coords[0] = dx; - coords[1] = -dy; - coords[2] = dz; - dx = 0; - dy = 0; - dz = 0; + coords[0] = accum_dx; + coords[1] = -accum_dy; + coords[2] = accum_dz; + accum_dx = accum_dy = accum_dz = 0; int num_buttons = NUM_BUTTONS; if (num_buttons > buttons_length) num_buttons = buttons_length; @@ -385,4 +383,5 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nGrabMouse(JNIEnv * env, jclass clazz, jboolean new_grab) { setGrab(new_grab == JNI_TRUE ? true : false); resetCursor(getWindowWidth()/2, transformY(getWindowHeight()/2)); + accum_dx = accum_dy = 0; } |
|
From: Elias N. <eli...@us...> - 2004-09-22 15:06:37
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22065/src/native/win32 Modified Files: Window.h org_lwjgl_Sys.cpp org_lwjgl_input_Controller.cpp org_lwjgl_input_Cursor.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Display.cpp Log Message: Updated win32 to report Mouse deltas Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- org_lwjgl_opengl_Display.cpp 15 Sep 2004 17:07:06 -0000 1.24 +++ org_lwjgl_opengl_Display.cpp 22 Sep 2004 15:06:27 -0000 1.25 @@ -41,6 +41,7 @@ #define _PRIVATE_WINDOW_H_ #include "Window.h" +#include <windowsx.h> #include "extgl_wgl.h" #include "common_tools.h" #include "extgl_wgl.h" @@ -322,6 +323,49 @@ } } break; + case WM_MOUSEMOVE: + { + int xPos = GET_X_LPARAM(lParam); + int yPos = GET_Y_LPARAM(lParam); + handleMouseMoved(xPos, yPos); + return 0; + } + case WM_MOUSEWHEEL: + { + int dwheel = GET_WHEEL_DELTA_WPARAM(wParam); + handleMouseScrolled(dwheel); + return 0; + } + case WM_LBUTTONDOWN: + { + handleMouseButton(0, 1); + return 0; + } + case WM_LBUTTONUP: + { + handleMouseButton(0, 0); + return 0; + } + case WM_RBUTTONDOWN: + { + handleMouseButton(1, 1); + return 0; + } + case WM_RBUTTONUP: + { + handleMouseButton(1, 0); + return 0; + } + case WM_MBUTTONDOWN: + { + handleMouseButton(2, 1); + return 0; + } + case WM_MBUTTONUP: + { + handleMouseButton(2, 0); + return 0; + } case WM_ACTIVATE: { switch(LOWORD(wParam)) { @@ -398,7 +442,7 @@ /* * Handle native Win32 messages */ -static void handleMessages(JNIEnv * env, jclass clazz) +void handleMessages(void) { /* * Now's our chance to deal with Windows messages that are @@ -496,7 +540,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nUpdate (JNIEnv * env, jclass clazz) { - handleMessages(env, clazz); + handleMessages(); } Index: org_lwjgl_input_Controller.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- org_lwjgl_input_Controller.cpp 26 Jul 2004 17:01:55 -0000 1.24 +++ org_lwjgl_input_Controller.cpp 22 Sep 2004 15:06:27 -0000 1.25 @@ -40,13 +40,11 @@ */ -#define WIN32_LEAN_AND_MEAN -#include "org_lwjgl_input_Controller.h" -#include <windows.h> #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0500 -#include <dinput.h> #include "Window.h" +#include "org_lwjgl_input_Controller.h" +#include <dinput.h> #include "common_tools.h" #define CONTROLLER_AXISMAX 1000 // Maxmimum range to which we'll gauge the swing Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Window.h 15 Sep 2004 17:07:06 -0000 1.18 +++ Window.h 22 Sep 2004 15:06:27 -0000 1.19 @@ -43,6 +43,11 @@ #define _LWJGL_WINDOW_H_INCLUDED_ #define WIN32_LEAN_AND_MEAN + #define _WIN32_WINDOWS 0x0410 + #define WINVER 0x0410 + #define _WIN32_WINNT 0x0400 + + #include <windows.h> #include <jni.h> #include "extgl.h" @@ -66,6 +71,14 @@ WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc); + WINDOW_H_API void handleMouseMoved(int x, int y); + + WINDOW_H_API void handleMouseScrolled(int dwheel); + + WINDOW_H_API void handleMouseButton(int button, int state); + + WINDOW_H_API void handleMessages(void); + /* * Find a suitable pixel format */ Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- org_lwjgl_input_Mouse.cpp 26 Jul 2004 18:59:40 -0000 1.61 +++ org_lwjgl_input_Mouse.cpp 22 Sep 2004 15:06:27 -0000 1.62 @@ -39,14 +39,12 @@ * @version $Revision$ */ -#define WIN32_LEAN_AND_MEAN -#include "org_lwjgl_input_Mouse.h" -#include <windows.h> #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0300 -#include <dinput.h> #include "Window.h" +#include <dinput.h> #include "common_tools.h" +#include "org_lwjgl_input_Mouse.h" extern HINSTANCE dll_handle; // Handle to the LWJGL dll static LPDIRECTINPUT lpdi = NULL; // DirectInput @@ -57,10 +55,19 @@ static bool mCreate_success; // bool used to determine successfull creation static bool mFirstTimeInitialization = true; // boolean to determine first time initialization -static POINT cursorPos; static bool mouse_grabbed; static int mouseMask = DISCL_NONEXCLUSIVE | DISCL_FOREGROUND; +/* These deltas track the cursor position from Windows messages */ +static int dx; +static int dy; +static int dwheel; +static int last_x; +static int last_y; + +static event_queue_t event_queue; +static bool buffer_enabled; + // Function prototypes (defined in the cpp file, since header file is generic across platforms void EnumerateMouseCapabilities(); BOOL CALLBACK EnumMouseObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef); @@ -70,12 +77,22 @@ void InitializeMouseFields(); void UpdateMouseFields(JNIEnv *env, jclass clsMouse, jobject coord_buffer_obj, jobject button_buffer_obj); +static void putEvent(jint button, jint state, jint dx, jint dy, jint dz) { + if (buffer_enabled) { + putEventElement(&event_queue, button); + putEventElement(&event_queue, state); + putEventElement(&event_queue, dx); + putEventElement(&event_queue, dy); + putEventElement(&event_queue, dz); + } +} + static void resetCursorPos(void) { /* Reset cursor position to middle of the window */ RECT clientRect; GetClientRect(getCurrentHWND(), &clientRect); - cursorPos.x = (clientRect.left + clientRect.right)/2; - cursorPos.y = clientRect.bottom - 1 - (clientRect.bottom - clientRect.top)/2; + last_x = (clientRect.left + clientRect.right)/2; + last_y = clientRect.bottom - 1 - (clientRect.bottom - clientRect.top)/2; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { @@ -92,6 +109,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv *env, jclass clazz) { HRESULT hr; + initEventQueue(&event_queue); + + last_x = last_y = dx = dy = dwheel = 0; + buffer_enabled = false; + // Create input HRESULT ret = DirectInputCreate(dll_handle, DIRECTINPUT_VERSION, &lpdi, NULL); if (ret != DI_OK && ret != DIERR_BETADIRECTINPUTVERSION) { @@ -128,51 +150,76 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer(JNIEnv * env, jclass clazz) { + buffer_enabled = true; } -static unsigned char mapButton(DWORD button_id) { - switch (button_id) { - case DIMOFS_BUTTON0: return 0; - case DIMOFS_BUTTON1: return 1; - case DIMOFS_BUTTON2: return 2; - case DIMOFS_BUTTON3: return 3; -/* case DIMOFS_BUTTON4: return 4; - case DIMOFS_BUTTON5: return 5; - case DIMOFS_BUTTON6: return 6; - case DIMOFS_BUTTON7: return 7;*/ - default: return mButtoncount; - } +void handleMouseScrolled(int event_dwheel) { + dwheel += event_dwheel; + putEvent(-1, 0, 0, 0, event_dwheel); } -static int bufferButtons(int num_di_events, DIDEVICEOBJECTDATA *di_buffer, unsigned char *buffer, int buffer_size) { +void handleMouseMoved(int x, int y) { + int event_dx = x - last_x; + int event_dy = y - last_y; + dx += event_dx; + dy += event_dy; + putEvent(-1, 0, event_dx, -event_dy, 0); + last_x = x; + last_y = y; +} + +void handleMouseButton(int button, int state) { + putEvent(button, state, 0, 0, 0); +} + +static void copyDXEvents(int num_di_events, DIDEVICEOBJECTDATA *di_buffer) { int buffer_index = 0; + int dx = 0, dy = 0, dwheel = 0; for (int i = 0; i < num_di_events; i++) { - unsigned char button = mapButton(di_buffer[i].dwOfs); - if (button >= 0 && button < mButtoncount) { - unsigned char state = (unsigned char)di_buffer[i].dwData & 0x80; - if (state != 0) - state = 1; - if (buffer_index == buffer_size) + int button_state = (di_buffer[i].dwData & 0x80) != 0 ? 1 : 0; + switch (di_buffer[i].dwOfs) { + case DIMOFS_BUTTON0: + putEvent(0, button_state, dx, dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON1: + putEvent(1, button_state, dx, dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON2: + putEvent(2, button_state, dx, dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_BUTTON3: + putEvent(3, button_state, dx, dy, dwheel); + dx = dy = dwheel = 0; + break; + case DIMOFS_X: + dx += di_buffer[i].dwData; + break; + case DIMOFS_Y: + dy += di_buffer[i].dwData; + break; + case DIMOFS_Z: + dwheel += di_buffer[i].dwData; break; - buffer[buffer_index++] = button; - buffer[buffer_index++] = state; } } - return buffer_index/2; + if (dx != 0 || dy != 0 || dwheel != 0) + putEvent(-1, 0, dx, -dy, dwheel); } -JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead - (JNIEnv * env, jclass clazz, jobject buffer_obj, jint buffer_position) +static void readDXBuffer() { - static DIDEVICEOBJECTDATA rgdod[EVENT_BUFFER_SIZE]; + DIDEVICEOBJECTDATA rgdod[EVENT_BUFFER_SIZE]; DWORD num_di_events = EVENT_BUFFER_SIZE; HRESULT ret; ret = mDIDevice->Acquire(); if (ret != DI_OK && ret != S_FALSE) - return 0; + return; ret = mDIDevice->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), @@ -181,9 +228,7 @@ 0); if (ret == DI_OK) { - unsigned char *buffer_ptr = buffer_position + (unsigned char*)env->GetDirectBufferAddress(buffer_obj); - int buffer_size = (int)env->GetDirectBufferCapacity(buffer_obj) - buffer_position; - return bufferButtons(num_di_events, rgdod, buffer_ptr, buffer_size); + copyDXEvents(num_di_events, rgdod); } else if (ret == DI_BUFFEROVERFLOW) { printfDebug("Buffer overflowed\n"); } else if (ret == DIERR_INPUTLOST) { @@ -199,7 +244,19 @@ } else { printfDebug("unknown keyboard error\n"); } - return 0; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead + (JNIEnv * env, jclass clazz, jobject buffer_obj, jint buffer_position) +{ + jint* buffer_ptr = (jint *)env->GetDirectBufferAddress(buffer_obj) + buffer_position; + int buffer_size = (env->GetDirectBufferCapacity(buffer_obj))/sizeof(jint) - buffer_position; + if (mouse_grabbed) { + readDXBuffer(); + } else { + handleMessages(); + } + return copyEvents(&event_queue, buffer_ptr, buffer_size, 5); } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps @@ -378,7 +435,8 @@ return val; } -static void getGDICursorDelta(int* return_dx, int* return_dy) { +/*static void getGDICursorDelta(int* return_dx, int* return_dy) { + int dx; int dy; @@ -397,14 +455,15 @@ *return_dx = dx; *return_dy = dy; } - +*/ /** * Updates the fields on the Mouse */ static void UpdateMouseFields(JNIEnv *env, jclass clsMouse, jobject coord_buffer_obj, jobject button_buffer_obj) { HRESULT hRes; DIMOUSESTATE diMouseState; // State of Mouse - int dx, dy; + + handleMessages(); int *coords = (int *)env->GetDirectBufferAddress(coord_buffer_obj); int coords_length = (int)env->GetDirectBufferCapacity(coord_buffer_obj); @@ -435,17 +494,16 @@ } if (mouse_grabbed) { - dx = diMouseState.lX; - dy = diMouseState.lY; + coords[0] = diMouseState.lX; + coords[1] = -diMouseState.lY; + coords[2] = diMouseState.lZ; } else { - getGDICursorDelta(&dx, &dy); + coords[0] = dx; + coords[1] = -dy; + coords[2] = dwheel; + dx = dy = dwheel = 0; } - dy = -dy; - coords[0] = dx; - coords[1] = dy; - coords[2] = diMouseState.lZ; - for (int i = 0; i < mButtoncount; i++) { if (diMouseState.rgbButtons[i] != 0) { diMouseState.rgbButtons[i] = JNI_TRUE; Index: org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- org_lwjgl_input_Keyboard.cpp 26 Jul 2004 17:01:56 -0000 1.35 +++ org_lwjgl_input_Keyboard.cpp 22 Sep 2004 15:06:27 -0000 1.36 @@ -39,13 +39,11 @@ * @version $Revision$ */ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> #undef DIRECTINPUT_VERSION #define DIRECTINPUT_VERSION 0x0300 +#include "Window.h" #include <dinput.h> #include "org_lwjgl_input_Keyboard.h" -#include "Window.h" #include "common_tools.h" @@ -199,10 +197,10 @@ 0); if (ret == DI_OK) { - unsigned char * buf = buffer_position + (unsigned char *)env->GetDirectBufferAddress(buffer_obj); - int buffer_size = (int)env->GetDirectBufferCapacity(buffer_obj) - buffer_position; + jint * buf = buffer_position + (jint *)env->GetDirectBufferAddress(buffer_obj); + int buffer_size = ((int)env->GetDirectBufferCapacity(buffer_obj))/sizeof(jint) - buffer_position; int index = 0; - int event_size = translationEnabled ? 4 : 2; + int event_size = 3; DWORD current_di_event = 0; while (index + event_size <= buffer_size && current_di_event < num_di_events) { num_events++; @@ -232,25 +230,25 @@ buf[index++] = 0; buf[index++] = 0; } + jint ch_int; if (useUnicode) { wchar_t ch = transBufUnicode[current_char]; - buf[index++] = (unsigned char) (ch & 0xff); - buf[index++] = (unsigned char) ((ch & 0xff00) >> 8); + ch_int = ((int)ch) & 0xFFFF; } else { - buf[index++] = (unsigned char)transBufAscii[current_char]; - buf[index++] = 0; + unsigned char ch = (unsigned char)transBufAscii[current_char]; + ch_int = ((int)ch) & 0xFF; } + buf[index++] = ch_int; current_char++; } while (index + event_size <= buffer_size && current_char < num_chars); } else { buf[index++] = 0; - buf[index++] = 0; } } else { buf[index++] = 0; - buf[index++] = 0; } - } + } else + buf[index++] = 0; current_di_event++; } } else if (ret == DI_BUFFEROVERFLOW) { Index: org_lwjgl_input_Cursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Cursor.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_input_Cursor.cpp 25 Jul 2004 14:51:28 -0000 1.13 +++ org_lwjgl_input_Cursor.cpp 22 Sep 2004 15:06:27 -0000 1.14 @@ -39,9 +39,8 @@ * @version $Revision$ */ -#include <windows.h> -#include "org_lwjgl_input_Cursor.h" #include "Window.h" +#include "org_lwjgl_input_Cursor.h" #include "common_tools.h" JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor Index: org_lwjgl_Sys.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Sys.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- org_lwjgl_Sys.cpp 12 Aug 2004 15:22:48 -0000 1.34 +++ org_lwjgl_Sys.cpp 22 Sep 2004 15:06:27 -0000 1.35 @@ -39,10 +39,9 @@ * @version $Revision$ */ -#include <windows.h> +#include "Window.h" #include "org_lwjgl_Sys.h" #include "common_tools.h" -#include "Window.h" unsigned __int64 hires_timer_freq = 0; // Hires timer frequency unsigned __int64 hires_timer = 0; // Hires timer current time |
|
From: Elias N. <eli...@us...> - 2004-09-22 15:06:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22065/src/native/linux Modified Files: org_lwjgl_input_Mouse.c Log Message: Updated win32 to report Mouse deltas Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_input_Mouse.c 22 Sep 2004 11:08:21 -0000 1.9 +++ org_lwjgl_input_Mouse.c 22 Sep 2004 15:06:26 -0000 1.10 @@ -65,7 +65,6 @@ static int dz; static int last_x; static int last_y; -static int last_z; static jbyte buttons[NUM_BUTTONS]; static event_queue_t event_queue; static bool buffer_enabled; @@ -84,14 +83,12 @@ } static void setCursorPos(int x, int y) { - int current_x = x; - int current_y = y; - jint event_dx = current_x - last_x; - jint event_dy = current_y - last_y; + jint event_dx = x - last_x; + jint event_dy = y - last_y; dx += event_dx; dy += event_dy; - last_x = current_x; - last_y = current_y; + last_x = x; + last_y = y; putEvent(-1, 0, event_dx, -event_dy, 0); } @@ -245,7 +242,7 @@ if (disp == NULL) return; int i; - last_z = last_y = last_x = dx = dy = dz = 0; + last_y = last_x = dx = dy = dz = 0; for (i = 0; i < NUM_BUTTONS; i++) buttons[i] = 0; if (!blankCursor()) { |
|
From: Elias N. <eli...@us...> - 2004-09-22 11:08:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1516/src/native/common Modified Files: common_tools.c common_tools.h Log Message: Add delta values to Mouse events Index: common_tools.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- common_tools.c 10 Sep 2004 09:56:26 -0000 1.2 +++ common_tools.c 22 Sep 2004 11:08:20 -0000 1.3 @@ -37,6 +37,7 @@ * @version $Revision$ */ +#include <jni.h> #include <stdlib.h> #include "common_tools.h" @@ -86,13 +87,13 @@ event_queue->list_end = 0; } -void putEventElement(event_queue_t *queue, unsigned char byte) { +void putEventElement(event_queue_t *queue, jint s) { int next_index = (queue->list_end + 1)%EVENT_BUFFER_SIZE; if (next_index == queue->list_start) { printfDebug("Event buffer overflow!\n"); return; } - queue->input_event_buffer[queue->list_end] = byte; + queue->input_event_buffer[queue->list_end] = s; queue->list_end = next_index; } @@ -100,16 +101,16 @@ return queue->list_start != queue->list_end; } -static void copyEvent(event_queue_t *queue, unsigned char *output_event_buffer, int output_index, int event_size) { +static void copyEvent(event_queue_t *queue, jint *output_event_buffer, int output_index, int event_size) { int i; for (i = 0; i < event_size; i++) { output_event_buffer[output_index] = queue->input_event_buffer[queue->list_start]; - incListStart(queue); + incListStart(queue); output_index++; } } -int copyEvents(event_queue_t *event_queue, unsigned char *output_event_buffer, int buffer_size, int event_size) { +int copyEvents(event_queue_t *event_queue, jint *output_event_buffer, int buffer_size, int event_size) { int num_events = 0; int index = 0; while (index + event_size <= buffer_size && hasMoreEvents(event_queue)) { Index: common_tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- common_tools.h 10 Sep 2004 09:56:26 -0000 1.22 +++ common_tools.h 22 Sep 2004 11:08:21 -0000 1.23 @@ -51,7 +51,7 @@ #define ATTRIB_LIST_SIZE (256) typedef struct { - unsigned char input_event_buffer[EVENT_BUFFER_SIZE]; + jint input_event_buffer[EVENT_BUFFER_SIZE]; int list_start; int list_end; @@ -125,9 +125,8 @@ extern bool isDebugEnabled(void); extern jstring getVersionString(JNIEnv *env); extern void initEventQueue(event_queue_t *event_queue); -extern int copyEvents(event_queue_t *event_queue, unsigned char *output_event_buffer, int buffer_size, int event_size); -extern void putEventElement(event_queue_t *queue, unsigned char byte); -extern unsigned char *getOutputList(event_queue_t *queue); +extern int copyEvents(event_queue_t *event_queue, jint *output_event_buffer, int buffer_size, int event_size); +extern void putEventElement(event_queue_t *queue, jint byte); extern void throwException(JNIEnv *env, const char *msg); extern void throwOpenALException(JNIEnv * env, const char * err); extern void throwFMODException(JNIEnv * env, const char * err); |
|
From: Elias N. <eli...@us...> - 2004-09-22 11:08:33
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1516/src/java/org/lwjgl/input Modified Files: Keyboard.java Mouse.java Log Message: Add delta values to Mouse events Index: Keyboard.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Keyboard.java,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- Keyboard.java 29 Jul 2004 11:41:10 -0000 1.51 +++ Keyboard.java 22 Sep 2004 11:08:05 -0000 1.52 @@ -34,6 +34,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.ByteBuffer; +import java.nio.IntBuffer; import java.util.HashMap; import java.util.Map; @@ -198,6 +199,8 @@ /** Buffer size in events */ private final static int BUFFER_SIZE = 50; + /** Event size in elements */ + private final static int EVENT_SIZE = 3; /** Key names */ private static final String[] keyName = new String[255]; @@ -241,7 +244,7 @@ * followed by state. If translation is enabled, the state is followed by * a 2 byte java char representing the translated character. */ - private static ByteBuffer readBuffer; + private static IntBuffer readBuffer; /** True if translation is enabled */ private static boolean translationEnabled; @@ -351,10 +354,7 @@ private static void read() { readBuffer.compact(); int numEvents = nRead(readBuffer, readBuffer.position()); - if (translationEnabled) - readBuffer.position(readBuffer.position() + numEvents*4); - else - readBuffer.position(readBuffer.position() + numEvents*2); + readBuffer.position(readBuffer.position() + numEvents*EVENT_SIZE); readBuffer.flip(); } @@ -370,7 +370,7 @@ * Native method to read the keyboard buffer * @return the total number of events read. */ - private static native int nRead(ByteBuffer buffer, int buffer_position); + private static native int nRead(IntBuffer buffer, int buffer_position); /** * Enable keyboard translation. Must be called after the keyboard is created, @@ -396,7 +396,7 @@ public static void enableBuffer() throws LWJGLException { if (!created) throw new IllegalStateException("Keyboard must be created before you can enable buffering"); - readBuffer = BufferUtils.createByteBuffer(4*BUFFER_SIZE); + readBuffer = BufferUtils.createIntBuffer(EVENT_SIZE*BUFFER_SIZE); readBuffer.limit(0); nEnableBuffer(); } @@ -474,10 +474,7 @@ public static int getNumKeyboardEvents() { if (!created) throw new IllegalStateException("Keyboard must be created before you can read events"); - if (translationEnabled) - return readBuffer.remaining()/4; - else - return readBuffer.remaining()/2; + return readBuffer.remaining()/EVENT_SIZE; } /** @@ -500,9 +497,8 @@ if (readBuffer.hasRemaining()) { eventKey = readBuffer.get() & 0xFF; eventState = readBuffer.get() != 0; - if (translationEnabled) { - eventCharacter = readBuffer.getChar(); - } + int eventCharacterInt = readBuffer.get() & 0xFFFF; + eventCharacter = (char)eventCharacterInt; return true; } else { return false; Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- Mouse.java 27 Jul 2004 17:08:48 -0000 1.65 +++ Mouse.java 22 Sep 2004 11:08:20 -0000 1.66 @@ -127,16 +127,23 @@ private static boolean initialized; /** The mouse button events from the last read */ - private static ByteBuffer readBuffer = null; + private static IntBuffer readBuffer = null; /** The current mouse event button being examined */ private static int eventButton; /** The current state of the button being examined in the event queue */ private static boolean eventState; + + /** The current delta of the mouse in the event queue */ + private static int event_dx; + private static int event_dy; + private static int event_dwheel; /** Buffer size in events */ private final static int BUFFER_SIZE = 50; + /** Event size in elements */ + private final static int EVENT_SIZE = 5; private static boolean isGrabbed; @@ -404,7 +411,7 @@ private static void read() { readBuffer.compact(); int numEvents = nRead(readBuffer, readBuffer.position()); - readBuffer.position(readBuffer.position() + numEvents * 2); + readBuffer.position(readBuffer.position() + numEvents * EVENT_SIZE); readBuffer.flip(); } @@ -456,7 +463,7 @@ */ public static void enableBuffer() throws LWJGLException { if (!created) throw new IllegalStateException("Mouse must be created before you can enable buffering"); - readBuffer = BufferUtils.createByteBuffer(2 * BUFFER_SIZE); + readBuffer = BufferUtils.createIntBuffer(EVENT_SIZE * BUFFER_SIZE); readBuffer.limit(0); nEnableBuffer(); } @@ -472,12 +479,13 @@ * Native method to read the keyboard buffer * @return the total number of events read. */ - private static native int nRead(ByteBuffer buffer, int buffer_position); + private static native int nRead(IntBuffer buffer, int buffer_position); /** * Gets the next mouse event. You can query which button caused the event by using - * <code>getEventButton()</code>. To get the state of that key, for that event, use - * <code>getEventButtonState</code>. + * <code>getEventButton()</code> (if any). To get the state of that key, for that event, use + * <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>, + * <code>getEventDY()</code> and <code>getEventDZ()</code>. * @see org.lwjgl.input.Mouse#getEventButton() * @see org.lwjgl.input.Mouse#getEventButtonState() * @return true if a mouse event was read, false otherwise @@ -488,28 +496,56 @@ throw new IllegalStateException("Event buffering must be enabled before you can read events"); if (readBuffer.hasRemaining()) { - eventButton = readBuffer.get() & 0xFF; + eventButton = readBuffer.get(); eventState = readBuffer.get() != 0; + event_dx = readBuffer.get(); + event_dy = readBuffer.get(); + event_dwheel = readBuffer.get(); return true; } else return false; } /** - * @return Current events button + * @return Current events button. Returns -1 if no button state was changed */ public static int getEventButton() { return eventButton; } /** - * @return Current events button state + * Get the current events button state. If <code>getEventButton()</code> is -1, + * and IllegalStateException is thrown. + * @return Current events button state. */ public static boolean getEventButtonState() { + if (eventButton == -1) + throw new IllegalStateException("Current event has no button state change"); return eventState; } /** + * @return Current events delta x + */ + public static int getEventDX() { + return event_dx; + } + + /** + * @return Current events delta y + */ + public static int getEventDY() { + return event_dy; + } + + /** + * @return Current events delta z + */ + public static int getEventDWheel() { + return event_dwheel; + } + + /** * Retrieves the absolute position. If the Display has been created * x will be clamped to 0...width-1. * |
|
From: Elias N. <eli...@us...> - 2004-09-22 11:08:32
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1516/src/native/linux Modified Files: org_lwjgl_input_Keyboard.c org_lwjgl_input_Mouse.c Log Message: Add delta values to Mouse events Index: org_lwjgl_input_Keyboard.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- org_lwjgl_input_Keyboard.c 22 Sep 2004 09:28:09 -0000 1.5 +++ org_lwjgl_input_Keyboard.c 22 Sep 2004 11:08:21 -0000 1.6 @@ -141,10 +141,10 @@ static int translateEvent(XKeyEvent *event) { static char temp_translation_buffer[KEYBOARD_BUFFER_SIZE]; static XComposeStatus status; - int num_chars, i; + int num_chars, i; + jint ch; - if (event->type == KeyRelease) { - putEventElement(&event_queue, 0); + if (!translation_enabled || event->type == KeyRelease) { putEventElement(&event_queue, 0); return 0; } @@ -152,17 +152,16 @@ if (num_chars > 0) { num_chars--; /* Assume little endian byte order */ - putEventElement(&event_queue, temp_translation_buffer[0]); - putEventElement(&event_queue, 0); + ch = (jint)temp_translation_buffer[0] & 0xFF; + putEventElement(&event_queue, ch); for (i = 0; i < num_chars; i++) { putEventElement(&event_queue, 0); putEventElement(&event_queue, 0); - putEventElement(&event_queue, temp_translation_buffer[i + 1]); - putEventElement(&event_queue, 0); + ch = ((jint)temp_translation_buffer[i + 1]) & 0xFF; + putEventElement(&event_queue, ch); } } else { putEventElement(&event_queue, 0); - putEventElement(&event_queue, 0); } return num_chars; } @@ -182,8 +181,7 @@ //printf("Reading a key %d %d count %d\n", (int)keycode, (int)state, num_events); putEventElement(&event_queue, keycode); putEventElement(&event_queue, state); - if (translation_enabled) - translateEvent(key_event); + translateEvent(key_event); } void handleKeyEvent(XKeyEvent *event) { @@ -201,14 +199,10 @@ } JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz, jobject buffer, jint buffer_position) { - int event_size; + int event_size = 3; handleMessages(); - if (translation_enabled) - event_size = 4; - else - event_size = 2; - unsigned char* buffer_ptr = (unsigned char *)(*env)->GetDirectBufferAddress(env, buffer); - int buffer_size = (*env)->GetDirectBufferCapacity(env, buffer) - buffer_position; + jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer); + int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer))/sizeof(jint) - buffer_position; return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, event_size); } Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- org_lwjgl_input_Mouse.c 22 Sep 2004 09:28:09 -0000 1.8 +++ org_lwjgl_input_Mouse.c 22 Sep 2004 11:08:21 -0000 1.9 @@ -73,13 +73,26 @@ static Cursor blank_cursor; static Cursor current_cursor; +static void putEvent(jint button, jint state, jint dx, jint dy, jint dz) { + if (buffer_enabled) { + putEventElement(&event_queue, button); + putEventElement(&event_queue, state); + putEventElement(&event_queue, dx); + putEventElement(&event_queue, dy); + putEventElement(&event_queue, dz); + } +} + static void setCursorPos(int x, int y) { int current_x = x; int current_y = y; - dx += current_x - last_x; - dy += current_y - last_y; + jint event_dx = current_x - last_x; + jint event_dy = current_y - last_y; + dx += event_dx; + dy += event_dy; last_x = current_x; last_y = current_y; + putEvent(-1, 0, event_dx, -event_dy, 0); } static int transformY(int y) { @@ -275,22 +288,24 @@ if (button_num == NUM_BUTTONS) return; buttons[button_num] = state; - if (buffer_enabled) { - putEventElement(&event_queue, button_num); - putEventElement(&event_queue, state); - } + putEvent(button_num, state, 0, 0, 0); } void handleButtonPress(XButtonEvent *event) { + jint delta = 0; switch (event->button) { case Button4: - dz += WHEEL_SCALE; + delta = WHEEL_SCALE; + putEvent(-1, 0, 0, 0, delta); break; case Button5: - dz -= WHEEL_SCALE; + delta = -WHEEL_SCALE; + putEvent(-1, 0, 0, 0, delta); + break; + default: break; - default: break; } + dz += delta; handleButton(event, 1); } @@ -364,10 +379,10 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz, jobject buffer, jint buffer_position) { - unsigned char* buffer_ptr = (unsigned char *)(*env)->GetDirectBufferAddress(env, buffer); - int buffer_size = (*env)->GetDirectBufferCapacity(env, buffer) - buffer_position; + jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer); + int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer))/sizeof(jint) - buffer_position; handleMessages(); - return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, 2); + return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, 5); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nGrabMouse(JNIEnv * env, jclass clazz, jboolean new_grab) { |
|
From: Elias N. <eli...@us...> - 2004-09-22 09:28:36
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10503/linux Modified Files: Window.h org_lwjgl_input_Keyboard.c org_lwjgl_input_Mouse.c org_lwjgl_opengl_Display.c Log Message: Linux: Improve input latency by processing X messages from nPoll and nRead Index: org_lwjgl_input_Keyboard.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- org_lwjgl_input_Keyboard.c 10 Sep 2004 08:13:55 -0000 1.4 +++ org_lwjgl_input_Keyboard.c 22 Sep 2004 09:28:09 -0000 1.5 @@ -196,11 +196,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll(JNIEnv * env, jclass clazz, jobject buffer) { unsigned char *new_keyboard_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, buffer); + handleMessages(); memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); } JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz, jobject buffer, jint buffer_position) { int event_size; + handleMessages(); if (translation_enabled) event_size = 4; else Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Window.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- Window.h 8 Sep 2004 20:15:55 -0000 1.20 +++ Window.h 22 Sep 2004 09:28:09 -0000 1.21 @@ -54,6 +54,7 @@ * release input (keyboard, mouse) */ extern bool releaseInput(void); + extern void handleMessages(void); extern bool checkXError(JNIEnv *env); extern Atom getWarpAtom(void); Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- org_lwjgl_opengl_Display.c 15 Sep 2004 17:44:39 -0000 1.3 +++ org_lwjgl_opengl_Display.c 22 Sep 2004 09:28:09 -0000 1.4 @@ -247,7 +247,8 @@ focused = true; } } -static void handleMessages() { + +void handleMessages(void) { XEvent event; Window win; int revert_mode; Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_input_Mouse.c 21 Sep 2004 14:36:52 -0000 1.7 +++ org_lwjgl_input_Mouse.c 22 Sep 2004 09:28:09 -0000 1.8 @@ -340,6 +340,7 @@ int coords_length = (*env)->GetDirectBufferCapacity(env, coord_buffer_obj); unsigned char *buttons_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, button_buffer_obj); int buttons_length = (*env)->GetDirectBufferCapacity(env, button_buffer_obj); + handleMessages(); if (coords_length < 3) { printfDebug("ERROR: Not enough space in coords array: %d < 3\n", coords_length); return; @@ -365,6 +366,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz, jobject buffer, jint buffer_position) { unsigned char* buffer_ptr = (unsigned char *)(*env)->GetDirectBufferAddress(env, buffer); int buffer_size = (*env)->GetDirectBufferCapacity(env, buffer) - buffer_position; + handleMessages(); return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size, 2); } |
|
From: Elias N. <eli...@us...> - 2004-09-21 14:37:02
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4094/linux Modified Files: org_lwjgl_input_Mouse.c Log Message: Fix linux crash in nGetNativeCursorCaps Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_input_Mouse.c 10 Sep 2004 08:13:55 -0000 1.6 +++ org_lwjgl_input_Mouse.c 21 Sep 2004 14:36:52 -0000 1.7 @@ -177,12 +177,16 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps (JNIEnv *env, jclass clazz) { int caps = 0; + Display *disp = incDisplay(env); + if (disp == NULL) + return caps; XcursorBool argb_supported = XcursorSupportsARGB(getDisplay()); XcursorBool anim_supported = XcursorSupportsAnim(getDisplay()); if (argb_supported) caps |= org_lwjgl_input_Mouse_CURSOR_8_BIT_ALPHA | org_lwjgl_input_Mouse_CURSOR_ONE_BIT_TRANSPARENCY; if (anim_supported) caps |= org_lwjgl_input_Mouse_CURSOR_ANIMATION; + decDisplay(); return caps; } |
|
From: Brian M. <ma...@us...> - 2004-09-19 11:17:38
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7033/openal Modified Files: AL.java Log Message: native loading modified to be in line with oal Index: AL.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/AL.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- AL.java 10 Aug 2004 10:31:52 -0000 1.32 +++ AL.java 19 Sep 2004 11:17:28 -0000 1.33 @@ -146,6 +146,7 @@ } String jwsPath = getPathFromJWS(jwsLibname); + Sys.log("getPathFromJWS: Paths found: " + jwsPath); if (jwsPath != null) { libpath += seperator + jwsPath.substring(0, jwsPath.lastIndexOf(File.separator)); @@ -160,6 +161,10 @@ for (int i = 0; i < oalPaths.length - 1; i++) { oalPaths[i] = st.nextToken() + File.separator; } + + for(int i=0 ; i<oalPaths.length; i++) { + Sys.log("Will search " + oalPaths[i] + " for " + jwsLibname); + } //add cwd path oalPaths[oalPaths.length - 1] = ""; @@ -238,9 +243,7 @@ */ private static String getPathFromJWS(String libname) { try { - - Sys.log("JWS Classloader looking for: " + libname); - + Sys.log("getPathFromJWS: searching for: " + libname); Object o = AL.class.getClassLoader(); Class c = o.getClass(); Method findLibrary = |
|
From: Brian M. <ma...@us...> - 2004-09-19 11:17:37
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7033/fmod3 Modified Files: FMOD.java Log Message: native loading modified to be in line with oal Index: FMOD.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FMOD.java 16 Sep 2004 22:40:12 -0000 1.4 +++ FMOD.java 19 Sep 2004 11:17:28 -0000 1.5 @@ -191,16 +191,16 @@ private static String JNI_LIBRARY_NAME = "lwjgl-fmod3"; /** The native library name on win32 */ - private static String FMOD_WIN32_LIBRARY_NAME = "fmod.dll"; + private static String FMOD_WIN32_LIBRARY_NAME = "fmod"; /** The native library name on win32 */ - private static String FMOD_LINUX_LIBRARY_NAME = "libfmod.so.0"; + private static String FMOD_LINUX_LIBRARY_NAME = "fmod"; /** The native library name on win32 */ - private static String FMOD_OSX_LIBRARY_NAME = "fmod_cfm.shlb"; + private static String FMOD_OSX_LIBRARY_NAME = "fmod"; /** Version of FMOD */ - public static final String VERSION = "0.9a"; + public static final String VERSION = "0.92"; static { initialize(); @@ -275,7 +275,8 @@ dllName = FMOD_LINUX_LIBRARY_NAME; } - String jwsPath = getPathFromJWS(dllName.substring(0, dllName.indexOf("."))); + String jwsPath = getPathFromJWS(dllName); + Sys.log("getPathFromJWS: Paths found: " + jwsPath); if (jwsPath != null) { libpath += seperator + jwsPath.substring(0, jwsPath.lastIndexOf(File.separator)); @@ -287,7 +288,11 @@ //build paths for (int i = 0; i < paths.length - 1; i++) { - paths[i] = st.nextToken() + File.separator + dllName; + paths[i] = st.nextToken() + File.separator; + } + + for(int i=0 ; i<paths.length; i++) { + Sys.log("Will search " + paths[i] + " for " + dllName); } //add cwd path @@ -323,7 +328,8 @@ * @return Absolute path to library if found, otherwise null */ private static String getPathFromJWS(String libname) { - try { + try { + Sys.log("getPathFromJWS: searching for: " + libname); Object o = FMOD.class.getClassLoader(); Class c = o.getClass(); Method findLibrary = @@ -332,7 +338,7 @@ return (String) findLibrary.invoke(o, arguments); } catch (Exception e) { - System.out.println("Failure locating FMOD using classloader:" + e); + Sys.log("Failure locating FMOD using classloader:" + e); } return null; } |
|
From: Brian M. <ma...@us...> - 2004-09-19 11:17:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6951 Modified Files: extfmod3.c extfmod3.h org_lwjgl_fmod3_FMOD.c Log Message: native loading modified to be in line with oal Index: org_lwjgl_fmod3_FMOD.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/fmod3/org_lwjgl_fmod3_FMOD.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_fmod3_FMOD.c 10 Sep 2004 08:13:53 -0000 1.1 +++ org_lwjgl_fmod3_FMOD.c 19 Sep 2004 11:17:07 -0000 1.2 @@ -33,7 +33,19 @@ #include "org_lwjgl_fmod3_FMOD.h" #include "extfmod3.h" -static const char* VERSION = "0.9a"; +static const char* VERSION = "0.92"; + +/** + * Concatenate two strings + */ +static char *concatenate(const char *str1, const char *str2) { + int length1 = strlen(str1); + int length2 = strlen(str2); + char *str = (char *)calloc(length1 + length2 + 1, sizeof(char)); + strncpy(str, str1, length1); + strncpy(str + length1, str2, length2 + 1); + return str; +} /* * Class: org_lwjgl_fmod3_FMOD @@ -52,11 +64,25 @@ JNIEXPORT void JNICALL Java_org_lwjgl_fmod3_FMOD_nCreate(JNIEnv *env, jclass clazz, jobjectArray paths) { jsize pathcount = (*env)->GetArrayLength(env, paths); int i; + jstring path; + const char *path_str; + char *lib_str; + for(i=0;i<pathcount;i++) { - jstring path = (jstring) (*env)->GetObjectArrayElement(env, paths, i); - char *path_str = (char *) (*env)->GetStringUTFChars(env, path, NULL); - printfDebug("Trying to load fmod_instance from %s\n", path_str); - fmod_create(env, path_str); + path = (jstring) (*env)->GetObjectArrayElement(env, paths, i); + path_str = (*env)->GetStringUTFChars(env, path, NULL); +#ifdef _WIN32 + lib_str = concatenate(path_str, "fmod.dll"); +#endif +#ifdef _X11 + lib_str = concatenate(path_str, "libfmod.so"); +#endif +#ifdef _AGL + lib_str = concatenate(path_str, "fmod_cfm.shlb"); +#endif + printfDebug("Testing '%s'\n", lib_str); + fmod_create(env, lib_str); + free(lib_str); (*env)->ReleaseStringUTFChars(env, path, path_str); if(fmod_instance != NULL) { Index: extfmod3.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/fmod3/extfmod3.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- extfmod3.h 3 Sep 2004 06:03:32 -0000 1.5 +++ extfmod3.h 19 Sep 2004 11:17:07 -0000 1.6 @@ -40,7 +40,7 @@ #include "fmod_errors.h" // Called to create an FMOD instance -void fmod_create(JNIEnv *env, char*); +void fmod_create(JNIEnv *env, const char*); // Called to destroy our FMOD instance void fmod_destroy(); Index: extfmod3.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/fmod3/extfmod3.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- extfmod3.c 10 Sep 2004 08:13:53 -0000 1.1 +++ extfmod3.c 19 Sep 2004 11:17:07 -0000 1.2 @@ -77,9 +77,9 @@ * * @param path path to try to load dll */ -void fmod_create(JNIEnv *env, char* path) { +void fmod_create(JNIEnv *env, const char* path) { // try to create an instance using the supplied path - fmod_instance = FMOD_CreateInstance(path); + fmod_instance = FMOD_CreateInstance((char *)path); // if we got one, we need to locate and cache jni stuff used for callbacks if (fmod_instance != NULL) { |
|
From: Elias N. <eli...@us...> - 2004-09-18 11:41:40
|
Update of /cvsroot/java-game-lib/LWJGL/src/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3949 Modified Files: configure.in Log Message: Removed redundant CXXFLAGS definition from configure.in Index: configure.in =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/configure.in,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- configure.in 11 Sep 2004 07:20:50 -0000 1.57 +++ configure.in 18 Sep 2004 11:41:30 -0000 1.58 @@ -29,7 +29,6 @@ LDFLAGS="-Wl,-static,-lXcursor,-lXrender,-lXrandr,-call_shared" AC_CHECK_HEADERS([AL/altypes.h AL/alctypes.h],, AC_MSG_ERROR([OpenAL headers required])) NATIVE_BUILD_DIR=linux - CXXFLAGS="$CXXFLAGS -Wall $_BUILD_FLAGS" CFLAGS="$CFLAGS -Wall $_BUILD_FLAGS" LIBS="$LIBS $X_LIBS" AC_CHECK_LIB(X11, XOpenDisplay,, AC_MSG_ERROR(X11 is required)) |
|
From: Brian M. <ma...@us...> - 2004-09-17 05:56:19
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5750/src/java/org/lwjgl/test/input Modified Files: MouseTest.java Log Message: use public display mode constructor to get proper window size Index: MouseTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- MouseTest.java 22 Jul 2004 15:00:36 -0000 1.39 +++ MouseTest.java 17 Sep 2004 05:56:10 -0000 1.40 @@ -129,15 +129,10 @@ */ protected boolean setDisplayMode() { // get modes - DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(WINDOW_WIDTH, WINDOW_HEIGHT, -1, -1, -1, -1, 60, 60); + DisplayMode dm = new DisplayMode(WINDOW_WIDTH, WINDOW_HEIGHT); try { - org.lwjgl.util.Display.setDisplayMode(dm, new String[] { - "width=" + WINDOW_WIDTH, - "height=" + WINDOW_HEIGHT, - "freq=" + 60, - "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel() - }); + Display.setDisplayMode(dm); return true; } catch (Exception e) { e.printStackTrace(); |
|
From: Brian M. <ma...@us...> - 2004-09-16 22:40:24
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20077/src/java/org/lwjgl/fmod3 Modified Files: FMOD.java Log Message: use OAL type loading Index: FMOD.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3/FMOD.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FMOD.java 12 Sep 2004 13:28:38 -0000 1.3 +++ FMOD.java 16 Sep 2004 22:40:12 -0000 1.4 @@ -32,6 +32,7 @@ package org.lwjgl.fmod3; import java.io.File; +import java.lang.reflect.Method; import java.nio.FloatBuffer; import java.util.ArrayList; import java.util.HashMap; @@ -274,6 +275,12 @@ dllName = FMOD_LINUX_LIBRARY_NAME; } + String jwsPath = getPathFromJWS(dllName.substring(0, dllName.indexOf("."))); + if (jwsPath != null) { + libpath += seperator + + jwsPath.substring(0, jwsPath.lastIndexOf(File.separator)); + } + // split, and rebuild library path to path + dll StringTokenizer st = new StringTokenizer(libpath, seperator); String[] paths = new String[st.countTokens() + 1]; @@ -284,7 +291,7 @@ } //add cwd path - paths[paths.length - 1] = dllName; + paths[paths.length - 1] = dllName; return paths; } @@ -304,6 +311,31 @@ created = false; nDestroy(); } + + /** + * Tries to locate FMOD from the JWS Library path + * This method exists because FMOD is loaded from native code, and as such + * is exempt from JWS library loading rutines. FMOD therefore always fails. + * We therefore invoke the protected method of the JWS classloader to see if it can + * locate it. + * + * @param libname Name of library to search for + * @return Absolute path to library if found, otherwise null + */ + private static String getPathFromJWS(String libname) { + try { + Object o = FMOD.class.getClassLoader(); + Class c = o.getClass(); + Method findLibrary = + c.getMethod("findLibrary", new Class[] { String.class }); + Object[] arguments = new Object[] { libname }; + return (String) findLibrary.invoke(o, arguments); + + } catch (Exception e) { + System.out.println("Failure locating FMOD using classloader:" + e); + } + return null; + } /** * Native method the destroy the FMOD |
|
From: Brian M. <ma...@us...> - 2004-09-16 22:38:41
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19758/src/java/org/lwjgl/test/fmod3 Modified Files: NetTest.java Log Message: print stack trace on error Index: NetTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/NetTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- NetTest.java 16 Sep 2004 21:11:52 -0000 1.3 +++ NetTest.java 16 Sep 2004 22:38:31 -0000 1.4 @@ -253,6 +253,7 @@ FMOD.create(); } catch (FMODException fmode) { error(fmode.getMessage()); + fmode.printStackTrace(); return false; } |
|
From: Brian M. <ma...@us...> - 2004-09-16 21:12:02
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1875/src/java/org/lwjgl/test/fmod3 Modified Files: NetTest.java Log Message: AWT version - much neater Index: NetTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/fmod3/NetTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- NetTest.java 20 Aug 2004 06:22:54 -0000 1.2 +++ NetTest.java 16 Sep 2004 21:11:52 -0000 1.3 @@ -31,7 +31,19 @@ */ package org.lwjgl.test.fmod3; -import java.nio.ByteBuffer; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; @@ -39,7 +51,6 @@ import org.lwjgl.fmod3.FMODException; import org.lwjgl.fmod3.FSound; import org.lwjgl.fmod3.FSoundStream; -import org.lwjgl.fmod3.callbacks.FSoundMetaDataCallback; /** * $Id$ <br> @@ -48,90 +59,237 @@ * @version $Revision$ */ public class NetTest { + + private Frame frame; + private boolean initialized; + private Thread fmodThread; + private volatile boolean running; + private int channel = -1; + private boolean paused = true; + + public NetTest(Frame frame) { + this.frame = frame; + } public static void main(String[] args) { - if (args.length < 1) { - System.out.println("Usage:\n NetTest <url>"); - - // default to monkeyradio.org - args = new String[1]; - args[0] = "http://207.200.96.227:8038/"; - } + final Frame frame = new Frame("LWJGL Fmod streaming player"); + final NetTest netTest = new NetTest(frame); + final boolean playing = false; + + final TextField txtField; + final Button btnPlay; + final Button btnStop; + + // main panel + Panel panel = new Panel(); + panel.setLayout(new FlowLayout()); + panel.add(new Label("URL:")); + panel.add(txtField = new TextField("http://207.200.96.227:8038/", 60)); + panel.add(btnPlay = new Button("Play")); + panel.add(btnStop = new Button("Stop")); + panel.setBackground(new Color(0x99, 0x99, 0x99)); + + frame.add(panel); + frame.pack(); + + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + frame.dispose(); + netTest.dispose(); + } + }); + + btnPlay.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + netTest.play(txtField.getText()); + } + }); + + btnStop.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + netTest.stop(); + } + }); - try { - FMOD.create(); - } catch (FMODException fmode) { - fmode.printStackTrace(); - return; - } + // setup frame + int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - frame.getWidth()) / 2; + int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - frame.getHeight()) / 2; + frame.setLocation(x, y); + frame.setResizable(false); + frame.setVisible(true); + } + + /** + * + */ + private void dispose() { + if(initialized) { + stop(); + FSound.FSOUND_Close(); + FMOD.destroy(); + } + } - System.out.println("Initializing FMOD"); - if (!FSound.FSOUND_Init(44100, 32, 0)) { - System.out.println("Failed to initialize FMOD"); - System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); - return; - } + /** + * + */ + protected void pause() { + if(running && channel > 0) { + FSound.FSOUND_SetPaused(channel, paused = !paused); + + if(paused) { + frame.setTitle("LWJGL Fmod streaming player: Paused"); + } + } + } + + /** + * + */ + protected void play(final String url) { + if(!initialized) { + frame.setTitle("Initializing..."); + if(!initialize()) { + frame.setTitle("LWJGL Fmod streaming player"); + return; + } + } + if(fmodThread != null) { + stop(); + } - FSound.FSOUND_Stream_SetBufferSize(100); - FSound.FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80); + + fmodThread = new Thread() { + public void run() { + frame.setTitle("Opening [" + url + "]"); + running = true; + FSoundStream stream = FSound.FSOUND_Stream_Open(url, FSound.FSOUND_NORMAL | FSound.FSOUND_NONBLOCKING, 0, 0); + + if (stream != null) { + IntBuffer status = BufferUtils.createIntBuffer(4); + while(running) { + if(channel < 0) { + channel = FSound.FSOUND_Stream_PlayEx(FSound.FSOUND_FREE, stream, null, true); + FSound.FSOUND_SetPaused(channel, false); + paused = false; + } + + int openstate = FSound.FSOUND_Stream_GetOpenState(stream); + if ((openstate == -1) || (openstate == -3)) { + error("failed to open stream!: " + FSound.FSOUND_Stream_Net_GetLastServerStatus()); + break; + } + + FSound.FSOUND_Stream_Net_GetStatus(stream, status); + + if(!paused) { + frame.setTitle("Playing [state: " + getNameFor(status.get(0)) + ", buffer: " + status.get(1) + ", bitrate: " + status.get(2) + "]"); + } + pause(10); + } + + while(!FSound.FSOUND_Stream_Stop(stream)) { + pause(10); + } + while(!FSound.FSOUND_Stream_Close(stream)) { + pause(10); + } + channel = -1; + } else { + error("Unable to play: " + url + ". Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); + } + } + }; + fmodThread.start(); + } - System.out.println("Loading " + args[0]); - FSoundStream stream = FSound.FSOUND_Stream_Open(args[0], FSound.FSOUND_NORMAL | FSound.FSOUND_NONBLOCKING, 0, 0); + /** + * @param i + * @return + */ + protected String getNameFor(int i) { + switch(i) { + case FSound.FSOUND_STREAM_NET_NOTCONNECTED: + return "FSOUND_STREAM_NET_NOTCONNECTED"; + case FSound.FSOUND_STREAM_NET_CONNECTING: + return "FSOUND_STREAM_NET_CONNECTING"; + case FSound.FSOUND_STREAM_NET_BUFFERING: + return "FSOUND_STREAM_NET_BUFFERING"; + case FSound.FSOUND_STREAM_NET_READY: + return "FSOUND_STREAM_NET_READY"; + case FSound.FSOUND_STREAM_NET_ERROR: + return "FSOUND_STREAM_NET_ERROR"; + } + return ""; + } + /** + * + */ + protected void stop() { + if(frame.isVisible()) { + frame.setTitle("LWJGL Fmod streaming player: stopping..."); + } - if (stream != null) { + running = false; + if(fmodThread != null) { + try { + fmodThread.join(); + } catch (InterruptedException inte) { + } + fmodThread = null; + } + + if(frame.isVisible()) { + frame.setTitle("LWJGL Fmod streaming player"); + } + } + + protected boolean initialize() { + if(!initialized) { + try { + FMOD.create(); + } catch (FMODException fmode) { + error(fmode.getMessage()); + return false; + } - int channel = -1; - boolean run = true; - IntBuffer status = BufferUtils.createIntBuffer(4); - while(run) { - if(channel < 0) { - channel = FSound.FSOUND_Stream_PlayEx(FSound.FSOUND_FREE, stream, null, true); - FSound.FSOUND_SetPaused(channel, false); - - if (channel != -1) { - FSound.FSOUND_Stream_Net_SetMetadataCallback(stream, new FSoundMetaDataCallback() { - public void FSOUND_METADATACALLBACK(ByteBuffer name, ByteBuffer value) { - byte[] charName = new byte[name.capacity()]; - name.get(charName); - - byte[] charValue = new byte[value.capacity()]; - value.get(charValue); - - System.out.println(new String(charName) + " = " + new String(charValue)); - } - }); - } - } - - int openstate = FSound.FSOUND_Stream_GetOpenState(stream); - if ((openstate == -1) || (openstate == -3)) { - System.out.println("\nERROR: failed to open stream!\n"); - System.out.println("SERVER: " + FSound.FSOUND_Stream_Net_GetLastServerStatus() + "\n"); - break; - } - - FSound.FSOUND_Stream_Net_GetStatus(stream, status); - - System.out.println("Status: " + status.get(0) + ", buffer: " + status.get(1) + ", bitrate: " + status.get(2) + ", flags: " + status.get(3)); - - pause(100); + if (!FSound.FSOUND_Init(44100, 32, 0)) { + error("Failed to initialize FMOD: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); + return false; } - FSound.FSOUND_Stream_Stop(stream); - FSound.FSOUND_Stream_Close(stream); - } else { - System.out.println("Unable to play: " + args[0]); - System.out.println("Error: " + FMOD.FMOD_ErrorString(FSound.FSOUND_GetError())); - } + FSound.FSOUND_Stream_SetBufferSize(500); + FSound.FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80); + initialized = true; + } + return initialized; + } - FSound.FSOUND_Close(); - FMOD.destroy(); + /** + * @param string + */ + private void error(String string) { + final Dialog dialog = new Dialog(frame, "Error", true); + dialog.add(new Label(string)); + dialog.pack(); + + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialog.dispose(); + } + }); + + // setup dialog + int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - dialog.getWidth()) / 2; + int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - dialog.getHeight()) / 2; + dialog.setLocation(x, y); + dialog.setVisible(true); } - - /** + + /** * @param i */ private static void pause(long i) { |
|
From: Brian M. <ma...@us...> - 2004-09-16 21:11:32
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1771/src/java/org/lwjgl/fmod3 Modified Files: FSound.java Log Message: add net enums Index: FSound.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/fmod3/FSound.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- FSound.java 10 Sep 2004 21:56:58 -0000 1.7 +++ FSound.java 16 Sep 2004 21:11:22 -0000 1.8 @@ -335,6 +335,21 @@ /** An Advanced Streaming Format header line */ public static final int FSOUND_TAGFIELD_ASF = 5; + + /** Stream hasn't connected yet */ + public static final int FSOUND_STREAM_NET_NOTCONNECTED = 0; + + /** Stream is connecting to remote host */ + public static final int FSOUND_STREAM_NET_CONNECTING = 1; + + /** Stream is buffering data */ + public static final int FSOUND_STREAM_NET_BUFFERING = 2; + + /** Stream is ready to play */ + public static final int FSOUND_STREAM_NET_READY = 3; + + /** Stream has suffered a fatal error */ + public static final int FSOUND_STREAM_NET_ERROR = 4; // Pre Initialization / Initialization / Enumeration // ====================================================== |
|
From: Elias N. <eli...@us...> - 2004-09-15 17:45:07
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27855/src/native/common Modified Files: org_lwjgl_opengl_Display.h Log Message: Added setLocation support for linux Index: org_lwjgl_opengl_Display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Display.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- org_lwjgl_opengl_Display.h 9 Aug 2004 11:55:48 -0000 1.4 +++ org_lwjgl_opengl_Display.h 15 Sep 2004 17:44:38 -0000 1.5 @@ -11,6 +11,8 @@ /* Inaccessible static: initial_mode */ /* Inaccessible static: timeNow */ /* Inaccessible static: timeThen */ +/* Inaccessible static: x */ +/* Inaccessible static: y */ /* Inaccessible static: title */ /* Inaccessible static: fullscreen */ /* Inaccessible static: vsync */ @@ -27,10 +29,10 @@ /* * Class: org_lwjgl_opengl_Display * Method: nCreateWindow - * Signature: (Lorg/lwjgl/opengl/DisplayMode;Z)V + * Signature: (Lorg/lwjgl/opengl/DisplayMode;ZII)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nCreateWindow - (JNIEnv *, jclass, jobject, jboolean); + (JNIEnv *, jclass, jobject, jboolean, jint, jint); /* * Class: org_lwjgl_opengl_Display @@ -184,6 +186,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSetVSyncEnabled (JNIEnv *, jclass, jboolean); +/* + * Class: org_lwjgl_opengl_Display + * Method: nReshape + * Signature: (IIII)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nReshape + (JNIEnv *, jclass, jint, jint, jint, jint); + #ifdef __cplusplus } #endif |
|
From: Elias N. <eli...@us...> - 2004-09-15 17:45:07
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27855/src/native/linux Modified Files: org_lwjgl_opengl_Display.c Log Message: Added setLocation support for linux Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_Display.c 10 Sep 2004 14:09:33 -0000 1.2 +++ org_lwjgl_opengl_Display.c 15 Sep 2004 17:44:39 -0000 1.3 @@ -343,7 +343,11 @@ return supported; } -static bool createWindow(JNIEnv* env, int width, int height) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nReshape(JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) { + XMoveWindow(getDisplay(), getCurrentWindow(), x, y); +} + +static bool createWindow(JNIEnv* env, int x, int y, int width, int height) { bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); dirty = true; focused = true; @@ -370,7 +374,7 @@ attribmask |= CWOverrideRedirect; attribs.override_redirect = True; } - win = XCreateWindow(getDisplay(), root_win, 0, 0, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); + win = XCreateWindow(getDisplay(), root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); if (!checkXError(env)) { XFreeColormap(getDisplay(), cmap); return false; @@ -706,7 +710,7 @@ decDisplay(); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nCreateWindow(JNIEnv *env, jclass clazz, jobject mode, jboolean fullscreen) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nCreateWindow(JNIEnv *env, jclass clazz, jobject mode, jboolean fullscreen, int x, int y) { bool current_fullscreen = fullscreen == JNI_TRUE; if (current_fullscreen) { if (getCurrentDisplayModeExtension() == XRANDR && isNetWMFullscreenSupported()) @@ -720,7 +724,7 @@ jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); int width = (*env)->GetIntField(env, mode, fid_width); int height = (*env)->GetIntField(env, mode, fid_height); - bool window_created = createWindow(env, width, height); + bool window_created = createWindow(env, x, y, width, height); if (!window_created) { return; } |
|
From: Brian M. <ma...@us...> - 2004-09-15 17:07:23
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18511/native/win32 Modified Files: Window.h display.cpp org_lwjgl_opengl_Display.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: support for setLocation Index: display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/display.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- display.cpp 22 Jul 2004 07:38:56 -0000 1.3 +++ display.cpp 15 Sep 2004 17:07:06 -0000 1.4 @@ -53,6 +53,8 @@ WORD* originalGamma = new WORD[256 * 3]; // Original gamma settings WORD* currentGamma = new WORD[256 * 3]; // Current gamma settings DEVMODE devmode; // Now we'll remember this value for the future +extern HWND display_hwnd = NULL; // Handle to the window +extern RECT clientSize; char * driver = getDriver(); jobjectArray getAvailableDisplayModes(JNIEnv *env) @@ -213,7 +215,7 @@ devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (freq != 0) devmode.dmFields |= DM_DISPLAYFREQUENCY; - LONG cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); + LONG cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); if (cdsret != DISP_CHANGE_SUCCESSFUL) { // Failed: so let's check to see if it's a wierd dual screen display @@ -227,7 +229,6 @@ return; } } - modeSet = true; } Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_opengl_Display.cpp 9 Aug 2004 16:08:51 -0000 1.23 +++ org_lwjgl_opengl_Display.cpp 15 Sep 2004 17:07:06 -0000 1.24 @@ -47,17 +47,18 @@ #include "display.h" #include "org_lwjgl_opengl_Display.h" -static bool oneShotInitialised = false; // Registers the LWJGL window class +static bool oneShotInitialised = false; // Registers the LWJGL window class -static HWND display_hwnd = NULL; // Handle to the window -static HDC display_hdc = NULL; // Device context -static HGLRC display_hglrc = NULL; // OpenGL context -static bool isFullScreen = false; // Whether we're fullscreen or not -static bool isMinimized = false; // Whether we're minimized or not +static HWND display_hwnd = NULL; // Handle to the window +static HDC display_hdc = NULL; // Device context +static HGLRC display_hglrc = NULL; // OpenGL context +static bool isFullScreen = false; // Whether we're fullscreen or not +static bool isMinimized = false; // Whether we're minimized or not static bool isFocused = false; // whether we're focused or not static bool isDirty = false; // Whether we're dirty or not -static bool isUndecorated = false; // Whether we're undecorated or not -extern HINSTANCE dll_handle; // Handle to the LWJGL dll +static bool isUndecorated = false; // Whether we're undecorated or not +extern HINSTANCE dll_handle; // Handle to the LWJGL dll +RECT clientSize; // client size rect used when creating and positioning window static bool closerequested; static int pixel_format_index; @@ -346,6 +347,17 @@ { isDirty = true; } + /*case WM_MOVE: { + // get fields of display + jclass cls_display = env->FindClass("org/lwjgl/opengl/Display"); + jfieldID fid_x = env->GetStaticFieldID(cls_display, "x", "I"); + jfieldID fid_y = env->GetStaticFieldID(cls_display, "y", "I"); + + // set fields + env->SetStaticIntField(cls_display, fid_x, (int)(short) LOWORD(lParam)); + env->SetStaticIntField(cls_display, fid_y, (int)(short) HIWORD(lParam)); + + }*/ } // default action @@ -414,7 +426,7 @@ * * Returns true for success, or false for failure */ -HWND createWindow(int width, int height, bool fullscreen, bool undecorated) +HWND createWindow(int x, int y, int width, int height, bool fullscreen, bool undecorated) { int exstyle, windowflags; @@ -436,7 +448,6 @@ // If we're not a fullscreen window, adjust the height to account for the // height of the title bar (unless undecorated) - RECT clientSize; clientSize.bottom = height; clientSize.left = 0; clientSize.right = width; @@ -455,7 +466,7 @@ WINDOWCLASSNAME, "", windowflags, - 0, 0, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, + x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, NULL, NULL, dll_handle, @@ -574,7 +585,7 @@ return getAvailableDisplayModes(env); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nCreateWindow(JNIEnv *env, jclass clazz, jobject mode, jboolean fullscreen) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nCreateWindow(JNIEnv *env, jclass clazz, jobject mode, jboolean fullscreen, jint x, jint y) { closerequested = false; isMinimized = false; isFocused = true; @@ -587,7 +598,7 @@ int width = env->GetIntField(mode, fid_width); int height = env->GetIntField(mode, fid_height); - display_hwnd = createWindow(width, height, isFullScreen, isUndecorated); + display_hwnd = createWindow(x, y, width, height, isFullScreen, isUndecorated); if (display_hwnd == NULL) { throwException(env, "Failed to create the window."); return; @@ -656,7 +667,7 @@ if (pixel_format_index == -1) return false; } - HWND arb_hwnd = createWindow(1, 1, false, false); + HWND arb_hwnd = createWindow(0, 0, 1, 1, false, false); if (arb_hwnd == NULL) return false; HDC arb_hdc = GetDC(arb_hwnd); @@ -672,7 +683,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_createContext(JNIEnv *env, jclass clazz, jobject pixel_format) { - HWND dummy_hwnd = createWindow(1, 1, false, false); + HWND dummy_hwnd = createWindow(0, 0, 1, 1, false, false); if (dummy_hwnd == NULL) { throwException(env, "Failed to create the window."); return; @@ -729,3 +740,38 @@ display_hglrc = NULL; } } + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nReshape(JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) { + if (isFullScreen) { + return; + } + + int exstyle, windowflags; + + if (isFullScreen) { + exstyle = WS_EX_APPWINDOW | WS_EX_TOPMOST; + windowflags = WS_POPUP; + } else if (getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")) { + exstyle = WS_EX_APPWINDOW; + windowflags = WS_POPUP; + } else { + exstyle = WS_EX_APPWINDOW; + windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU; + } + + // If we're not a fullscreen window, adjust the height to account for the + // height of the title bar: + clientSize.bottom = height; + clientSize.left = 0; + clientSize.right = width; + clientSize.top = 0; + + AdjustWindowRectEx( + &clientSize, // client-rectangle structure + windowflags, // window styles + FALSE, // menu-present option + exstyle // extended window style + ); + + SetWindowPos(display_hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER); +} Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Window.h 2 Aug 2004 14:47:52 -0000 1.17 +++ Window.h 15 Sep 2004 17:07:06 -0000 1.18 @@ -56,26 +56,26 @@ extern bool isMinimized; // Whether we're minimized or not extern bool isFocused; // Whether we're focused or not extern bool isDirty; // Whether we're dirty or not - #endif /* _PRIVATE_WINDOW_H_ */ - - WINDOW_H_API HWND getCurrentHWND(); + #endif /* _PRIVATE_WINDOW_H_ */ - WINDOW_H_API HGLRC getCurrentContext(); - - WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat); - - WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc); - - /* - * Find a suitable pixel format - */ - WINDOW_H_API int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format); - - /* - * Find a suitable pixel format using the WGL_ARB_pixel_format extension + WINDOW_H_API HWND getCurrentHWND(); + + WINDOW_H_API HGLRC getCurrentContext(); + + WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat); + + WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc); + + /* + * Find a suitable pixel format */ - WINDOW_H_API int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); - + WINDOW_H_API int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format); + + /* + * Find a suitable pixel format using the WGL_ARB_pixel_format extension + */ + WINDOW_H_API int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); + /* * Create a window with the specified title, position, size, and * fullscreen attribute. The window will have DirectInput associated @@ -83,7 +83,7 @@ * * Returns true for success, or false for failure */ - WINDOW_H_API HWND createWindow(int width, int height, bool fullscreen, bool undecorated); + WINDOW_H_API HWND createWindow(int x, int y, int width, int height, bool fullscreen, bool undecorated); /* Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- org_lwjgl_opengl_Pbuffer.cpp 2 Aug 2004 14:47:52 -0000 1.20 +++ org_lwjgl_opengl_Pbuffer.cpp 15 Sep 2004 17:07:06 -0000 1.21 @@ -79,7 +79,7 @@ } static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pixel_format, jobject pixelFormatCaps, const int *pBufferAttribs_ptr) { - HWND dummy_hwnd = createWindow(1, 1, false, false); + HWND dummy_hwnd = createWindow(0, 0, 1, 1, false, false); if (dummy_hwnd == NULL) { throwException(env, "Could not create dummy window"); return NULL; |
|
From: Brian M. <ma...@us...> - 2004-09-15 17:07:23
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18511/java/org/lwjgl/test Modified Files: WindowCreationTest.java Log Message: support for setLocation Index: WindowCreationTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/WindowCreationTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- WindowCreationTest.java 22 Jul 2004 15:10:55 -0000 1.22 +++ WindowCreationTest.java 15 Sep 2004 17:07:05 -0000 1.23 @@ -31,8 +31,10 @@ */ package org.lwjgl.test; +import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; import org.lwjgl.input.Keyboard; /** @@ -52,6 +54,12 @@ // get avaialble modes, and print out DisplayMode[] modes = Display.getAvailableDisplayModes(); System.out.println("Found " + modes.length + " display modes"); + + int x = 100, y = 100; + boolean fullscreen = false; + + System.out.println("Moving to 100, 100"); + Display.setLocation(x, y); // Create the actual window try { @@ -65,9 +73,10 @@ System.out.println("Window created"); System.out.println(Display.getDisplayMode().getHeight() + ", " + Display.getDisplayMode().getWidth() + ", " + Display.getTitle()); - + // wait for user to close window - while(!Display.isCloseRequested()) { + while(!Display.isCloseRequested()) { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); Display.update(); try { Thread.sleep(100); @@ -78,6 +87,31 @@ if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { break; } + + if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { + Display.setLocation(x -= 10, y); + } + + if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { + Display.setLocation(x += 10, y); + } + + if(Keyboard.isKeyDown(Keyboard.KEY_UP)) { + Display.setLocation(x, y -= 10); + } + + if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { + Display.setLocation(x, y += 10); + } + + if(Keyboard.isKeyDown(Keyboard.KEY_F)) { + try { + Display.setFullscreen(fullscreen = !fullscreen); + } catch (LWJGLException lwjgle) { + lwjgle.printStackTrace(); + } + } + } // nuke window and get out |
|
From: Brian M. <ma...@us...> - 2004-09-15 17:07:23
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18511/java/org/lwjgl/opengl Modified Files: Display.java Log Message: support for setLocation Index: Display.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Display.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Display.java 20 Aug 2004 06:22:54 -0000 1.22 +++ Display.java 15 Sep 2004 17:07:04 -0000 1.23 @@ -75,14 +75,14 @@ /** Timer for sync() */ private static long timeNow, timeThen; -// /** X coordinate of the window */ -// private static int x; + /** X coordinate of the window */ + private static int x; /** * Y coordinate of the window. Y in window coordinates is from the top of the display down, * unlike GL, where it is typically at the bottom of the display. */ -// private static int y; + private static int y; /** Title of the window (never null) */ private static String title = "Game"; @@ -177,13 +177,15 @@ * A native context must exist, and it will be attached to the window. */ private static void createWindow() throws LWJGLException { - nCreateWindow(current_mode, fullscreen); + x = Math.max(0, Math.min(initial_mode.getWidth() - current_mode.getWidth(), x)); + y = Math.max(0, Math.min(initial_mode.getHeight() - current_mode.getHeight(), y)); + nCreateWindow(current_mode, fullscreen, (fullscreen) ? 0 : x, (fullscreen) ? 0 : y); nSetTitle(title); initControls(); nSetVSyncEnabled(vsync); } - private static native void nCreateWindow(DisplayMode mode, boolean fullscreen) throws LWJGLException; + private static native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; private static void destroyWindow() { // Automatically destroy keyboard, mouse, and controller @@ -329,21 +331,17 @@ /** * @return the X coordinate of the window (always 0 for fullscreen) */ -/* public static int getX() { - if (!isCreated()) - throw new IllegalStateException("Cannot get X on uncreated window"); - return x; - } -*/ + /*public static int getX() { + return (fullscreen) ? 0 : x; + }*/ + /** * @return the Y coordinate of the window (always 0 for fullscreen) */ -/* public static int getY() { - if (!isCreated()) - throw new IllegalStateException("Cannot get Y on uncreated window"); - return y; - } -*/ + /*public static int getY() { + return (fullscreen) ? 0 : y; + }*/ + /** * @return the title of the window @@ -370,10 +368,11 @@ return; destroyWindow(); try { - if (fullscreen) + if (fullscreen) { switchDisplayMode(); - else + } else { resetDisplayMode(); + } createWindow(); } catch (LWJGLException e) { destroyContext(); @@ -697,30 +696,28 @@ private static native void nSetVSyncEnabled(boolean sync); -// /** -// * Set the window's location. This is a no-op on fullscreen windows. -// * The window is clamped to remain entirely on the screen. If you attempt -// * to position the window such that it would extend off the screen, the window -// * is simply placed as close to the edge as possible. -// * @param x, y The new window location -// */ -// public static void setLocation(int x, int y) { -// if (!isCreated()) -// throw new IllegalStateException("Cannot move uncreated window"); -// if (fullscreen) { -// return; -// } -// Display.x = Math.max(0, Math.min(Display.getWidth() - Display.width, x)); -// Display.y = Math.max(0, Math.min(Display.getHeight() - Display.height, y)); -// nReshape(Display.x, Display.y, Display.width, Display.height); -// } -// -// -// /** -// * Native method to reshape the window -// * @param x, y The new window location -// * @param width, height The new window dimensions -// */ -// private static native void nReshape(int x, int y, int width, int height); + /** + * Set the window's location. This is a no-op on fullscreen windows. + * The window is clamped to remain entirely on the screen. If you attempt + * to position the window such that it would extend off the screen, the window + * is simply placed as close to the edge as possible. + * @param x, y The new window location + */ + public static void setLocation(int x, int y) { + if (fullscreen) { + return; + } + + // offset if already created + if(isCreated()) { + x = Math.max(0, Math.min(initial_mode.getWidth() - current_mode.getWidth(), x)); + y = Math.max(0, Math.min(initial_mode.getHeight() - current_mode.getHeight(), y)); + nReshape(x, y, current_mode.getWidth(), current_mode.getHeight()); + } + // cache position + Display.x = x; + Display.y = y; + } + private static native void nReshape(int x, int y, int width, int height); } |
|
From: Brian M. <ma...@us...> - 2004-09-15 17:04:44
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17950 Modified Files: org_lwjgl_openal_eax_EAXBufferProperties.c org_lwjgl_openal_eax_EAXListenerProperties.c Log Message: updated to c code Index: org_lwjgl_openal_eax_EAXListenerProperties.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_openal_eax_EAXListenerProperties.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_openal_eax_EAXListenerProperties.c 10 Sep 2004 08:13:48 -0000 1.1 +++ org_lwjgl_openal_eax_EAXListenerProperties.c 15 Sep 2004 17:04:26 -0000 1.2 @@ -61,62 +61,62 @@ jfieldID field; //get class/fields - listener_class = env->FindClass("org/lwjgl/openal/eax/EAXListenerProperties"); + listener_class = (*env)->FindClass(env, "org/lwjgl/openal/eax/EAXListenerProperties"); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "room_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoom)); + field = (*env)->GetStaticFieldID(env, listener_class, "room_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoom)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "roomHF_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoomHF)); + field = (*env)->GetStaticFieldID(env, listener_class, "roomHF_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, lRoomHF)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "roomRolloffFactor_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flRoomRolloffFactor)); + field = (*env)->GetStaticFieldID(env, listener_class, "roomRolloffFactor_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flRoomRolloffFactor)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "decayTime_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayTime)); + field = (*env)->GetStaticFieldID(env, listener_class, "decayTime_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayTime)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "decayHFRatio_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayHFRatio)); + field = (*env)->GetStaticFieldID(env, listener_class, "decayHFRatio_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flDecayHFRatio)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "reflections_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReflections)); + field = (*env)->GetStaticFieldID(env, listener_class, "reflections_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReflections)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "reflectionsDelay_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReflectionsDelay)); + field = (*env)->GetStaticFieldID(env, listener_class, "reflectionsDelay_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReflectionsDelay)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "reverb_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReverb)); + field = (*env)->GetStaticFieldID(env, listener_class, "reverb_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, lReverb)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "reverbDelay_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReverbDelay)); + field = (*env)->GetStaticFieldID(env, listener_class, "reverbDelay_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flReverbDelay)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "environment_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwEnvironment)); + field = (*env)->GetStaticFieldID(env, listener_class, "environment_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwEnvironment)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "environmentSize_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentSize)); + field = (*env)->GetStaticFieldID(env, listener_class, "environmentSize_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentSize)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "environmentDiffusion_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentDiffusion)); + field = (*env)->GetStaticFieldID(env, listener_class, "environmentDiffusion_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flEnvironmentDiffusion)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "airAbsorptionHF_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, flAirAbsorptionHF)); + field = (*env)->GetStaticFieldID(env, listener_class, "airAbsorptionHF_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, flAirAbsorptionHF)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "flags_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwFlags)); + field = (*env)->GetStaticFieldID(env, listener_class, "flags_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXLISTENERPROPERTIES, dwFlags)); #endif } Index: org_lwjgl_openal_eax_EAXBufferProperties.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_openal_eax_EAXBufferProperties.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- org_lwjgl_openal_eax_EAXBufferProperties.c 10 Sep 2004 08:13:48 -0000 1.1 +++ org_lwjgl_openal_eax_EAXBufferProperties.c 15 Sep 2004 17:04:26 -0000 1.2 @@ -60,58 +60,58 @@ jfieldID field; //get class/fields - listener_class = env->FindClass("org/lwjgl/openal/eax/EAXBufferProperties"); + listener_class = (*env)->FindClass(env, "org/lwjgl/openal/eax/EAXBufferProperties"); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "direct_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirect)); + field = (*env)->GetStaticFieldID(env, listener_class, "direct_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirect)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "directHF_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirectHF)); + field = (*env)->GetStaticFieldID(env, listener_class, "directHF_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lDirectHF)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "room_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoom)); + field = (*env)->GetStaticFieldID(env, listener_class, "room_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoom)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "roomHF_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoomHF)); + field = (*env)->GetStaticFieldID(env, listener_class, "roomHF_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lRoomHF)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "roomRolloffFactor_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flRoomRolloffFactor)); + field = (*env)->GetStaticFieldID(env, listener_class, "roomRolloffFactor_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, flRoomRolloffFactor)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "obstruction_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lObstruction)); + field = (*env)->GetStaticFieldID(env, listener_class, "obstruction_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lObstruction)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "obstructionLFRatio_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flObstructionLFRatio)); + field = (*env)->GetStaticFieldID(env, listener_class, "obstructionLFRatio_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, flObstructionLFRatio)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "occlusion_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOcclusion)); + field = (*env)->GetStaticFieldID(env, listener_class, "occlusion_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOcclusion)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "occlusionLFRatio_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionLFRatio)); + field = (*env)->GetStaticFieldID(env, listener_class, "occlusionLFRatio_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionLFRatio)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "occlusionRoomRatio_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionRoomRatio)); + field = (*env)->GetStaticFieldID(env, listener_class, "occlusionRoomRatio_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, flOcclusionRoomRatio)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "outsideVolumeHF_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOutsideVolumeHF)); + field = (*env)->GetStaticFieldID(env, listener_class, "outsideVolumeHF_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, lOutsideVolumeHF)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "airAbsorptionFactor_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, flAirAbsorptionFactor)); + field = (*env)->GetStaticFieldID(env, listener_class, "airAbsorptionFactor_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, flAirAbsorptionFactor)); //set environmentDiffusion_offset - field = env->GetStaticFieldID(listener_class, "flags_offset", "I"); - env->SetStaticIntField(listener_class, field, offsetof(EAXBUFFERPROPERTIES, dwFlags)); + field = (*env)->GetStaticFieldID(env, listener_class, "flags_offset", "I"); + (*env)->SetStaticIntField(env, listener_class, field, offsetof(EAXBUFFERPROPERTIES, dwFlags)); #endif } |
|
From: Brian M. <ma...@us...> - 2004-09-15 16:07:52
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5066 Modified Files: GLImpl.java Log Message: fix imports Index: GLImpl.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/util/GLImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- GLImpl.java 9 Sep 2004 23:50:11 -0000 1.4 +++ GLImpl.java 15 Sep 2004 16:07:42 -0000 1.5 @@ -31,9 +31,12 @@ */ package org.lwjgl.util; -import org.lwjgl.opengl.GL20; - -import java.nio.*; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; /** * $Id$ |