Win32: Better Sys.alert fix
This commit is contained in:
parent
70fc843321
commit
63da8a93e4
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat);
|
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);
|
WINDOW_H_API void handleMouseMoved(int x, int y);
|
||||||
|
|
||||||
|
@ -101,10 +101,4 @@
|
||||||
*/
|
*/
|
||||||
WINDOW_H_API void handleMessage(JNIEnv * env, jobject obj);
|
WINDOW_H_API void handleMessage(JNIEnv * env, jobject obj);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Close the window
|
|
||||||
*/
|
|
||||||
WINDOW_H_API void closeWindow();
|
|
||||||
|
|
||||||
#endif /* _LWJGL_WINDOW_H_INCLUDED_ */
|
#endif /* _LWJGL_WINDOW_H_INCLUDED_ */
|
||||||
|
|
|
@ -82,7 +82,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_NativeSysImplementation_alert
|
||||||
{
|
{
|
||||||
char * eMessageText = GetStringNativeChars(env, message);
|
char * eMessageText = GetStringNativeChars(env, message);
|
||||||
char * cTitleBarText = GetStringNativeChars(env, title);
|
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);
|
printfDebug("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
|
||||||
|
|
||||||
|
|
|
@ -265,21 +265,21 @@ int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format) {
|
||||||
/*
|
/*
|
||||||
* Close the window
|
* Close the window
|
||||||
*/
|
*/
|
||||||
void closeWindow(HWND hwnd, HDC hdc)
|
void closeWindow(HWND *hwnd, HDC *hdc)
|
||||||
{
|
{
|
||||||
// Release device context
|
// Release device context
|
||||||
if (hdc != NULL && hwnd != NULL) {
|
if (*hdc != NULL && *hwnd != NULL) {
|
||||||
printfDebug("Releasing DC\n");
|
printfDebug("Releasing DC\n");
|
||||||
ReleaseDC(hwnd, hdc);
|
ReleaseDC(*hwnd, *hdc);
|
||||||
hdc = NULL;
|
*hdc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the window
|
// Close the window
|
||||||
if (hwnd != NULL) {
|
if (*hwnd != NULL) {
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
ShowWindow(*hwnd, SW_HIDE);
|
||||||
printfDebug("Destroy window\n");
|
printfDebug("Destroy window\n");
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(*hwnd);
|
||||||
hwnd = NULL;
|
*hwnd = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createWindow(JNIEnv *e
|
||||||
}
|
}
|
||||||
display_hdc = GetDC(display_hwnd);
|
display_hdc = GetDC(display_hwnd);
|
||||||
if (!applyPixelFormat(display_hdc, pixel_format_index)) {
|
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");
|
throwException(env, "Could not apply pixel format to window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -667,7 +667,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createWindow(JNIEnv *e
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyWindow(JNIEnv *env, jobject self) {
|
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) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_switchDisplayMode(JNIEnv *env, jobject self, jobject mode) {
|
||||||
|
@ -723,12 +723,12 @@ static bool createARBContextAndPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_f
|
||||||
|
|
||||||
arb_hdc = GetDC(arb_hwnd);
|
arb_hdc = GetDC(arb_hwnd);
|
||||||
if ( !applyPixelFormat(arb_hdc, pixel_format_index) ) {
|
if ( !applyPixelFormat(arb_hdc, pixel_format_index) ) {
|
||||||
closeWindow(arb_hwnd, arb_hdc);
|
closeWindow(&arb_hwnd, &arb_hdc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
arb_context = wglCreateContext(arb_hdc);
|
arb_context = wglCreateContext(arb_hdc);
|
||||||
closeWindow(arb_hwnd, arb_hdc);
|
closeWindow(&arb_hwnd, &arb_hdc);
|
||||||
if ( arb_context == NULL )
|
if ( arb_context == NULL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -764,13 +764,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createContext(JNIEnv *
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!applyPixelFormat(dummy_hdc, pixel_format_index)) {
|
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");
|
throwException(env, "Could not apply pixel format to window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
display_hglrc = wglCreateContext(dummy_hdc);
|
display_hglrc = wglCreateContext(dummy_hdc);
|
||||||
if (display_hglrc == NULL) {
|
if (display_hglrc == NULL) {
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
throwException(env, "Failed to create OpenGL rendering context");
|
throwException(env, "Failed to create OpenGL rendering context");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -778,7 +778,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createContext(JNIEnv *
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throwException(env, "Could not bind context to dummy window");
|
throwException(env, "Could not bind context to dummy window");
|
||||||
wglDeleteContext(display_hglrc);
|
wglDeleteContext(display_hglrc);
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
extgl_InitWGL(env);
|
extgl_InitWGL(env);
|
||||||
|
@ -786,7 +786,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createContext(JNIEnv *
|
||||||
samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
|
samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I"));
|
||||||
if (samples > 0) {
|
if (samples > 0) {
|
||||||
arb_success = createARBContextAndPixelFormat(env, dummy_hdc, pixel_format, &pixel_format_index_arb, &context_arb);
|
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);
|
wglDeleteContext(display_hglrc);
|
||||||
if (!arb_success) {
|
if (!arb_success) {
|
||||||
throwException(env, "Samples > 0 but could not find a suitable ARB pixel format");
|
throwException(env, "Samples > 0 but could not find a suitable ARB pixel format");
|
||||||
|
@ -795,7 +795,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createContext(JNIEnv *
|
||||||
display_hglrc = context_arb;
|
display_hglrc = context_arb;
|
||||||
pixel_format_index = pixel_format_index_arb;
|
pixel_format_index = pixel_format_index_arb;
|
||||||
} else
|
} else
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyContext(JNIEnv *env, jobject self) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyContext(JNIEnv *env, jobject self) {
|
||||||
|
|
|
@ -97,21 +97,21 @@ static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pix
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!applyPixelFormat(dummy_hdc, iPixelFormat)) {
|
if (!applyPixelFormat(dummy_hdc, iPixelFormat)) {
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
throwException(env, "Could not apply pixel format to window");
|
throwException(env, "Could not apply pixel format to window");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dummy_hglrc = wglCreateContext(dummy_hdc);
|
dummy_hglrc = wglCreateContext(dummy_hdc);
|
||||||
if (dummy_hglrc == NULL) {
|
if (dummy_hglrc == NULL) {
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
throwException(env, "Failed to create OpenGL rendering context");
|
throwException(env, "Failed to create OpenGL rendering context");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result = wglMakeCurrent(dummy_hdc, dummy_hglrc);
|
result = wglMakeCurrent(dummy_hdc, dummy_hglrc);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
wglDeleteContext(dummy_hglrc);
|
wglDeleteContext(dummy_hglrc);
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
throwException(env, "Could not bind context to dummy window");
|
throwException(env, "Could not bind context to dummy window");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -122,17 +122,17 @@ static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pix
|
||||||
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true);
|
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true);
|
||||||
wglDeleteContext(dummy_hglrc);
|
wglDeleteContext(dummy_hglrc);
|
||||||
if (!pbuffers_supported) {
|
if (!pbuffers_supported) {
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
throwException(env, "No Pbuffer support.");
|
throwException(env, "No Pbuffer support.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (iPixelFormat == -1) {
|
if (iPixelFormat == -1) {
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
throwException(env, "Could not find suitable pixel format.");
|
throwException(env, "Could not find suitable pixel format.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribs_ptr);
|
Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribs_ptr);
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(&dummy_hwnd, &dummy_hdc);
|
||||||
return Pbuffer;
|
return Pbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue