|
From: Elias N. <eli...@us...> - 2003-10-24 05:58:45
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv31990/macosx Modified Files: Window.h org_lwjgl_Display.cpp org_lwjgl_opengl_Window.cpp Log Message: Index: Window.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Window.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Window.h 22 Oct 2003 10:57:18 -0000 1.8 +++ Window.h 24 Oct 2003 05:51:50 -0000 1.9 @@ -44,9 +44,8 @@ #include <jni.h> #include <Carbon/Carbon.h> - extern void setQuitRequested(void); extern void resetMode(JNIEnv *env); - extern void switchMode(JNIEnv *env, long width, long height, long bpp, long freq); + extern bool switchMode(JNIEnv *env, long width, long height, long bpp, long freq); extern void handleKeyboardEvent(EventRef event); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_Display.cpp 22 Oct 2003 18:34:42 -0000 1.23 +++ org_lwjgl_Display.cpp 24 Oct 2003 05:51:50 -0000 1.24 @@ -93,12 +93,30 @@ } } -void switchMode(JNIEnv *env, long width, long height, long bpp, long freq) { +bool switchMode(JNIEnv *env, long width, long height, long bpp, long freq) { init(env); captureDisplay(); - CFDictionaryRef displayMode = CGDisplayBestModeForParametersAndRefreshRate(kCGDirectMainDisplay, bpp, width, height, freq, NULL); - CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode); - saveMode(env, width, height, bpp, freq); + CFArrayRef modes = CGDisplayAvailableModes(kCGDirectMainDisplay); + int size = CFArrayGetCount(modes); + for (int i = 0; i < size; i++) { + CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i); + long mode_width; + long mode_height; + long mode_bpp; + long mode_freq; + getDictLong(mode, kCGDisplayWidth, &mode_width); + getDictLong(mode, kCGDisplayHeight, &mode_height); + getDictLong(mode, kCGDisplayRefreshRate, &mode_freq); + getDictLong(mode, kCGDisplayBitsPerPixel, &mode_bpp); + if (width == mode_width && height == mode_height && bpp == mode_bpp && mode_freq == freq) { + CGDisplayErr err = CGDisplaySwitchToMode(kCGDirectMainDisplay, mode); + if (!err) { + saveMode(env, width, height, bpp, freq); + return true; + } + } + } + return false; } void resetMode(JNIEnv *env) { @@ -123,7 +141,9 @@ int height = env->GetIntField(mode, fid_height); int bpp = env->GetIntField(mode, fid_bpp); int freq = env->GetIntField(mode, fid_freq); - switchMode(env, width, height, bpp, freq); + if (!switchMode(env, width, height, bpp, freq)) { + throwException(env, "Could not switch mode."); + } } JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes(JNIEnv * env, jclass clazz) { Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- org_lwjgl_opengl_Window.cpp 22 Oct 2003 10:57:19 -0000 1.25 +++ org_lwjgl_opengl_Window.cpp 24 Oct 2003 05:51:50 -0000 1.26 @@ -103,7 +103,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil, jobject ext_set) { vsync_enabled = false; - current_fullscreen = fullscreen == JNI_FALSE; + current_fullscreen = fullscreen == JNI_TRUE; if (!extgl_Open()) { throwException(env, "Could not load gl library"); return; @@ -112,8 +112,14 @@ throwException(env, "Could not load agl symbols"); return; } - if (current_fullscreen) - switchMode(env, width, height, bpp, 60); + if (!current_fullscreen) { + if (!switchMode(env, width, height, bpp, 60)) { + destroyMode(env, clazz); + extgl_Close(); + throwException(env, "Could not switch mode."); + return; + } + } if (!createFullscreenContext(env, bpp, alpha, depth, stencil)) { destroyMode(env, clazz); extgl_Close(); |