|
From: Elias N. <eli...@us...> - 2005-01-29 10:18:11
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27207/src/native/win32 Modified Files: Window.h org_lwjgl_Sys.c org_lwjgl_opengl_Display.c org_lwjgl_opengl_Pbuffer.c Log Message: Win32: Better Sys.alert fix Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_opengl_Pbuffer.c 19 Jan 2005 13:15:44 -0000 1.7 +++ org_lwjgl_opengl_Pbuffer.c 29 Jan 2005 10:17:56 -0000 1.8 @@ -97,21 +97,21 @@ return NULL; } if (!applyPixelFormat(dummy_hdc, iPixelFormat)) { - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "Could not apply pixel format to window"); return NULL; } dummy_hglrc = wglCreateContext(dummy_hdc); if (dummy_hglrc == NULL) { - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "Failed to create OpenGL rendering context"); return NULL; } result = wglMakeCurrent(dummy_hdc, dummy_hglrc); if (!result) { wglDeleteContext(dummy_hglrc); - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "Could not bind context to dummy window"); return NULL; } @@ -122,17 +122,17 @@ iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true); wglDeleteContext(dummy_hglrc); if (!pbuffers_supported) { - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "No Pbuffer support."); return NULL; } if (iPixelFormat == -1) { - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "Could not find suitable pixel format."); return NULL; } Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribs_ptr); - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); return Pbuffer; } Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_opengl_Display.c 27 Jan 2005 21:26:46 -0000 1.6 +++ org_lwjgl_opengl_Display.c 29 Jan 2005 10:17:56 -0000 1.7 @@ -265,21 +265,21 @@ /* * Close the window */ -void closeWindow(HWND hwnd, HDC hdc) +void closeWindow(HWND *hwnd, HDC *hdc) { // Release device context - if (hdc != NULL && hwnd != NULL) { + if (*hdc != NULL && *hwnd != NULL) { printfDebug("Releasing DC\n"); - ReleaseDC(hwnd, hdc); - hdc = NULL; + ReleaseDC(*hwnd, *hdc); + *hdc = NULL; } // Close the window - if (hwnd != NULL) { - ShowWindow(hwnd, SW_HIDE); + if (*hwnd != NULL) { + ShowWindow(*hwnd, SW_HIDE); printfDebug("Destroy window\n"); - DestroyWindow(hwnd); - hwnd = NULL; + DestroyWindow(*hwnd); + *hwnd = NULL; } } @@ -655,7 +655,7 @@ } display_hdc = GetDC(display_hwnd); if (!applyPixelFormat(display_hdc, pixel_format_index)) { - closeWindow(display_hwnd, display_hdc); + closeWindow(&display_hwnd, &display_hdc); throwException(env, "Could not apply pixel format to window"); return; } @@ -667,7 +667,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyWindow(JNIEnv *env, jobject self) { - closeWindow(display_hwnd, display_hdc); + closeWindow(&display_hwnd, &display_hdc); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_switchDisplayMode(JNIEnv *env, jobject self, jobject mode) { @@ -723,12 +723,12 @@ arb_hdc = GetDC(arb_hwnd); if ( !applyPixelFormat(arb_hdc, pixel_format_index) ) { - closeWindow(arb_hwnd, arb_hdc); + closeWindow(&arb_hwnd, &arb_hdc); return false; } arb_context = wglCreateContext(arb_hdc); - closeWindow(arb_hwnd, arb_hdc); + closeWindow(&arb_hwnd, &arb_hdc); if ( arb_context == NULL ) return false; @@ -764,13 +764,13 @@ return; } if (!applyPixelFormat(dummy_hdc, pixel_format_index)) { - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "Could not apply pixel format to window"); return; } display_hglrc = wglCreateContext(dummy_hdc); if (display_hglrc == NULL) { - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); throwException(env, "Failed to create OpenGL rendering context"); return; } @@ -778,7 +778,7 @@ if (!result) { throwException(env, "Could not bind context to dummy window"); wglDeleteContext(display_hglrc); - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); return; } extgl_InitWGL(env); @@ -786,7 +786,7 @@ samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); if (samples > 0) { arb_success = createARBContextAndPixelFormat(env, dummy_hdc, pixel_format, &pixel_format_index_arb, &context_arb); - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); wglDeleteContext(display_hglrc); if (!arb_success) { throwException(env, "Samples > 0 but could not find a suitable ARB pixel format"); @@ -795,7 +795,7 @@ display_hglrc = context_arb; pixel_format_index = pixel_format_index_arb; } else - closeWindow(dummy_hwnd, dummy_hdc); + closeWindow(&dummy_hwnd, &dummy_hdc); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyContext(JNIEnv *env, jobject self) { Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Window.h 26 Oct 2004 20:07:24 -0000 1.21 +++ Window.h 29 Jan 2005 10:17:56 -0000 1.22 @@ -66,7 +66,7 @@ WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat); - WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc); + WINDOW_H_API void closeWindow(HWND *hwnd, HDC *hdc); WINDOW_H_API void handleMouseMoved(int x, int y); @@ -101,10 +101,4 @@ */ WINDOW_H_API void handleMessage(JNIEnv * env, jobject obj); - - /* - * Close the window - */ - WINDOW_H_API void closeWindow(); - #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Index: org_lwjgl_Sys.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Sys.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_Sys.c 28 Jan 2005 22:42:23 -0000 1.7 +++ org_lwjgl_Sys.c 29 Jan 2005 10:17:56 -0000 1.8 @@ -82,7 +82,7 @@ { char * eMessageText = GetStringNativeChars(env, message); char * cTitleBarText = GetStringNativeChars(env, title); - MessageBox(NULL, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); + MessageBox(getCurrentHWND(), eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); printfDebug("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText); |