|
From: <eli...@us...> - 2006-05-18 12:11:54
|
Revision: 2339 Author: elias_naur Date: 2006-05-18 05:11:37 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2339&view=rev Log Message: ----------- Win32: Updated various native string handling to use the new _s "secure" variants. Modified Paths: -------------- trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/win32/display.c trunk/LWJGL/src/native/win32/org_lwjgl_Sys.c Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2006-05-18 11:43:52 UTC (rev 2338) +++ trunk/LWJGL/src/native/common/common_tools.c 2006-05-18 12:11:37 UTC (rev 2339) @@ -83,7 +83,7 @@ char buffer[BUFFER_SIZE]; jstring str; #ifdef WIN32 - _vsnprintf(buffer, BUFFER_SIZE, format, ap); + vsnprintf_s(buffer, BUFFER_SIZE, _TRUNCATE, format, ap); #else vsnprintf(buffer, BUFFER_SIZE, format, ap); #endif Modified: trunk/LWJGL/src/native/win32/display.c =================================================================== --- trunk/LWJGL/src/native/win32/display.c 2006-05-18 11:43:52 UTC (rev 2338) +++ trunk/LWJGL/src/native/win32/display.c 2006-05-18 12:11:37 UTC (rev 2339) @@ -263,9 +263,11 @@ jstring getVersion(JNIEnv * env, char *driver) { +#define BUFFER_SIZE 1024 jstring ret = NULL; - TCHAR driverDLL[256] = "\0"; + const char *dll_ext = ".dll"; + TCHAR driverDLL[BUFFER_SIZE] = "\0"; DWORD var = 0; DWORD dwInfoSize; LPVOID lpInfoBuff; @@ -274,8 +276,8 @@ if (driver == NULL) { return NULL; } - strcat(driverDLL, driver); - strcat(driverDLL, ".dll"); + strncat_s(driverDLL, BUFFER_SIZE, driver, strlen(driver)); + strncat_s(driverDLL, BUFFER_SIZE, dll_ext, strlen(dll_ext)); dwInfoSize = GetFileVersionInfoSize(driverDLL, &var); lpInfoBuff = malloc(dwInfoSize); bRetval = GetFileVersionInfo(driverDLL, 0, dwInfoSize, lpInfoBuff); @@ -286,11 +288,11 @@ UINT uiLen = 0; bRetval = VerQueryValue(lpInfoBuff, TEXT("\\"), (void **) &fxdFileInfo, &uiLen); if (bRetval != 0) { - TCHAR version[256]; - TCHAR ms[10], ls[10]; - sprintf(ms, "%d.%d\0", fxdFileInfo->dwProductVersionMS >> 16, fxdFileInfo->dwProductVersionMS & 0xFFFF); - sprintf(ls, "%d.%d\0", fxdFileInfo->dwProductVersionLS >> 16, fxdFileInfo->dwProductVersionLS & 0xFFFF); - sprintf(version, "%s.%s\0", ms, ls); + TCHAR version[BUFFER_SIZE]; + TCHAR ms[BUFFER_SIZE], ls[BUFFER_SIZE]; + _snprintf_s(ms, BUFFER_SIZE, _TRUNCATE, "%d.%d\0", fxdFileInfo->dwProductVersionMS >> 16, fxdFileInfo->dwProductVersionMS & 0xFFFF); + _snprintf_s(ls, BUFFER_SIZE, _TRUNCATE, "%d.%d\0", fxdFileInfo->dwProductVersionLS >> 16, fxdFileInfo->dwProductVersionLS & 0xFFFF); + _snprintf_s(version, BUFFER_SIZE, _TRUNCATE, "%s.%s\0", ms, ls); ret = NewStringNative(env, version); } } Modified: trunk/LWJGL/src/native/win32/org_lwjgl_Sys.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_Sys.c 2006-05-18 11:43:52 UTC (rev 2338) +++ trunk/LWJGL/src/native/win32/org_lwjgl_Sys.c 2006-05-18 12:11:37 UTC (rev 2339) @@ -101,15 +101,17 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_NativeSysImplementation_openURL (JNIEnv * env, jobject ignored, jstring url) { +#define BUFFER_SIZE 1024 + const char *std_args = "rundll32 url.dll,FileProtocolHandler "; STARTUPINFO si; PROCESS_INFORMATION pi; char * urlString = GetStringNativeChars(env, url); - char command[256]; - strcpy(command, ""); - strcat(command, "rundll32 url.dll,FileProtocolHandler "); - strncat(command, urlString, 200); // Prevent buffer overflow + char command[BUFFER_SIZE]; + strncpy_s(command, BUFFER_SIZE, "", 1); + strncat_s(command, BUFFER_SIZE, std_args, _TRUNCATE); + strncat_s(command, BUFFER_SIZE, urlString, _TRUNCATE); free(urlString); ZeroMemory( &si, sizeof(si) ); @@ -140,8 +142,6 @@ return JNI_TRUE; } - - const void * getClipboard(int type) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-10 20:43:19
|
Revision: 2360 Author: elias_naur Date: 2006-06-10 13:42:26 -0700 (Sat, 10 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2360&view=rev Log Message: ----------- Removed Keyboard.isStateKeySet() - it is easily replaced by Toolkit.getLockingKeyState() Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-06-10 19:46:28 UTC (rev 2359) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-06-10 20:42:26 UTC (rev 2360) @@ -191,10 +191,10 @@ public static final int KEY_POWER = 0xDE; public static final int KEY_SLEEP = 0xDF; - public static final int STATE_ON = 0; +/* public static final int STATE_ON = 0; public static final int STATE_OFF = 1; public static final int STATE_UNKNOWN = 2; - +*/ public static final int KEYBOARD_SIZE = 256; /** Buffer size in events */ @@ -334,7 +334,6 @@ * character for that event. * * @see org.lwjgl.input.Keyboard#isKeyDown(int key) - * @see org.lwjgl.input.Keyboard#isStateKeySet(int key) * @see org.lwjgl.input.Keyboard#next() * @see org.lwjgl.input.Keyboard#getEventKey() * @see org.lwjgl.input.Keyboard#getEventKeyState() @@ -371,12 +370,12 @@ * @param key State key to test (KEY_CAPITAL | KEY_NUMLOCK | KEY_SYSRQ) * @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown */ - public static int isStateKeySet(int key) { +/* public static int isStateKeySet(int key) { if (!created) throw new IllegalStateException("Keyboard must be created before you can query key state"); return Display.getImplementation().isStateKeySet(key); } - +*/ /** * Gets a key's name * @param key The key Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-06-10 19:46:28 UTC (rev 2359) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-06-10 20:42:26 UTC (rev 2360) @@ -203,7 +203,7 @@ */ int readKeyboard(IntBuffer buffer, int buffer_position); - int isStateKeySet(int key); +// int isStateKeySet(int key); /** Native cursor handles */ Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-06-10 19:46:28 UTC (rev 2359) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-06-10 20:42:26 UTC (rev 2360) @@ -625,10 +625,10 @@ } private static native int nReadKeyboard(IntBuffer buffer, int buffer_position); - public int isStateKeySet(int key) { +/* public int isStateKeySet(int key) { return Keyboard.STATE_UNKNOWN; } - +*/ private static native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-06-10 19:46:28 UTC (rev 2359) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-06-10 20:42:26 UTC (rev 2360) @@ -413,7 +413,7 @@ return keyboard_queue.copyEvents(buffer); } - public int isStateKeySet(int key) { +/* public int isStateKeySet(int key) { int awt_key; switch (key) { case Keyboard.KEY_CAPITAL: @@ -436,7 +436,7 @@ return Keyboard.STATE_UNKNOWN; } } - +*/ /** Native cursor handles */ public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-10 19:46:28 UTC (rev 2359) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-10 20:42:26 UTC (rev 2360) @@ -164,7 +164,7 @@ } private native int nReadKeyboard(IntBuffer buffer, int buffer_position); - public native int isStateKeySet(int key); +// public native int isStateKeySet(int key); public native ByteBuffer nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; Modified: trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c 2006-06-10 19:46:28 UTC (rev 2359) +++ trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c 2006-06-10 20:42:26 UTC (rev 2360) @@ -277,7 +277,7 @@ return num_events; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_isStateKeySet(JNIEnv *env, jobject self, jint key) +/*JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_isStateKeySet(JNIEnv *env, jobject self, jint key) { int state = org_lwjgl_input_Keyboard_STATE_UNKNOWN; switch(key) { @@ -293,4 +293,4 @@ } return state; -} +}*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-12 13:29:09
|
Revision: 2362 Author: elias_naur Date: 2006-06-12 06:28:56 -0700 (Mon, 12 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2362&view=rev Log Message: ----------- Windows implementation of floating point pixel formats Modified Paths: -------------- trunk/LWJGL/src/native/linux/context.c trunk/LWJGL/src/native/win32/context.c trunk/LWJGL/src/native/win32/extgl_wgl.c trunk/LWJGL/src/native/win32/extgl_wgl.h Modified: trunk/LWJGL/src/native/linux/context.c =================================================================== --- trunk/LWJGL/src/native/linux/context.c 2006-06-12 13:01:05 UTC (rev 2361) +++ trunk/LWJGL/src/native/linux/context.c 2006-06-12 13:28:56 UTC (rev 2362) @@ -271,7 +271,7 @@ throwException(env, "Samples > 0 specified but there's no support for GLX_ARB_multisample"); return false; } - bool floating_point = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); if (floating_point && !extension_flags.GLX_ARB_fbconfig_float) { throwException(env, "Floating point specified but there's no support for GLX_ARB_fbconfig_float"); return false; Modified: trunk/LWJGL/src/native/win32/context.c =================================================================== --- trunk/LWJGL/src/native/win32/context.c 2006-06-12 13:01:05 UTC (rev 2361) +++ trunk/LWJGL/src/native/win32/context.c 2006-06-12 13:28:56 UTC (rev 2362) @@ -183,6 +183,8 @@ int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); + bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + int pixel_type = floating_point ? WGL_TYPE_RGBA_FLOAT_ARB : WGL_TYPE_RGBA_ARB; int iPixelFormat; unsigned int num_formats_returned; attrib_list_t attrib_list; @@ -200,7 +202,7 @@ } if (!getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL")) putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB); - putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, WGL_TYPE_RGBA_ARB); + putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type); putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE); putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE); putAttrib(&attrib_list, WGL_COLOR_BITS_ARB); putAttrib(&attrib_list, bpp); @@ -217,7 +219,7 @@ putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE); putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers); // Assume caller checked extension availability - if ( pixelFormatCaps != NULL ) { + if (pixelFormatCaps != NULL) { pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps); pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps); @@ -358,6 +360,7 @@ int pixel_format_id; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); + bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); bool use_arb_selection = samples > 0 || pbuffer || pixelFormatCaps != NULL; pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer); if (use_arb_selection) { @@ -392,6 +395,12 @@ throwException(env, "No support for WGL_ARB_multisample"); return -1; } + if (floating_point && !extensions.WGL_ARB_pixel_format_float) { + wglMakeCurrent(saved_current_hdc, saved_current_hglrc); + wglDeleteContext(dummy_hglrc); + throwException(env, "No support for WGL_ARB_pixel_format_float"); + return -1; + } if (pixelFormatCaps != NULL && !extensions.WGL_ARB_render_texture) { wglMakeCurrent(saved_current_hdc, saved_current_hglrc); wglDeleteContext(dummy_hglrc); Modified: trunk/LWJGL/src/native/win32/extgl_wgl.c =================================================================== --- trunk/LWJGL/src/native/win32/extgl_wgl.c 2006-06-12 13:01:05 UTC (rev 2361) +++ trunk/LWJGL/src/native/win32/extgl_wgl.c 2006-06-12 13:28:56 UTC (rev 2362) @@ -133,6 +133,7 @@ extensions->WGL_ARB_buffer_region = WGLQueryExtension(extensions, "WGL_ARB_buffer_region"); extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read"); extensions->WGL_ARB_multisample = WGLQueryExtension(extensions, "WGL_ARB_multisample"); + extensions->WGL_ARB_pixel_format_float = WGLQueryExtension(extensions, "WGL_ARB_pixel_format_float"); extensions->WGL_ARB_pbuffer = WGLQueryExtension(extensions, "WGL_ARB_pbuffer"); extensions->WGL_ARB_pixel_format = WGLQueryExtension(extensions, "WGL_ARB_pixel_format"); extensions->WGL_ARB_render_texture = WGLQueryExtension(extensions, "WGL_ARB_render_texture"); Modified: trunk/LWJGL/src/native/win32/extgl_wgl.h =================================================================== --- trunk/LWJGL/src/native/win32/extgl_wgl.h 2006-06-12 13:01:05 UTC (rev 2361) +++ trunk/LWJGL/src/native/win32/extgl_wgl.h 2006-06-12 13:28:56 UTC (rev 2362) @@ -160,6 +160,12 @@ #define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 +/*-------------------------------------------------------------------*/ +/*------------WGL_ARB_pixel_format_float ----------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 + typedef struct { bool WGL_ARB_buffer_region; bool WGL_ARB_extensions_string; @@ -172,6 +178,7 @@ bool WGL_EXT_swap_control; bool WGL_NV_render_depth_texture; bool WGL_NV_render_texture_rectangle; + bool WGL_ARB_pixel_format_float; wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; wglGetExtensionsStringARBPROC wglGetExtensionsStringARB; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-15 15:04:19
|
Revision: 2370 Author: elias_naur Date: 2006-06-15 08:03:29 -0700 (Thu, 15 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2370&view=rev Log Message: ----------- windows: Add support for WGL_ATI_pixel_format_float Modified Paths: -------------- trunk/LWJGL/src/native/win32/context.c trunk/LWJGL/src/native/win32/context.h trunk/LWJGL/src/native/win32/extgl_wgl.c trunk/LWJGL/src/native/win32/extgl_wgl.h trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c Modified: trunk/LWJGL/src/native/win32/context.c =================================================================== --- trunk/LWJGL/src/native/win32/context.c 2006-06-15 13:42:48 UTC (rev 2369) +++ trunk/LWJGL/src/native/win32/context.c 2006-06-15 15:03:29 UTC (rev 2370) @@ -173,7 +173,25 @@ return new_hwnd; } -static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) { +static int convertToBPE(int bpp) { + int bpe; + switch (bpp) { + case 0: + bpe = 0; + break; + case 32: + case 24: + bpe = 8; + break; + case 16: /* Fall through */ + default: + bpe = 4; + break; + } + return bpe; +} + +static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); @@ -183,7 +201,6 @@ int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); - bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); int pixel_type = floating_point ? WGL_TYPE_RGBA_FLOAT_ARB : WGL_TYPE_RGBA_ARB; int iPixelFormat; unsigned int num_formats_returned; @@ -192,6 +209,7 @@ jlong pixelFormatCapsSize; BOOL result; jlong i; + int bpe = convertToBPE(bpp); initAttribList(&attrib_list); if (window) { @@ -205,7 +223,9 @@ putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, pixel_type); putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE); putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE); - putAttrib(&attrib_list, WGL_COLOR_BITS_ARB); putAttrib(&attrib_list, bpp); + putAttrib(&attrib_list, WGL_RED_BITS_ARB); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, WGL_GREEN_BITS_ARB); putAttrib(&attrib_list, bpe); + putAttrib(&attrib_list, WGL_BLUE_BITS_ARB); putAttrib(&attrib_list, bpe); putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha); putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth); putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil); @@ -235,20 +255,20 @@ return iPixelFormat; } -static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { +static int findPixelFormatARB(JNIEnv *env, HDC hdc, WGLExtensions *extensions, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { int bpp; int iPixelFormat; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); if (use_hdc_bpp) { bpp = GetDeviceCaps(hdc, BITSPIXEL); - iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); + iPixelFormat = findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer, floating_point); if (iPixelFormat == -1) bpp = 16; else return iPixelFormat; } else bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); - return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); + return findPixelFormatARBFromBPP(env, hdc, extensions, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer, floating_point); } /* @@ -352,7 +372,7 @@ return findPixelFormatFromBPP(env, hdc, pixel_format, bpp, double_buffer); } -int findPixelFormatOnDC(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { +static int findPixelFormatOnDC(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { HGLRC dummy_hglrc; HDC saved_current_hdc; HGLRC saved_current_hglrc; @@ -360,7 +380,6 @@ int pixel_format_id; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); bool use_arb_selection = samples > 0 || floating_point || pbuffer || pixelFormatCaps != NULL; pixel_format_id = findPixelFormatDefault(env, hdc, pixel_format, use_hdc_bpp, double_buffer); if (pixel_format_id != -1 && use_arb_selection) { @@ -395,10 +414,15 @@ throwException(env, "No support for WGL_ARB_multisample"); return -1; } - if (floating_point && !extensions.WGL_ARB_pixel_format_float) { + /* + * Apparently, some drivers don't report WGL_ARB_pixel_format_float + * even though GL_ARB_color_buffer_float and WGL_ATI_color_format_float + * is supported. + */ + if (floating_point && !(extensions.WGL_ARB_pixel_format_float || extensions.WGL_ATI_pixel_format_float)) { wglMakeCurrent(saved_current_hdc, saved_current_hglrc); wglDeleteContext(dummy_hglrc); - throwException(env, "No support for WGL_ARB_pixel_format_float"); + throwException(env, "No support for WGL_ARB_pixel_format_float nor WGL_ATI_pixel_format_float"); return -1; } if (pixelFormatCaps != NULL && !extensions.WGL_ARB_render_texture) { @@ -407,7 +431,7 @@ throwException(env, "No support for WGL_ARB_render_texture"); return -1; } - pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer); + pixel_format_id = findPixelFormatARB(env, hdc, &extensions, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); wglMakeCurrent(saved_current_hdc, saved_current_hglrc); wglDeleteContext(dummy_hglrc); } @@ -434,7 +458,7 @@ return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false); } -int findPixelFormat(JNIEnv *env, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { +int findPixelFormat(JNIEnv *env, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point) { HWND dummy_hwnd; HDC dummy_hdc; int pixel_format_id; @@ -444,7 +468,7 @@ return -1; } dummy_hdc = GetDC(dummy_hwnd); - pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer); + pixel_format_id = findPixelFormatOnDC(env, dummy_hdc, pixel_format, pixelFormatCaps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); closeWindow(&dummy_hwnd, &dummy_hdc); return pixel_format_id; } Modified: trunk/LWJGL/src/native/win32/context.h =================================================================== --- trunk/LWJGL/src/native/win32/context.h 2006-06-15 13:42:48 UTC (rev 2369) +++ trunk/LWJGL/src/native/win32/context.h 2006-06-15 15:03:29 UTC (rev 2370) @@ -94,6 +94,6 @@ */ extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated); -extern int findPixelFormat(JNIEnv *env, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); +extern int findPixelFormat(JNIEnv *env, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point); #endif Modified: trunk/LWJGL/src/native/win32/extgl_wgl.c =================================================================== --- trunk/LWJGL/src/native/win32/extgl_wgl.c 2006-06-15 13:42:48 UTC (rev 2369) +++ trunk/LWJGL/src/native/win32/extgl_wgl.c 2006-06-15 15:03:29 UTC (rev 2370) @@ -134,6 +134,7 @@ extensions->WGL_ARB_make_current_read = WGLQueryExtension(extensions, "WGL_ARB_make_current_read"); extensions->WGL_ARB_multisample = WGLQueryExtension(extensions, "WGL_ARB_multisample"); extensions->WGL_ARB_pixel_format_float = WGLQueryExtension(extensions, "WGL_ARB_pixel_format_float"); + extensions->WGL_ATI_pixel_format_float = WGLQueryExtension(extensions, "WGL_ATI_pixel_format_float"); extensions->WGL_ARB_pbuffer = WGLQueryExtension(extensions, "WGL_ARB_pbuffer"); extensions->WGL_ARB_pixel_format = WGLQueryExtension(extensions, "WGL_ARB_pixel_format"); extensions->WGL_ARB_render_texture = WGLQueryExtension(extensions, "WGL_ARB_render_texture"); Modified: trunk/LWJGL/src/native/win32/extgl_wgl.h =================================================================== --- trunk/LWJGL/src/native/win32/extgl_wgl.h 2006-06-15 13:42:48 UTC (rev 2369) +++ trunk/LWJGL/src/native/win32/extgl_wgl.h 2006-06-15 15:03:29 UTC (rev 2370) @@ -166,6 +166,12 @@ #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +/*-------------------------------------------------------------------*/ +/*------------WGL_ATI_pixel_format_float ----------------------------*/ +/*-------------------------------------------------------------------*/ + +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 + typedef struct { bool WGL_ARB_buffer_region; bool WGL_ARB_extensions_string; @@ -179,6 +185,7 @@ bool WGL_NV_render_depth_texture; bool WGL_NV_render_texture_rectangle; bool WGL_ARB_pixel_format_float; + bool WGL_ATI_pixel_format_float; wglGetExtensionsStringEXTPROC wglGetExtensionsStringEXT; wglGetExtensionsStringARBPROC wglGetExtensionsStringARB; Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c 2006-06-15 13:42:48 UTC (rev 2369) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c 2006-06-15 15:03:29 UTC (rev 2370) @@ -62,7 +62,7 @@ HGLRC saved_context; int pixel_format_id; - pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixelFormatCaps, false, true, false, false); + pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixelFormatCaps, false, true, false, false, false); if (pixel_format_id == -1) return false; dummy_hwnd = createDummyWindow(origin_x, origin_y); @@ -137,13 +137,15 @@ const int *pBufferAttribs_ptr; Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); int pixel_format_id; + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); if ( pBufferAttribs != NULL ) { pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs); } else { pBufferAttribs_ptr = NULL; } - pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixelFormatCaps, false, false, true, false); + pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixelFormatCaps, false, false, true, false, floating_point); if (pixel_format_id == -1) return; if (!getExtensions(env, &extensions, pixel_format, pixelFormatCaps)) Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c 2006-06-15 13:42:48 UTC (rev 2369) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c 2006-06-15 15:03:29 UTC (rev 2370) @@ -50,7 +50,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PeerInfo_nChoosePixelFormat (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) { Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - int pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer); + jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); + bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + int pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); if (pixel_format_id == -1) return; // Let it throw This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-23 16:45:57
|
Revision: 2385 Author: elias_naur Date: 2006-06-23 09:45:21 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2385&view=rev Log Message: ----------- Windows: Cleanup of native input code Modified Paths: -------------- trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c trunk/LWJGL/src/native/win32/org_lwjgl_input_Mouse.c Modified: trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c 2006-06-23 08:16:27 UTC (rev 2384) +++ trunk/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.c 2006-06-23 16:45:21 UTC (rev 2385) @@ -69,34 +69,28 @@ return; } - // Check to see if we're already initialized - if (lpdiKeyboard != NULL) { - throwException(env, "Keyboard already created."); - return; - } - // Create a keyboard device - if (IDirectInput_CreateDevice(lpdi, &GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) { + if (IDirectInput_CreateDevice(lpdi, &GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) { throwException(env, "Failed to create keyboard."); return; } - if (IDirectInputDevice_SetCooperativeLevel(lpdiKeyboard, getCurrentHWND(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { + if (IDirectInputDevice_SetCooperativeLevel(lpdiKeyboard, getCurrentHWND(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { throwException(env, "Failed to set keyboard cooperation mode."); return; } // Tell 'em wot format to be in (the default "you are a mouse and keyboard" format) - IDirectInputDevice_SetDataFormat(lpdiKeyboard, &c_dfDIKeyboard); + IDirectInputDevice_SetDataFormat(lpdiKeyboard, &c_dfDIKeyboard); dipropdw.diph.dwSize = sizeof(DIPROPDWORD); dipropdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipropdw.diph.dwObj = 0; dipropdw.diph.dwHow = DIPH_DEVICE; dipropdw.dwData = KEYBOARD_BUFFER_SIZE; - IDirectInputDevice_SetProperty(lpdiKeyboard, DIPROP_BUFFERSIZE, &dipropdw.diph); + IDirectInputDevice_SetProperty(lpdiKeyboard, DIPROP_BUFFERSIZE, &dipropdw.diph); - ret = IDirectInputDevice_Acquire(lpdiKeyboard); + ret = IDirectInputDevice_Acquire(lpdiKeyboard); if(FAILED(ret)) { printfDebugJava(env, "Failed to acquire keyboard"); } @@ -120,14 +114,14 @@ { // Release keyboard if (lpdiKeyboard != NULL) { - IDirectInputDevice_Unacquire(lpdiKeyboard); - IDirectInputDevice_Release(lpdiKeyboard); + IDirectInputDevice_Unacquire(lpdiKeyboard); + IDirectInputDevice_Release(lpdiKeyboard); lpdiKeyboard = NULL; } // Release DirectInput if (lpdi != NULL) { printfDebugJava(env, "Destroying directinput"); - IDirectInput_Release(lpdi); + IDirectInput_Release(lpdi); lpdi = NULL; } } @@ -140,50 +134,32 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nPollKeyboard (JNIEnv * env, jobject self, jobject buffer) { - HRESULT ret; - void *keyboardBuffer; - jlong buffer_size; - do { - ret = IDirectInputDevice_Acquire(lpdiKeyboard); - if (ret == DIERR_INPUTLOST) { - printf("Input lost\n"); - return; - } else if (ret == DIERR_NOTACQUIRED) { - printf("not acquired\n"); - return; - } else if (ret == DIERR_INVALIDPARAM) { - printf("invalid parameter\n"); - return; - } else if (ret == DIERR_NOTBUFFERED) { - printf("not buffered\n"); - return; - } else if (ret == DIERR_NOTINITIALIZED) { - printf("not inited\n"); - return; - } else if (ret != DI_OK && ret != S_FALSE) { - //printf("unknown keyboard error\n"); - return; - } - } while (ret != DI_OK && ret != S_FALSE); + void *keyboardBuffer; + jlong buffer_size; + HRESULT ret = IDirectInputDevice_Acquire(lpdiKeyboard); + if (ret != DI_OK && ret != S_FALSE) { +// printfDebugJava(env, "Failed to acquire keyboard (%x)\n", ret); + return; + } - keyboardBuffer = (void *)(*env)->GetDirectBufferAddress(env, buffer); - buffer_size = (*env)->GetDirectBufferCapacity(env, buffer); - IDirectInputDevice_GetDeviceState(lpdiKeyboard, (DWORD)buffer_size, keyboardBuffer); + keyboardBuffer = (void *)(*env)->GetDirectBufferAddress(env, buffer); + buffer_size = (*env)->GetDirectBufferCapacity(env, buffer); + IDirectInputDevice_GetDeviceState(lpdiKeyboard, (DWORD)buffer_size, keyboardBuffer); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_nReadKeyboard (JNIEnv * env, jobject self, jobject buffer_obj, jint buffer_position) { - UINT scan_code; - UINT virt_key; - bool key_down; - jint * buf; - jint ch_int; - int buffer_size; - int index = 0; - int event_size = 3; - DWORD current_di_event = 0; - DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE]; + UINT scan_code; + UINT virt_key; + bool key_down; + jint * buf; + jint ch_int; + int buffer_size; + int index = 0; + int event_size = 3; + DWORD current_di_event = 0; + DIDEVICEOBJECTDATA rgdod[KEYBOARD_BUFFER_SIZE]; wchar_t transBufUnicode[KEYBOARD_BUFFER_SIZE]; WORD transBufAscii[KEYBOARD_BUFFER_SIZE]; @@ -194,42 +170,42 @@ int num_chars; int num_events = 0; - ret = IDirectInputDevice_Acquire(lpdiKeyboard); + ret = IDirectInputDevice_Acquire(lpdiKeyboard); if (ret != DI_OK && ret != S_FALSE) return 0; - ret = IDirectInputDevice_GetDeviceData(lpdiKeyboard, - sizeof(DIDEVICEOBJECTDATA), - rgdod, - &num_di_events, - 0); + ret = IDirectInputDevice_GetDeviceData(lpdiKeyboard, + sizeof(DIDEVICEOBJECTDATA), + rgdod, + &num_di_events, + 0); if (ret == DI_OK) { - buf = buffer_position + (jint *)(*env)->GetDirectBufferAddress(env, buffer_obj); - buffer_size = ((int)(*env)->GetDirectBufferCapacity(env, buffer_obj))/sizeof(jint) - buffer_position; + buf = buffer_position + (jint *)(*env)->GetDirectBufferAddress(env, buffer_obj); + buffer_size = ((int)(*env)->GetDirectBufferCapacity(env, buffer_obj))/sizeof(jint) - buffer_position; while (index + event_size <= buffer_size && current_di_event < num_di_events) { num_events++; buf[index++] = (unsigned char) rgdod[current_di_event].dwOfs; buf[index++] = (unsigned char) rgdod[current_di_event].dwData; - key_down = (rgdod[current_di_event].dwData & 0x80) != 0; + key_down = (rgdod[current_di_event].dwData & 0x80) != 0; if (key_down) { - scan_code = rgdod[current_di_event].dwOfs; - virt_key = MapVirtualKey(scan_code, 1); + scan_code = rgdod[current_di_event].dwOfs; + virt_key = MapVirtualKey(scan_code, 1); if (virt_key != 0 && GetKeyboardState(state)) { // Mark key down in the scan code scan_code = scan_code & 0x7fff; if (useUnicode) { num_chars = ToUnicode(virt_key, - scan_code, - state, - transBufUnicode, - KEYBOARD_BUFFER_SIZE, 0); + scan_code, + state, + transBufUnicode, + KEYBOARD_BUFFER_SIZE, 0); } else { num_chars = ToAscii(virt_key, - scan_code, - state, - transBufAscii, - 0); + scan_code, + state, + transBufAscii, + 0); } if (num_chars > 0) { int current_char = 0; Modified: trunk/LWJGL/src/native/win32/org_lwjgl_input_Mouse.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_input_Mouse.c 2006-06-23 08:16:27 UTC (rev 2384) +++ trunk/LWJGL/src/native/win32/org_lwjgl_input_Mouse.c 2006-06-23 16:45:21 UTC (rev 2385) @@ -127,7 +127,7 @@ */ static bool CreateMouse(JNIEnv *env) { HRESULT hr; - hr = IDirectInput_CreateDevice(lpdi, &GUID_SysMouse, &mDIDevice, NULL); + hr = IDirectInput_CreateDevice(lpdi, &GUID_SysMouse, &mDIDevice, NULL); if FAILED(hr) { throwException(env, "CreateDevice failed"); return false; @@ -447,15 +447,6 @@ return DIENUM_CONTINUE; } -static int cap(int val, int min, int max) { - if (val < min) - return min; - else if (val > max) - return max; - else - return val; -} - /** * Updates the fields on the Mouse */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-26 14:05:52
|
Revision: 2387 Author: elias_naur Date: 2006-06-26 07:05:42 -0700 (Mon, 26 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2387&view=rev Log Message: ----------- Windows: moved closerequested from native to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-26 13:50:48 UTC (rev 2386) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-26 14:05:42 UTC (rev 2387) @@ -60,12 +60,39 @@ private final static int WM_MBUTTONDBLCLK = 0x0209; private final static int WM_MOUSEWHEEL = 0x020A; + private final static int WM_QUIT = 0x0012; + private final static int WM_SYSCOMMAND = 0x0112; + + private final static int SC_SIZE = 0xF000; + private final static int SC_MOVE = 0xF010; + private final static int SC_MINIMIZE = 0xF020; + private final static int SC_MAXIMIZE = 0xF030; + private final static int SC_NEXTWINDOW = 0xF040; + private final static int SC_PREVWINDOW = 0xF050; + private final static int SC_CLOSE = 0xF060; + private final static int SC_VSCROLL = 0xF070; + private final static int SC_HSCROLL = 0xF080; + private final static int SC_MOUSEMENU = 0xF090; + private final static int SC_KEYMENU = 0xF100; + private final static int SC_ARRANGE = 0xF110; + private final static int SC_RESTORE = 0xF120; + private final static int SC_TASKLIST = 0xF130; + private final static int SC_SCREENSAVE = 0xF140; + private final static int SC_HOTKEY = 0xF150; + private final static int SC_DEFAULT = 0xF160; + private final static int SC_MONITORPOWER = 0xF170; + private final static int SC_CONTEXTHELP = 0xF180; + private final static int SC_SEPARATOR = 0xF00F; + private static Win32DisplayPeerInfo peer_info; private static WindowsKeyboard keyboard; private static WindowsMouse mouse; + private static boolean close_requested; + public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { + close_requested = false; nCreateWindow(mode, fullscreen, x, y); peer_info.initDC(); } @@ -109,7 +136,11 @@ private native String nGetVersion(String driver); public native DisplayMode init() throws LWJGLException; public native void setTitle(String title); - public native boolean isCloseRequested(); + public boolean isCloseRequested() { + boolean saved = close_requested; + close_requested = false; + return saved; + } public native boolean isVisible(); public native boolean isActive(); public native boolean isDirty(); @@ -333,6 +364,23 @@ case WM_MBUTTONUP: handleMouseButton(2, 0); return true; + case WM_QUIT: + close_requested = true; + return true; + case WM_SYSCOMMAND: + switch ((int)wParam) { + case SC_KEYMENU: + case SC_MOUSEMENU: + case SC_SCREENSAVE: + case SC_MONITORPOWER: + return true; + case SC_CLOSE: + close_requested = true; + return true; + default: + break; + } + return false; default: return false; } Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-06-26 13:50:48 UTC (rev 2386) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-06-26 14:05:42 UTC (rev 2387) @@ -59,8 +59,6 @@ static bool did_maximize = false; // A flag to tell when a window // has recovered from minimized -static bool closerequested; - #define WINDOWCLASSNAME "LWJGL" bool getCurrentFullscreen() { @@ -136,24 +134,6 @@ setupCursorClipping(); switch (msg) { // disable screen saver and monitor power down messages which wreak havoc - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_KEYMENU: - case SC_MOUSEMENU: - // Ignore system menu retrieval - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0L; - break; - case SC_CLOSE: - closerequested = true; - //don't continue processing this command since this - //would shutdown the window, which the application might not want to - return 0L; - } - } - break; case WM_ACTIVATE: switch (wParam) { case WA_ACTIVE: @@ -176,11 +156,6 @@ break; } break; - case WM_QUIT: - { - closerequested = true; - return 0L; - } case WM_PAINT: { isDirty = true; @@ -270,13 +245,6 @@ return isMinimized ? JNI_FALSE : JNI_TRUE; } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isCloseRequested - (JNIEnv *env, jobject self) { - bool saved = closerequested; - closerequested = false; - return saved; -} - JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isActive (JNIEnv *env, jobject self) { return isFocused; @@ -302,7 +270,6 @@ oneShotInitialised = true; } - closerequested = false; isMinimized = false; isFocused = false; isDirty = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-26 14:25:18
|
Revision: 2389 Author: elias_naur Date: 2006-06-26 07:24:45 -0700 (Mon, 26 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2389&view=rev Log Message: ----------- Windows: Moved is_dirty from native to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-26 14:13:57 UTC (rev 2388) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-26 14:24:45 UTC (rev 2389) @@ -62,6 +62,7 @@ private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; + private final static int WM_PAINT = 0x000F; private final static int SC_SIZE = 0xF000; private final static int SC_MOVE = 0xF010; @@ -90,9 +91,11 @@ private static WindowsMouse mouse; private static boolean close_requested; + private static boolean is_dirty; public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { close_requested = false; + is_dirty = false; nCreateWindow(mode, fullscreen, x, y); peer_info.initDC(); } @@ -136,14 +139,22 @@ private native String nGetVersion(String driver); public native DisplayMode init() throws LWJGLException; public native void setTitle(String title); + public boolean isCloseRequested() { boolean saved = close_requested; close_requested = false; return saved; } + public native boolean isVisible(); public native boolean isActive(); - public native boolean isDirty(); + + public boolean isDirty() { + boolean saved = is_dirty; + is_dirty = false; + return saved; + } + public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException { peer_info = new Win32DisplayPeerInfo(pixel_format); return peer_info; @@ -381,6 +392,9 @@ break; } return false; + case WM_PAINT: + is_dirty = true; + return false; default: return false; } Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-06-26 14:13:57 UTC (rev 2388) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-06-26 14:24:45 UTC (rev 2389) @@ -54,7 +54,6 @@ 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 static bool did_maximize = false; // A flag to tell when a window // has recovered from minimized @@ -156,10 +155,6 @@ break; } break; - case WM_PAINT: - { - isDirty = true; - } } env = (JNIEnv *)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA); @@ -232,14 +227,6 @@ handleMessages(env); } - -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isDirty - (JNIEnv *env, jobject self) { - bool result = isDirty; - isDirty = false; - return result ? JNI_TRUE : JNI_FALSE; -} - JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isVisible (JNIEnv *env, jobject self) { return isMinimized ? JNI_FALSE : JNI_TRUE; @@ -272,7 +259,6 @@ isMinimized = false; isFocused = false; - isDirty = true; isFullScreen = fullscreen == JNI_TRUE; isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, isFullScreen, isUndecorated); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-06-27 11:11:52
|
Revision: 2391 Author: elias_naur Date: 2006-06-27 04:11:37 -0700 (Tue, 27 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2391&view=rev Log Message: ----------- Windows: Generalize getMin/MaxCursorSize to one native GetSystemMetrics Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/native/win32/org_lwjgl_input_Cursor.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-26 14:28:52 UTC (rev 2390) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-06-27 11:11:37 UTC (rev 2391) @@ -85,6 +85,8 @@ private final static int SC_CONTEXTHELP = 0xF180; private final static int SC_SEPARATOR = 0xF00F; + private final static int SM_CXCURSOR = 13; + private static Win32DisplayPeerInfo peer_info; private static WindowsKeyboard keyboard; @@ -221,9 +223,16 @@ public native void setNativeCursor(Object handle) throws LWJGLException; - public native int getMinCursorSize(); - public native int getMaxCursorSize(); + public int getMinCursorSize() { + return getSystemMetrics(SM_CXCURSOR); + } + public int getMaxCursorSize() { + return getSystemMetrics(SM_CXCURSOR); + } + + public native int getSystemMetrics(int index); + private static native long getDllInstance(); private static native long getHwnd(); Modified: trunk/LWJGL/src/native/win32/org_lwjgl_input_Cursor.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_input_Cursor.c 2006-06-26 14:28:52 UTC (rev 2390) +++ trunk/LWJGL/src/native/win32/org_lwjgl_input_Cursor.c 2006-06-27 11:11:37 UTC (rev 2391) @@ -44,19 +44,6 @@ #include "org_lwjgl_opengl_Win32Display.h" #include "common_tools.h" -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getMaxCursorSize -(JNIEnv *env, jobject self) -{ - return GetSystemMetrics(SM_CXCURSOR); -} - -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getMinCursorSize -(JNIEnv *env, jobject self) -{ - return GetSystemMetrics(SM_CXCURSOR); -} - - JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_nCreateCursor (JNIEnv *env, jobject self, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-06-26 14:28:52 UTC (rev 2390) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-06-27 11:11:37 UTC (rev 2391) @@ -548,3 +548,8 @@ GetClientRect(hwnd, &clientRect); return (clientRect.bottom - clientRect.top) - 1 - y; } + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getSystemMetrics(JNIEnv *env, jclass unused, jint index) { + return GetSystemMetrics(index); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-04 17:07:48
|
Revision: 2445 Author: elias_naur Date: 2006-07-04 10:07:13 -0700 (Tue, 04 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2445&view=rev Log Message: ----------- Added Keyboard.getEventNanoseconds() and Mouse.getEventNanoseconds() Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsDirectInputDevice3.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_WindowsDirectInputDevice8.c Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -56,7 +56,7 @@ */ public class Keyboard { /** Internal use - event size in bytes */ - public static final int EVENT_SIZE = 4 + 1 + 4; + public static final int EVENT_SIZE = 4 + 1 + 4 + 8; /** * The special character meaning that no @@ -256,6 +256,9 @@ /** The current state of the key being examined in the event queue */ private static boolean eventState; + + /** The current event time */ + private static long eventNanos; /** One time initialization */ private static boolean initialized; @@ -426,6 +429,7 @@ eventKey = readBuffer.getInt() & 0xFF; eventState = readBuffer.get() != 0; eventCharacter = readBuffer.getInt(); + eventNanos = readBuffer.getLong(); return true; } else { return false; @@ -466,4 +470,15 @@ public static boolean getEventKeyState() { return eventState; } + + /** + * Gets the time in nanoseconds of the current event. + * Only useful for relative comparisons with other + * Keyboard events, as the absolute time has no defined + * origin. + * @return The time in nanoseconds of the current event + */ + public static long getEventNanoseconds() { + return eventNanos; + } } Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -60,7 +60,7 @@ */ public class Mouse { /** Internal use - event size in bytes */ - public static final int EVENT_SIZE = 1 + 1 + 4 + 4 + 4; + public static final int EVENT_SIZE = 1 + 1 + 4 + 4 + 4 + 8; /** Has the mouse been created? */ private static boolean created; @@ -120,6 +120,7 @@ /** The current absolute position of the mouse in the event queue */ private static int event_x; private static int event_y; + private static long event_nanos; /** Buffer size in events */ private static final int BUFFER_SIZE = 50; @@ -379,6 +380,7 @@ event_x = Math.min(Display.getDisplayMode().getWidth() - 1, Math.max(0, event_x)); event_y = Math.min(Display.getDisplayMode().getHeight() - 1, Math.max(0, event_y)); event_dwheel = readBuffer.getInt(); + event_nanos = readBuffer.getLong(); return true; } else return false; @@ -438,6 +440,18 @@ } /** + * Gets the time in nanoseconds of the current event. + * Only useful for relative comparisons with other + * Mouse events, as the absolute time has no defined + * origin. + * + * @return The time in nanoseconds of the current event + */ + public static long getEventNanoseconds() { + return event_nanos; + } + + /** * Retrieves the absolute position. If the Display has been created * x will be clamped to 0...width-1. * Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -242,11 +242,11 @@ super(Keyboard.EVENT_SIZE); } - private void putKeyboardEvent(int key_code, byte state, int character) { - event.putInt(key_code).put(state).putInt(character); + private void putKeyboardEvent(int key_code, byte state, int character, long nanos) { + event.clear(); + event.putInt(key_code).put(state).putInt(character).putLong(nanos); event.flip(); putEvent(event); - event.compact(); } public synchronized void poll(ByteBuffer key_down_buffer) { @@ -255,7 +255,7 @@ key_down_buffer.position(old_position); } - private synchronized void handleKey(int key_code_mapped, byte state, int character) { + private synchronized void handleKey(int key_code_mapped, byte state, int character, long nanos) { if ( character == KeyEvent.CHAR_UNDEFINED ) character = Keyboard.CHAR_NONE; /* Ignore repeating presses */ @@ -263,7 +263,7 @@ return; key_states[key_code_mapped] = state; int key_int_char = character & 0xffff; - putKeyboardEvent(key_code_mapped, state, key_int_char); + putKeyboardEvent(key_code_mapped, state, key_int_char, nanos); } private int getMappedKeyCode(int key_code, int position) { @@ -291,11 +291,11 @@ } public void keyPressed(KeyEvent e) { - handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)1, e.getKeyChar()); + handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)1, e.getKeyChar(), e.getWhen()*1000000); } public void keyReleased(KeyEvent e) { - handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)0, Keyboard.CHAR_NONE); + handleKey(getMappedKeyCode(e.getKeyCode(), e.getKeyLocation()), (byte)0, Keyboard.CHAR_NONE, e.getWhen()*1000000); } public void keyTyped(KeyEvent e) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -972,7 +972,7 @@ /* Callbacks from nUpdate() */ private static void handleButtonEvent(long millis, int type, int button, int state) { if (mouse != null) - mouse.handleButtonEvent(grab, type, (byte)button); + mouse.handleButtonEvent(grab, millis, type, (byte)button); } private static void handleKeyEvent(long event_ptr, long millis, int type, int keycode, int state) { @@ -980,9 +980,9 @@ keyboard.handleKeyEvent(event_ptr, millis, type, keycode, state); } - private static void handlePointerMotionEvent(long root_window, int x_root, int y_root, int x, int y, int state) { + private static void handlePointerMotionEvent(long millis, long root_window, int x_root, int y_root, int x, int y, int state) { if (mouse != null) - mouse.handlePointerMotion(grab, pointer_grabbed, shouldGrab(), root_window, x_root, y_root, x, y); + mouse.handlePointerMotion(grab, pointer_grabbed, shouldGrab(), millis, root_window, x_root, y_root, x, y); } private static void handleWarpEvent(int x, int y) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -160,11 +160,11 @@ keyDownBuffer.position(old_position); } - private void putKeyboardEvent(int keycode, byte state, int ch) { - tmp_event.putInt(keycode).put(state).putInt(ch); + private void putKeyboardEvent(int keycode, byte state, int ch, long nanos) { + tmp_event.clear(); + tmp_event.putInt(keycode).put(state).putInt(ch).putLong(nanos); tmp_event.flip(); event_queue.putEvent(tmp_event); - tmp_event.compact(); } private int lookupStringISO88591(long event_ptr, int[] translation_buffer) { @@ -202,24 +202,24 @@ return lookupStringISO88591(event_ptr, translation_buffer); } - private void translateEvent(long event_ptr, int event_type, int keycode, byte key_state) { + private void translateEvent(long event_ptr, int event_type, int keycode, byte key_state, long nanos) { int num_chars, i; int ch; if (event_type == KeyRelease) { - putKeyboardEvent(keycode, key_state, 0); + putKeyboardEvent(keycode, key_state, 0, nanos); return; } num_chars = lookupString(event_ptr, temp_translation_buffer); if (num_chars > 0) { ch = temp_translation_buffer[0]; - putKeyboardEvent(keycode, key_state, ch); + putKeyboardEvent(keycode, key_state, ch, nanos); for (i = 1; i < num_chars; i++) { ch = temp_translation_buffer[i]; - putKeyboardEvent(0, (byte)0, ch); + putKeyboardEvent(0, (byte)0, ch, nanos); } } else { - putKeyboardEvent(keycode, key_state, 0); + putKeyboardEvent(keycode, key_state, 0, nanos); } } @@ -298,6 +298,6 @@ int keycode = getKeycode(event_ptr, event_state); byte key_state = getKeyState(event_type); key_down_buffer[keycode] = key_state; - translateEvent(event_ptr, event_type, keycode, key_state); + translateEvent(event_ptr, event_type, keycode, key_state, millis*1000000); } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -73,6 +73,7 @@ private int accum_dz; private byte[] buttons = new byte[NUM_BUTTONS]; private EventQueue event_queue; + private long last_event_nanos; public LinuxMouse(long display, long window) { this.display = display; @@ -103,25 +104,28 @@ buttons_buffer.put(i, buttons[i]); } - private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz) { - event_buffer.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz); + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + event_buffer.clear(); + event_buffer.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); event_buffer.flip(); event_queue.putEvent(event_buffer); - event_buffer.compact(); + last_event_nanos = nanos; } - private void setCursorPos(boolean grab, int x, int y) { + private void setCursorPos(boolean grab, int x, int y, long nanos) { y = transformY(y); int dx = x - last_x; int dy = y - last_y; - accum_dx += dx; - accum_dy += dy; - last_x = x; - last_y = y; - if (grab) { - putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0); - } else { - putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0); + if (dx != 0 || dy != 0) { + accum_dx += dx; + accum_dy += dy; + last_x = x; + last_y = y; + if (grab) { + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); + } else { + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); + } } } @@ -131,8 +135,8 @@ } private static native void nSendWarpEvent(long display, long window, int center_x, int center_y); - private void doHandlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long root_window, int root_x, int root_y, int win_x, int win_y) { - setCursorPos(grab, win_x, win_y); + private void doHandlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) { + setCursorPos(grab, win_x, win_y, nanos); if (!pointer_grabbed || !should_grab) return; int root_window_height = nGetWindowHeight(display, root_window); @@ -164,7 +168,7 @@ public void changeGrabbed(boolean grab, boolean pointer_grabbed, boolean should_grab) { reset(); long root_window = nQueryPointer(display, window, query_pointer_buffer); - doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, query_pointer_buffer.get(0), query_pointer_buffer.get(1), query_pointer_buffer.get(2), query_pointer_buffer.get(3)); + doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, query_pointer_buffer.get(0), query_pointer_buffer.get(1), query_pointer_buffer.get(2), query_pointer_buffer.get(3), last_event_nanos); } public int getButtonCount() { @@ -184,11 +188,11 @@ } private static native void nWarpCursor(long display, long window, int x, int y); - public void handlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long root_window, int x_root, int y_root, int x, int y) { - doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, x_root, y_root, x, y); + public void handlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long millis, long root_window, int x_root, int y_root, int x, int y) { + doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, x_root, y_root, x, y, millis*1000000); } - private void handleButton(boolean grab, int button, byte state) { + private void handleButton(boolean grab, int button, byte state, long nanos) { byte button_num; switch (button) { case Button1: @@ -204,46 +208,43 @@ return; } buttons[button_num] = state; - putMouseEvent(grab, button_num, state, 0); + putMouseEvent(grab, button_num, state, 0, nanos); } - private void putMouseEvent(boolean grab, byte button, byte state, int dz) { + private void putMouseEvent(boolean grab, byte button, byte state, int dz, long nanos) { if (grab) - putMouseEventWithCoords(button, state, 0, 0, dz); + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); else - putMouseEventWithCoords(button, state, last_x, last_y, dz); + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); } - private void handleButtonPress(boolean grab, byte button) { + private void handleButtonPress(boolean grab, byte button, long nanos) { int delta = 0; switch (button) { case Button4: delta = WHEEL_SCALE; - putMouseEvent(grab, (byte)-1, (byte)0, delta); + putMouseEvent(grab, (byte)-1, (byte)0, delta, nanos); accum_dz += delta; break; case Button5: delta = -WHEEL_SCALE; - putMouseEvent(grab, (byte)-1, (byte)0, delta); + putMouseEvent(grab, (byte)-1, (byte)0, delta, nanos); accum_dz += delta; break; default: - handleButton(grab, button, (byte)1); + handleButton(grab, button, (byte)1, nanos); break; } } - private void handleButtonRelease(boolean grab, int button) { - handleButton(grab, button, (byte)0); - } - - public void handleButtonEvent(boolean grab, int type, byte button) { + public void handleButtonEvent(boolean grab, long millis, int type, byte button) { + long nanos = millis*1000000; switch (type) { case ButtonRelease: - handleButton(grab, button, (byte)0); + handleButton(grab, button, (byte)0, nanos); break; case ButtonPress: - handleButtonPress(grab, button); + handleButtonPress(grab, button, nanos); break; default: break; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -104,18 +104,18 @@ ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); } - private void putMouseEvent(byte button, byte state, int dz) { + private void putMouseEvent(byte button, byte state, int dz, long nanos) { if (grabbed) - putMouseEventWithCoords(button, state, 0, 0, dz); + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); else - putMouseEventWithCoords(button, state, last_x, last_y, dz); + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); } - private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz) { - event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz); + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + event.clear(); + event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); event.flip(); putEvent(event); - event.compact(); } public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) { @@ -133,7 +133,7 @@ buttons_buffer.position(old_position); } - private synchronized void setCursorPos(int x, int y) { + private synchronized void setCursorPos(int x, int y, long nanos) { y = transformY(y); if ( grabbed ) return; @@ -143,7 +143,7 @@ accum_dy += dy; last_x = x; last_y = y; - putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0); + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); } public void mouseClicked(MouseEvent e) { @@ -195,16 +195,16 @@ default: throw new IllegalArgumentException("Not a valid button: " + e.getButton()); } - setButton(button, state); + setButton(button, state, e.getWhen()*1000000); } public void mousePressed(MouseEvent e) { handleButton(e); } - private synchronized void setButton(byte button, byte state) { + private synchronized void setButton(byte button, byte state, long nanos) { buttons[button] = state; - putMouseEvent(button, state, 0); + putMouseEvent(button, state, 0, nanos); } public void mouseReleased(MouseEvent e) { @@ -212,10 +212,10 @@ } private void handleMotion(MouseEvent e) { - if ( grabbed ) { - updateDeltas(); + if (grabbed) { + updateDeltas(e.getWhen()*1000000); } else { - setCursorPos(e.getX(), e.getY()); + setCursorPos(e.getX(), e.getY(), e.getWhen()*1000000); } } @@ -227,20 +227,20 @@ handleMotion(e); } - private synchronized void handleWheel(int amount) { + private synchronized void handleWheel(int amount, long nanos) { accum_dz += amount; - putMouseEvent((byte)-1, (byte)0, amount); + putMouseEvent((byte)-1, (byte)0, amount, nanos); } - private void updateDeltas() { - if ( !grabbed ) + private void updateDeltas(long nanos) { + if (!grabbed) return; synchronized ( this ) { ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer); int dx = delta_buffer.get(0); int dy = -delta_buffer.get(1); if ( dx != 0 || dy != 0 ) { - putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0); + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); accum_dx += dx; accum_dy += dy; } @@ -249,6 +249,6 @@ public void mouseWheelMoved(MouseWheelEvent e) { int wheel_amount = -e.getWheelRotation() * WHEEL_SCALE; - handleWheel(wheel_amount); + handleWheel(wheel_amount, e.getWhen()*1000000); } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -338,51 +338,51 @@ private static native int nSetWindowIcon32(IntBuffer icon); - private static void handleMouseButton(int button, int state) { + private static void handleMouseButton(int button, int state, long millis) { if (mouse != null) - mouse.handleMouseButton((byte)button, (byte)state); + mouse.handleMouseButton((byte)button, (byte)state, millis); } - private static void handleMouseMoved(int x, int y) { + private static void handleMouseMoved(int x, int y, long millis) { if (mouse != null) - mouse.handleMouseMoved(x, y); + mouse.handleMouseMoved(x, y, millis); } - private static void handleMouseScrolled(int amount) { + private static void handleMouseScrolled(int amount, long millis) { if (mouse != null) - mouse.handleMouseScrolled(amount); + mouse.handleMouseScrolled(amount, millis); } private static native int transformY(long hwnd, int y); - private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam) { + private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { switch (msg) { case WM_MOUSEMOVE: int xPos = (int)(short)(lParam & 0xFFFF); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); - handleMouseMoved(xPos, yPos); + handleMouseMoved(xPos, yPos, millis); return true; case WM_MOUSEWHEEL: int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); - handleMouseScrolled(dwheel); + handleMouseScrolled(dwheel, millis); return true; case WM_LBUTTONDOWN: - handleMouseButton(0, 1); + handleMouseButton(0, 1, millis); return true; case WM_LBUTTONUP: - handleMouseButton(0, 0); + handleMouseButton(0, 0, millis); return true; case WM_RBUTTONDOWN: - handleMouseButton(1, 1); + handleMouseButton(1, 1, millis); return true; case WM_RBUTTONUP: - handleMouseButton(1, 0); + handleMouseButton(1, 0, millis); return true; case WM_MBUTTONDOWN: - handleMouseButton(2, 1); + handleMouseButton(2, 1, millis); return true; case WM_MBUTTONUP: - handleMouseButton(2, 0); + handleMouseButton(2, 0, millis); return true; case WM_QUIT: close_requested = true; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -54,6 +54,8 @@ public final static int GUID_Button = 4; public final static int GUID_Unknown = 5; + public final static int DATA_SIZE = 3; + private final long di_device; private ByteBuffer event_buffer; @@ -100,7 +102,7 @@ protected abstract int setBufferSize(long di_device, int buffer_size); public int getDeviceData(IntBuffer buffer) { - int events_remaining = buffer.remaining()/2; + int events_remaining = buffer.remaining()/DATA_SIZE; if (event_buffer == null || events_remaining > event_buffer.remaining()/getEventSize()) event_buffer = BufferUtils.createByteBuffer(events_remaining*getEventSize()); return getDeviceData(di_device, event_buffer, event_buffer.capacity(), buffer, buffer.position(), buffer.remaining()); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -48,6 +48,8 @@ public final static int GUID_Button = WindowsDirectInputDevice.GUID_Button; public final static int GUID_Unknown = WindowsDirectInputDevice.GUID_Unknown; + public final static int DATA_SIZE = WindowsDirectInputDevice.DATA_SIZE; + public WindowsDirectInputDevice3(long di_device) { super(di_device); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -48,6 +48,8 @@ public final static int GUID_Button = WindowsDirectInputDevice.GUID_Button; public final static int GUID_Unknown = WindowsDirectInputDevice.GUID_Unknown; + public final static int DATA_SIZE = WindowsDirectInputDevice.DATA_SIZE; + public WindowsDirectInputDevice8(long di_device) { super(di_device); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -110,6 +110,8 @@ byte dwData = (byte)src.get(); boolean key_down = (dwData & 0x80) != 0; dst.put(key_down ? (byte)1 : (byte)0); + long dwTimeStamp = ((long)src.get()) & 0xFFFFFFFF; + long nanos = dwTimeStamp*1000000; if (key_down) { int virt_key = MapVirtualKey(dwOfs, 1); if (virt_key != 0 && GetKeyboardState(keyboard_state) != 0) { @@ -130,16 +132,21 @@ } int char_int = ((int)unicode_buffer.get()) & 0xFFFF; dst.putInt(char_int); + dst.putLong(nanos); current_char++; } while (dst.hasRemaining() && current_char < num_chars); } else { dst.putInt(0); + dst.putLong(nanos); } } else { dst.putInt(0); + dst.putLong(nanos); } - } else + } else { dst.putInt(0); + dst.putLong(nanos); + } } } private static native int MapVirtualKey(int uCode, int uMapType); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-04 17:07:13 UTC (rev 2445) @@ -180,18 +180,18 @@ } } - private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz) { - mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz); + private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) { + mouse_event.clear(); + mouse_event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos); mouse_event.flip(); event_queue.putEvent(mouse_event); - mouse_event.compact(); } - private void putMouseEvent(byte button, byte state, int dz) { + private void putMouseEvent(byte button, byte state, int dz, long nanos) { if (mouse_grabbed) - putMouseEventWithCoords(button, state, 0, 0, dz); + putMouseEventWithCoords(button, state, 0, 0, dz, nanos); else - putMouseEventWithCoords(button, state, last_x, last_y, dz); + putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos); } private void copyDXEvents(IntBuffer buffer) { @@ -199,25 +199,28 @@ int dx = 0, dy = 0, dwheel = 0; byte button_state; int i; + long nanos = 0; while (buffer.hasRemaining()) { int dwOfs = buffer.get(); int dwData = buffer.get(); + long dwTimeStamp = ((long)buffer.get()) & 0xFFFFFFFF; + nanos = dwTimeStamp*1000000; button_state = (dwData & 0x80) != 0 ? (byte)1 : (byte)0; switch (dwOfs) { case DIMOFS_BUTTON0: - putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)0, button_state, dx, -dy, dwheel, nanos); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON1: - putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)1, button_state, dx, -dy, dwheel, nanos); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON2: - putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)2, button_state, dx, -dy, dwheel, nanos); dx = dy = dwheel = 0; break; case DIMOFS_BUTTON3: - putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel); + putMouseEventWithCoords((byte)3, button_state, dx, -dy, dwheel, nanos); dx = dy = dwheel = 0; break; case DIMOFS_X: @@ -232,7 +235,7 @@ } } if (dx != 0 || dy != 0 || dwheel != 0) - putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel); + putMouseEventWithCoords((byte)-1, (byte)0, dx, -dy, dwheel, nanos); } private void readDXBuffer() { @@ -284,27 +287,28 @@ event_queue.clearEvents(); } - public void handleMouseScrolled(int event_dwheel) { + public void handleMouseScrolled(int event_dwheel, long millis) { accum_dwheel += event_dwheel; - putMouseEvent((byte)-1, (byte)0, event_dwheel); + putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000); } - public void handleMouseMoved(int x, int y) { + public void handleMouseMoved(int x, int y, long millis) { int dx; int dy; dx = x - last_x; dy = y - last_y; last_x = x; last_y = y; + long nanos = millis*1000000; if (mouse_grabbed) { - putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0); + putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); } else { - putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0); + putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos); } } - public void handleMouseButton(byte button, byte state) { - putMouseEvent(button, state, 0); + public void handleMouseButton(byte button, byte state, long millis) { + putMouseEvent(button, state, 0, millis*1000000); if (button < BUTTON_STATES_SIZE) win32_message_button_states[button] = state != 0 ? (byte)1 : (byte)0; } Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-07-04 13:44:16 UTC (rev 2444) +++ trunk/LW... [truncated message content] |
|
From: <eli...@us...> - 2006-07-08 21:57:38
|
Revision: 2458 Author: elias_naur Date: 2006-07-08 14:57:20 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2458&view=rev Log Message: ----------- Windows: Moved gamma and display modes settings and more boolean state to java side. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java trunk/LWJGL/src/native/win32/Window.h trunk/LWJGL/src/native/win32/display.c trunk/LWJGL/src/native/win32/display.h trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-08 17:20:18 UTC (rev 2457) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32Display.java 2006-07-08 21:57:20 UTC (rev 2458) @@ -87,30 +87,145 @@ private final static int SM_CXCURSOR = 13; - private static Win32DisplayPeerInfo peer_info; + private final static int SIZE_RESTORED = 0; + private final static int SIZE_MINIMIZED = 1; + private final static int SIZE_MAXIMIZED = 2; + private final static int WM_SIZE = 0x0005; + private final static int WM_ACTIVATE = 0x0006; + private final static int WA_INACTIVE = 0; + private final static int WA_ACTIVE = 1; + private final static int WA_CLICKACTIVE = 2; + private final static int SW_SHOWMINNOACTIVE = 7; + private final static int SW_RESTORE = 9; - private static WindowsKeyboard keyboard; - private static WindowsMouse mouse; + private static Win32Display current_display; - private static boolean close_requested; - private static boolean is_dirty; + private Win32DisplayPeerInfo peer_info; + private WindowsKeyboard keyboard; + private WindowsMouse mouse; + + private boolean close_requested; + private boolean is_dirty; + + private ByteBuffer current_gamma; + private ByteBuffer saved_gamma; + private DisplayMode current_mode; + + private boolean mode_set; + private boolean isFullscreen; + private boolean isMinimized; + private boolean isFocused; + private boolean did_maximize; + private boolean inAppActivate; + + public Win32Display() { + current_display = this; + } + public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { close_requested = false; is_dirty = false; + isFullscreen = fullscreen; + isMinimized = false; + isFocused = false; + did_maximize = false; nCreateWindow(mode, fullscreen, x, y); peer_info.initDC(); } private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; - public native void destroyWindow(); - public native void switchDisplayMode(DisplayMode mode) throws LWJGLException; - public native void resetDisplayMode(); + public void destroyWindow() { + nDestroyWindow(); + if (isFullscreen) + resetCursorClipping(); + } + private static native void nDestroyWindow(); + private static native void resetCursorClipping(); + private static native void setupCursorClipping(long hwnd) throws LWJGLException; + + public void switchDisplayMode(DisplayMode mode) throws LWJGLException { + nSwitchDisplayMode(mode); + current_mode = mode; + mode_set = true; + } + private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException; + + /* + * Called when the application is alt-tabbed to or from + */ + private void appActivate(boolean active) { + if (inAppActivate) { + return; + } + inAppActivate = true; + isFocused = active; + if (active) { + if (isFullscreen) { + restoreDisplayMode(); + } + showWindow(getHwnd(), SW_RESTORE); + setForegroundWindow(getHwnd()); + setFocus(getHwnd()); + did_maximize = true; + } else if (isFullscreen) { + showWindow(getHwnd(), SW_SHOWMINNOACTIVE); + resetDisplayMode(); + } + inAppActivate = false; + } + private static native void showWindow(long hwnd, int mode); + private static native void setForegroundWindow(long hwnd); + private static native void setFocus(long hwnd); + + private void restoreDisplayMode() { + try { + doSetGammaRamp(current_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore gamma: " + e.getMessage()); + } + + if (!mode_set) { + mode_set = true; + try { + nSwitchDisplayMode(current_mode); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to restore display mode: " + e.getMessage()); + } + } + } + + public void resetDisplayMode() { + try { + doSetGammaRamp(saved_gamma); + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to reset gamma ramp: " + e.getMessage()); + } + current_gamma = saved_gamma; + if (mode_set) { + mode_set = false; + nResetDisplayMode(); + } + resetCursorClipping(); + } + private static native void nResetDisplayMode(); + public int getGammaRampLength() { return GAMMA_LENGTH; } - public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; + public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { + doSetGammaRamp(convertToNativeRamp(gammaRamp)); + } + private static native ByteBuffer convertToNativeRamp(FloatBuffer gamma_ramp) throws LWJGLException; + private static native ByteBuffer getCurrentGammaRamp() throws LWJGLException; + + private void doSetGammaRamp(ByteBuffer native_gamma) throws LWJGLException { + nSetGammaRamp(native_gamma); + current_gamma = native_gamma; + } + private static native void nSetGammaRamp(ByteBuffer native_ramp) throws LWJGLException; + public String getAdapter() { try { String adapter_string = Win32Registry.queryRegistrationKey( @@ -139,7 +254,13 @@ return null; } private native String nGetVersion(String driver); - public native DisplayMode init() throws LWJGLException; + + public DisplayMode init() throws LWJGLException { + current_gamma = saved_gamma = getCurrentGammaRamp(); + return current_mode = getCurrentDisplayMode(); + } + private static native DisplayMode getCurrentDisplayMode() throws LWJGLException; + public native void setTitle(String title); public boolean isCloseRequested() { @@ -148,9 +269,14 @@ return saved; } - public native boolean isVisible(); - public native boolean isActive(); + public boolean isVisible() { + return !isMinimized; + } + public boolean isActive() { + return isFocused; + } + public boolean isDirty() { boolean saved = is_dirty; is_dirty = false; @@ -163,7 +289,8 @@ } public void update() { nUpdate(); - if (didMaximize()) { + if (did_maximize) { + did_maximize = false; /** * WORKAROUND: * Making the context current (redundantly) when the window @@ -177,10 +304,13 @@ } } } - private native void nUpdate(); - private native boolean didMaximize(); + private static native void nUpdate(); - public native void reshape(int x, int y, int width, int height); + public void reshape(int x, int y, int width, int height) { + if (!isFullscreen) + nReshape(getHwnd(), x, y, width, height); + } + private static native void nReshape(long hwnd, int x, int y, int width, int height); public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException; /* Mouse */ @@ -219,7 +349,10 @@ return Cursor.CURSOR_ONE_BIT_TRANSPARENCY; } - public native void setCursorPosition(int x, int y); + public void setCursorPosition(int x, int y) { + nSetCursorPosition(x, y, isFullscreen); + } + private static native void nSetCursorPosition(int x, int y, boolean fullscreen); public native void setNativeCursor(Object handle) throws LWJGLException; @@ -338,17 +471,17 @@ private static native int nSetWindowIcon32(IntBuffer icon); - private static void handleMouseButton(int button, int state, long millis) { + private void handleMouseButton(int button, int state, long millis) { if (mouse != null) mouse.handleMouseButton((byte)button, (byte)state, millis); } - private static void handleMouseMoved(int x, int y, long millis) { + private void handleMouseMoved(int x, int y, long millis) { if (mouse != null) mouse.handleMouseMoved(x, y, millis); } - private static void handleMouseScrolled(int amount, long millis) { + private void handleMouseScrolled(int amount, long millis) { if (mouse != null) mouse.handleMouseScrolled(amount, millis); } @@ -356,7 +489,44 @@ private static native int transformY(long hwnd, int y); private static boolean handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + if (current_display != null) + return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis); + else + return false; + } + + private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { + if (isFullscreen && !isMinimized && isFocused) { + try { + setupCursorClipping(getHwnd()); + } catch (LWJGLException e) { + LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage()); + } + } switch (msg) { + // disable screen saver and monitor power down messages which wreak havoc + case WM_ACTIVATE: + switch ((int)wParam) { + case WA_ACTIVE: + case WA_CLICKACTIVE: + appActivate(true); + break; + case WA_INACTIVE: + appActivate(false); + break; + } + return true; + case WM_SIZE: + switch ((int)wParam) { + case SIZE_RESTORED: + case SIZE_MAXIMIZED: + isMinimized = false; + break; + case SIZE_MINIMIZED: + isMinimized = true; + break; + } + return false; case WM_MOUSEMOVE: int xPos = (int)(short)(lParam & 0xFFFF); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); Modified: trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java 2006-07-08 17:20:18 UTC (rev 2457) +++ trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java 2006-07-08 21:57:20 UTC (rev 2458) @@ -230,10 +230,14 @@ * @param time milliseconds to sleep */ private void pause(long time) { - try { - Thread.sleep(time); - } catch (InterruptedException inte) { - } + int SLEEP_DELAY = 100; + for (int i = 0; i < time; i += SLEEP_DELAY) { + try { + Display.processMessages(); + Thread.sleep(SLEEP_DELAY); + } catch (InterruptedException inte) { + } + } } /** Modified: trunk/LWJGL/src/native/win32/Window.h =================================================================== --- trunk/LWJGL/src/native/win32/Window.h 2006-07-08 17:20:18 UTC (rev 2457) +++ trunk/LWJGL/src/native/win32/Window.h 2006-07-08 21:57:20 UTC (rev 2458) @@ -56,9 +56,7 @@ #define WINDOW_H_API extern #endif /* _PRIVATE_WINDOW_H_ */ - WINDOW_H_API HWND getCurrentHWND(); - WINDOW_H_API HDC getCurrentHDC(); - WINDOW_H_API bool getCurrentFullscreen(); + WINDOW_H_API HWND getCurrentHWND(); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Modified: trunk/LWJGL/src/native/win32/display.c =================================================================== --- trunk/LWJGL/src/native/win32/display.c 2006-07-08 17:20:18 UTC (rev 2457) +++ trunk/LWJGL/src/native/win32/display.c 2006-07-08 21:57:20 UTC (rev 2458) @@ -42,18 +42,13 @@ #include <windows.h> // Multimon.h enables multi monitor emulation on win95 and winnt4 // So we only need the extended, multi-monitor aware path -#define COMPILE_MULTIMON_STUBS -#include <Multimon.h> +//#define COMPILE_MULTIMON_STUBS +//#include <Multimon.h> #include <jni.h> #include "org_lwjgl_opengl_Win32Display.h" #include "display.h" #include "common_tools.h" -static bool modeSet = false; // Whether we've done a display mode change -static WORD originalGamma[3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH]; // Original gamma settings -static WORD currentGamma[3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH]; // Current gamma settings -static DEVMODE devmode; // Now we'll remember this value for the future - static jobject createDisplayMode(JNIEnv *env, DEVMODE *devmode) { jclass displayModeClass; @@ -127,8 +122,9 @@ return ret; } -void switchDisplayMode(JNIEnv * env, jobject mode) -{ +void switchDisplayMode(JNIEnv * env, jobject mode) { + DEVMODE devmode; + jclass cls_displayMode = (*env)->GetObjectClass(env, mode); jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); @@ -165,99 +161,85 @@ return; // } } - modeSet = true; } -void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer) -{ - int i; - float scaledRampEntry; - WORD rampEntry; - HDC screenDC; - const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer); - // Turn array of floats into array of RGB WORDs - - for (i = 0; i < org_lwjgl_opengl_Win32Display_GAMMA_LENGTH; i ++) { - scaledRampEntry = gammaRamp[i]*0xffff; - rampEntry = (WORD)scaledRampEntry; - currentGamma[i] = rampEntry; - currentGamma[i + org_lwjgl_opengl_Win32Display_GAMMA_LENGTH] = rampEntry; - currentGamma[i + 2*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH] = rampEntry; - } - screenDC = GetDC(NULL); - if (SetDeviceGammaRamp(screenDC, currentGamma) == FALSE) { - throwException(env, "Failed to set device gamma."); - } - ReleaseDC(NULL, screenDC); +static jobject createNativeGammaBuffer(JNIEnv *env) { + return newJavaManagedByteBuffer(env, sizeof(WORD)*3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH); } +jobject getCurrentGammaRamp(JNIEnv *env) { + jobject gamma_buffer; + WORD *gamma; + HDC screenDC; -jobject initDisplay(JNIEnv * env) -{ - DEVMODE devmode; - jobject newMode; + gamma_buffer = createNativeGammaBuffer(env); + if (gamma_buffer == NULL) + return NULL; + gamma = (WORD *)(*env)->GetDirectBufferAddress(env, gamma_buffer); // Get the screen - HDC screenDC = GetDC(NULL); - if (!screenDC) { + screenDC = GetDC(NULL); + if (screenDC == NULL) { throwException(env, "Couldn't get screen DC!"); return NULL; } // Get the default gamma ramp - if (GetDeviceGammaRamp(screenDC, originalGamma) == FALSE) { + if (GetDeviceGammaRamp(screenDC, gamma) == FALSE) { printfDebugJava(env, "Failed to get initial device gamma"); } - memcpy(currentGamma, originalGamma, sizeof(WORD)*3*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH); ReleaseDC(NULL, screenDC); + return gamma_buffer; +} - if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) { - throwFormattedException(env, "Couldn't get current display settings (%ld)", GetLastError()); - return NULL; +void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer) { + HDC screenDC; + WORD *gammaRamp = (WORD *)(*env)->GetDirectBufferAddress(env, gammaRampBuffer); + + screenDC = GetDC(NULL); + if (SetDeviceGammaRamp(screenDC, gammaRamp) == FALSE) { + throwException(env, "Failed to set device gamma."); } - newMode = createDisplayMode(env, &devmode); - return newMode; + ReleaseDC(NULL, screenDC); } -void resetDisplayMode(JNIEnv * env) { - // Return device gamma to normal - HDC screenDC = GetDC(NULL); - if (!SetDeviceGammaRamp(screenDC, originalGamma)) { - printfDebugJava(env, "Could not reset device gamma"); - } - ReleaseDC(NULL, screenDC); +jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj) { + int i; + float scaledRampEntry; + WORD rampEntry; + HDC screenDC; + const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj); + jint gamma_ramp_length = (*env)->GetDirectBufferCapacity(env, float_gamma_obj); + jobject native_ramp; + WORD *native_ramp_buffer; - if (modeSet) { - modeSet = false; - // Under Win32, all we have to do is: - ChangeDisplaySettings(NULL, 0); + native_ramp = createNativeGammaBuffer(env); + if (native_ramp == NULL) + return NULL; + native_ramp_buffer = (WORD *)(*env)->GetDirectBufferAddress(env, native_ramp); + // Turn array of floats into array of RGB WORDs - // And we'll call init() again to put the correct mode back in Display - if (env != NULL) - initDisplay(env); + for (i = 0; i < gamma_ramp_length; i++) { + scaledRampEntry = gammaRamp[i]*0xffff; + rampEntry = (WORD)scaledRampEntry; + native_ramp_buffer[i] = rampEntry; + native_ramp_buffer[i + org_lwjgl_opengl_Win32Display_GAMMA_LENGTH] = rampEntry; + native_ramp_buffer[i + 2*org_lwjgl_opengl_Win32Display_GAMMA_LENGTH] = rampEntry; } + return native_ramp; } -/* - * Put display settings back to what they were when the window is maximized. - */ -void restoreDisplayMode(void) { - // Restore gamma - HDC screenDC = GetDC(NULL); - LONG cdsret; - if (!SetDeviceGammaRamp(screenDC, currentGamma)) { - printfDebug("Could not restore device gamma\n"); +jobject getCurrentDisplayMode(JNIEnv * env) { + DEVMODE devmode; + if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)) { + throwFormattedException(env, "Couldn't get current display settings (%ld)", GetLastError()); + return NULL; } - ReleaseDC(NULL, screenDC); + return createDisplayMode(env, &devmode); +} - if (!modeSet) { - printfDebug("Attempting to restore the display mode\n"); - modeSet = true; - cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN); - - if (cdsret != DISP_CHANGE_SUCCESSFUL) { - printfDebug("Failed to restore display mode\n"); - } - } +void resetDisplayMode(JNIEnv * env) { + // Under Win32, all we have to do is: + ChangeDisplaySettings(NULL, 0); } jstring getVersion(JNIEnv * env, char *driver) Modified: trunk/LWJGL/src/native/win32/display.h =================================================================== --- trunk/LWJGL/src/native/win32/display.h 2006-07-08 17:20:18 UTC (rev 2457) +++ trunk/LWJGL/src/native/win32/display.h 2006-07-08 21:57:20 UTC (rev 2458) @@ -49,7 +49,9 @@ extern void resetDisplayMode(JNIEnv * env); extern void restoreDisplayMode(void); extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer); -extern jobject initDisplay(JNIEnv * env); +extern jobject getCurrentGammaRamp(JNIEnv *env); +extern jobject getCurrentDisplayMode(JNIEnv * env); extern jstring getVersion(JNIEnv * env, char *driver); +extern jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj); #endif Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-07-08 17:20:18 UTC (rev 2457) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-07-08 21:57:20 UTC (rev 2458) @@ -53,18 +53,10 @@ static HICON large_icon = NULL; static HWND display_hwnd = NULL; // Handle to the window static HDC display_hdc = NULL; // Device 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 did_maximize = false; // A flag to tell when a window // has recovered from minimized #define WINDOWCLASSNAME "LWJGL" -bool getCurrentFullscreen() { - return isFullScreen; -} - HDC getCurrentHDC() { return display_hdc; } @@ -73,45 +65,6 @@ return display_hwnd; } -static void setupCursorClipping() { - RECT hwnd_client; - if (display_hwnd != NULL && GetWindowRect(display_hwnd, &hwnd_client) != 0) { - if (ClipCursor(&hwnd_client) == 0) - printfDebug("ClipCursor failed\n"); - } -} - -static void resetDisplayModeAndClipping(JNIEnv *env) { - resetDisplayMode(env); - ClipCursor(NULL); -} - -/* - * Called when the application is alt-tabbed to or from - */ -static void appActivate(bool active) -{ - static bool inAppActivate = false; - if (inAppActivate) { - return; - } - inAppActivate = true; - isFocused = active; - if (active) { - if (isFullScreen) { - restoreDisplayMode(); - } - ShowWindow(display_hwnd, SW_RESTORE); - SetForegroundWindow(display_hwnd); - SetFocus(display_hwnd); - did_maximize = true; - } else if (isFullScreen) { - ShowWindow(display_hwnd, SW_SHOWMINNOACTIVE); - resetDisplayModeAndClipping(NULL); - } - inAppActivate = false; -} - static void freeLargeIcon() { if (large_icon != NULL) { DestroyIcon(large_icon); @@ -126,13 +79,6 @@ } } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_didMaximize - (JNIEnv *env, jobject self) { - jboolean result = did_maximize ? JNI_TRUE : JNI_FALSE; - did_maximize = false; - return result; -} - /* * WindowProc for the GL window. */ @@ -145,34 +91,6 @@ jclass display_class; jmethodID handleMessage_method; LONG message_time; - if (isFullScreen && !isMinimized && isFocused) - setupCursorClipping(); - switch (msg) { - // disable screen saver and monitor power down messages which wreak havoc - case WM_ACTIVATE: - switch (wParam) { - case WA_ACTIVE: - case WA_CLICKACTIVE: - appActivate(true); - break; - case WA_INACTIVE: - appActivate(false); - break; - } - return 0L; - case WM_SIZE: - switch (wParam) { - case SIZE_RESTORED: - case SIZE_MAXIMIZED: - isMinimized = false; - break; - case SIZE_MINIMIZED: - isMinimized = true; - break; - } - break; - } - env = (JNIEnv *)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA); if (env != NULL && !(*env)->ExceptionOccurred(env)) { display_class = (*env)->FindClass(env, "org/lwjgl/opengl/Win32Display"); @@ -231,29 +149,16 @@ * Signature: ()V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setTitle - (JNIEnv * env, jobject self, jstring title_obj) -{ + (JNIEnv * env, jobject self, jstring title_obj) { char * title = GetStringNativeChars(env, title_obj); SetWindowText(display_hwnd, title); free(title); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nUpdate - (JNIEnv * env, jobject self) -{ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nUpdate(JNIEnv * env, jclass class) { handleMessages(env); } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isVisible - (JNIEnv *env, jobject self) { - return isMinimized ? JNI_FALSE : JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isActive - (JNIEnv *env, jobject self) { - return isFocused; -} - JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_Win32Display_getAvailableDisplayModes(JNIEnv *env, jobject self) { return getAvailableDisplayModes(env); } @@ -275,11 +180,8 @@ oneShotInitialised = true; } - isMinimized = false; - isFocused = false; - isFullScreen = fullscreen == JNI_TRUE; isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); - display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, isFullScreen, isUndecorated); + display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, isUndecorated); if (display_hwnd == NULL) { throwException(env, "Failed to create the window."); return; @@ -292,26 +194,64 @@ SetFocus(display_hwnd); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyWindow(JNIEnv *env, jobject self) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nDestroyWindow(JNIEnv *env, jclass clazz) { closeWindow(&display_hwnd, &display_hdc); - if (isFullScreen) - ClipCursor(NULL); freeLargeIcon(); freeSmallIcon(); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_switchDisplayMode(JNIEnv *env, jobject self, jobject mode) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_resetCursorClipping(JNIEnv *env, jclass unused) { + ClipCursor(NULL); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setupCursorClipping(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + RECT hwnd_client; + if (display_hwnd != NULL && GetWindowRect(hwnd, &hwnd_client) != 0) { + if (ClipCursor(&hwnd_client) == 0) + throwFormattedException(env, "ClipCursor failed (%d)", GetLastError()); + } +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nSwitchDisplayMode(JNIEnv *env, jobject self, jobject mode) { switchDisplayMode(env, mode); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_resetDisplayMode(JNIEnv *env, jobject self) { - resetDisplayModeAndClipping(env); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nResetDisplayMode(JNIEnv *env, jobject self) { + resetDisplayMode(env); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setGammaRamp(JNIEnv *env, jobject self, jobject gamma_buffer) { +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_getCurrentDisplayMode(JNIEnv *env, jclass unused) { + return getCurrentDisplayMode(env); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_convertToNativeRamp(JNIEnv *env, jclass unused, jobject float_ramp) { + return convertToNativeRamp(env, float_ramp); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_getCurrentGammaRamp(JNIEnv *env, jclass unused) { + return getCurrentGammaRamp(env); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nSetGammaRamp(JNIEnv *env, jclass unused, jobject gamma_buffer) { setGammaRamp(env, gamma_buffer); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_showWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint mode) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + ShowWindow(hwnd, mode); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setForegroundWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + SetForegroundWindow(hwnd); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setFocus(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + SetFocus(hwnd); +} + JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_Win32Display_nGetVersion(JNIEnv *env, jobject self, jstring driver) { char *driver_str; jstring result; @@ -323,19 +263,12 @@ return result; } -JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_init(JNIEnv *env, jobject self) { - return initDisplay(env); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_reshape(JNIEnv *env, jobject self, jint x, jint y, jint width, jint height) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; DWORD exstyle, windowflags; RECT clientSize; - if (isFullScreen) { - return; - } - - getWindowFlags(&windowflags, &exstyle, isFullScreen, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); + getWindowFlags(&windowflags, &exstyle, false, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); // If we're not a fullscreen window, adjust the height to account for the // height of the title bar: @@ -351,7 +284,7 @@ exstyle // extended window style ); - SetWindowPos(display_hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER); + SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER); } static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) { @@ -513,7 +446,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setCursorPosition -(JNIEnv * env, jobject self, jint x, jint y) { +(JNIEnv * env, jclass unused, jint x, jint y, jboolean fullscreen) { DWORD windowflags, exstyle; int transformed_x, transformed_y; RECT window_rect; @@ -523,7 +456,7 @@ int left_border_width; int bottom_border_width; - getWindowFlags(&windowflags, &exstyle, getCurrentFullscreen(), getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); + getWindowFlags(&windowflags, &exstyle, fullscreen, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")); if (!GetClientRect(getCurrentHWND(), &client_rect)) { printfDebugJava(env, "GetClientRect failed"); return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-09 08:32:00
|
Revision: 2460 Author: elias_naur Date: 2006-07-09 01:31:49 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2460&view=rev Log Message: ----------- Windows: don't cache the JNIEnv pointer in the message handle, but acquire it through the global JavaVM handle. Modified Paths: -------------- trunk/LWJGL/src/native/common/common_tools.c trunk/LWJGL/src/native/common/common_tools.h trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2006-07-08 22:17:09 UTC (rev 2459) +++ trunk/LWJGL/src/native/common/common_tools.c 2006-07-09 08:31:49 UTC (rev 2460) @@ -301,6 +301,12 @@ return jvm; } +JNIEnv *getThreadEnv() { + JNIEnv *env; + (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_4); + return env; +} + JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { jvm = vm; return JNI_VERSION_1_4; Modified: trunk/LWJGL/src/native/common/common_tools.h =================================================================== --- trunk/LWJGL/src/native/common/common_tools.h 2006-07-08 22:17:09 UTC (rev 2459) +++ trunk/LWJGL/src/native/common/common_tools.h 2006-07-09 08:31:49 UTC (rev 2460) @@ -122,6 +122,7 @@ #endif extern JavaVM *getJVM(); +extern JNIEnv *getThreadEnv(); extern void initAttribList(attrib_list_t *list); extern void putAttrib(attrib_list_t *list, int attrib); Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-07-08 22:17:09 UTC (rev 2459) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c 2006-07-09 08:31:49 UTC (rev 2460) @@ -87,11 +87,10 @@ WPARAM wParam, LPARAM lParam) { - JNIEnv *env; jclass display_class; jmethodID handleMessage_method; LONG message_time; - env = (JNIEnv *)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA); + JNIEnv *env = getThreadEnv(); if (env != NULL && !(*env)->ExceptionOccurred(env)) { display_class = (*env)->FindClass(env, "org/lwjgl/opengl/Win32Display"); if (display_class != NULL) { @@ -186,7 +185,6 @@ throwException(env, "Failed to create the window."); return; } - SetWindowLongPtr(display_hwnd, GWLP_USERDATA, (LONG_PTR)env); display_hdc = GetDC(display_hwnd); ShowWindow(display_hwnd, SW_SHOWDEFAULT); UpdateWindow(display_hwnd); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <eli...@us...> - 2006-07-10 15:32:23
|
Revision: 2465 Author: elias_naur Date: 2006-07-10 08:32:14 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2465&view=rev Log Message: ----------- Windows: Fixed fetches of a boolean field with GetIntField JNI Modified Paths: -------------- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c 2006-07-10 15:29:29 UTC (rev 2464) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c 2006-07-10 15:32:14 UTC (rev 2465) @@ -138,7 +138,7 @@ Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); int pixel_format_id; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); if ( pBufferAttribs != NULL ) { pBufferAttribs_ptr = (const int *)(*env)->GetDirectBufferAddress(env, pBufferAttribs); Modified: trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c =================================================================== --- trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c 2006-07-10 15:29:29 UTC (rev 2464) +++ trunk/LWJGL/src/native/win32/org_lwjgl_opengl_Win32PeerInfo.c 2006-07-10 15:32:14 UTC (rev 2465) @@ -51,7 +51,7 @@ (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) { Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - bool floating_point = (bool)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); + bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); int pixel_format_id = findPixelFormat(env, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); if (pixel_format_id == -1) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |