From 0886f84ed890ad933c7c3fded3b0598dc51e0afc Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Thu, 7 Aug 2003 21:53:06 +0000 Subject: [PATCH] *** empty log message *** --- src/java/org/lwjgl/Sys.java | 5 ++ src/native/common/org_lwjgl_Sys.h | 10 +++- src/native/win32/org_lwjgl_Display.cpp | 71 +++++++++++++++++--------- src/native/win32/org_lwjgl_Sys.cpp | 12 +++++ 4 files changed, 72 insertions(+), 26 deletions(-) diff --git a/src/java/org/lwjgl/Sys.java b/src/java/org/lwjgl/Sys.java index 27939083..efb8e4b0 100644 --- a/src/java/org/lwjgl/Sys.java +++ b/src/java/org/lwjgl/Sys.java @@ -191,4 +191,9 @@ public final class Sys { */ public static native void alert(String title, String message); + /* + * Cas: this is just a debugging aid. The native code is also commented out. + * + public static native int getDirectBufferAddress(Buffer buf); + */ } diff --git a/src/native/common/org_lwjgl_Sys.h b/src/native/common/org_lwjgl_Sys.h index 92b30e5b..8da2e8b2 100644 --- a/src/native/common/org_lwjgl_Sys.h +++ b/src/native/common/org_lwjgl_Sys.h @@ -19,7 +19,7 @@ extern "C" { /* Inaccessible static: LIBRARY_NAME */ /* Inaccessible static: DEBUG */ /* Inaccessible static: _debug */ -/* Inaccessible static: class_00024org_00024lwjgl_00024Sys */ +/* Inaccessible static: class_000240 */ /* * Class: org_lwjgl_Sys * Method: getTimerResolution @@ -60,6 +60,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert (JNIEnv *, jclass, jstring, jstring); +/* + * Class: org_lwjgl_Sys + * Method: getDirectBufferAddress + * Signature: (Ljava/nio/Buffer;)I +JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_getDirectBufferAddress + (JNIEnv *, jclass, jobject); + */ + #ifdef __cplusplus } #endif diff --git a/src/native/win32/org_lwjgl_Display.cpp b/src/native/win32/org_lwjgl_Display.cpp index 2f93737c..a739c8b8 100644 --- a/src/native/win32/org_lwjgl_Display.cpp +++ b/src/native/win32/org_lwjgl_Display.cpp @@ -273,11 +273,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode // Return device gamma to normal HDC screenDC = GetDC(NULL); - if (!SetDeviceGammaRamp(screenDC, originalGamma)) { -#ifdef _DEBUG - printf("Could not reset device gamma\n"); -#endif - } + try { + if (!SetDeviceGammaRamp(screenDC, originalGamma)) { + #ifdef _DEBUG + printf("Could not reset device gamma\n"); + #endif + } + } catch (...) { + printf("Exception occurred in SetDeviceGammaRamp\n"); + } ReleaseDC(NULL, screenDC); if (modeSet) { @@ -296,11 +300,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode void tempResetDisplayMode() { // Return device gamma to normal HDC screenDC = GetDC(NULL); - if (!SetDeviceGammaRamp(screenDC, originalGamma)) { -#ifdef _DEBUG - printf("Could not reset device gamma\n"); -#endif - } + try { + if (!SetDeviceGammaRamp(screenDC, originalGamma)) { + #ifdef _DEBUG + printf("Could not reset device gamma\n"); + #endif + } + } catch (...) { + printf("Exception occurred in SetDeviceGammaRamp\n"); + } ReleaseDC(NULL, screenDC); if (modeSet) { @@ -319,11 +327,15 @@ void tempResetDisplayMode() { void tempRestoreDisplayMode() { // Restore gamma HDC screenDC = GetDC(NULL); - if (!SetDeviceGammaRamp(screenDC, currentGamma)) { -#ifdef _DEBUG - printf("Could not restore device gamma\n"); -#endif - } + try { + if (!SetDeviceGammaRamp(screenDC, currentGamma)) { + #ifdef _DEBUG + printf("Could not restore device gamma\n"); + #endif + } + } catch (...) { + printf("Exception occurred in SetDeviceGammaRamp\n"); + } ReleaseDC(NULL, screenDC); if (!modeSet) { @@ -374,13 +386,18 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_setGammaRamp } jboolean ret; HDC screenDC = GetDC(NULL); - if (SetDeviceGammaRamp(screenDC, currentGamma) == FALSE) { -#ifdef _DEBUG - printf("Failed to set device gamma\n"); -#endif + try { + if (SetDeviceGammaRamp(screenDC, currentGamma) == FALSE) { + #ifdef _DEBUG + printf("Failed to set device gamma\n"); + #endif + ret = JNI_FALSE; + } else { + ret = JNI_TRUE; + } + } catch (...) { + printf("Exception occurred in SetDeviceGammaRamp\n"); ret = JNI_FALSE; - } else { - ret = JNI_TRUE; } ReleaseDC(NULL, screenDC); @@ -419,10 +436,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_init env->DeleteLocalRef(newMode); // Get the default gamma ramp - if (GetDeviceGammaRamp(screenDC, originalGamma) == FALSE) { -#ifdef _DEBUG - printf("Failed to get initial device gamma\n"); -#endif + try { + if (GetDeviceGammaRamp(screenDC, originalGamma) == FALSE) { + #ifdef _DEBUG + printf("Failed to get initial device gamma\n"); + #endif + } + } catch (...) { + printf("Exception occurred in GetDeviceGammaRamp\n"); } ReleaseDC(NULL, screenDC); } diff --git a/src/native/win32/org_lwjgl_Sys.cpp b/src/native/win32/org_lwjgl_Sys.cpp index 906bd58d..17fe3484 100644 --- a/src/native/win32/org_lwjgl_Sys.cpp +++ b/src/native/win32/org_lwjgl_Sys.cpp @@ -141,3 +141,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert env->ReleaseStringUTFChars(message, eMessageText); env->ReleaseStringUTFChars(title, cTitleBarText); } + +// Cas: I've left this here as sometimes it's handy to just pop it back in to debug stuff +/* + * Class: org_lwjgl_Sys + * Method: getDirectBufferAddress + * Signature: (Ljava/nio/Buffer;)I +JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_getDirectBufferAddress + (JNIEnv * env, jclass clazz, jobject buf) +{ + return (jint) env->GetDirectBufferAddress(buf); +} + */