From 450ff067cf43cbc28738eab55357c355cacb245d Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 14 Dec 2002 15:23:53 +0000 Subject: [PATCH] Added a standard system error output --- src/native/win32/org_lwjgl_Display.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/native/win32/org_lwjgl_Display.cpp b/src/native/win32/org_lwjgl_Display.cpp index bc23ac8d..3b233bfe 100644 --- a/src/native/win32/org_lwjgl_Display.cpp +++ b/src/native/win32/org_lwjgl_Display.cpp @@ -55,6 +55,23 @@ HWND hwnd = NULL; // Handle to the window HDC hdc = NULL; // Device context LPDIRECTINPUT lpdi = NULL; +void dumpLastError(void) { + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + 0, // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL + ); + printf("System error: %s\n", lpMsgBuf); + LocalFree(lpMsgBuf); +} + /* * A dummy WindowProc which does nothing. Used so we can have an invisible OpenGL window */ @@ -179,7 +196,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate #ifdef _DEBUG printf("Creating display: size %dx%d %dhz %dbpp...\n", width, height, freq, bpp); #endif - if (fullscreen && SetDisplayMode(width, height, bpp, freq) != 1) return JNI_FALSE; @@ -187,7 +203,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate Register a window. This window does nothing, it's just a requirement that we get a handle to it so we can do other things */ - if (!oneShotInitialised) { WNDCLASS windowClass; @@ -203,6 +218,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate windowClass.lpszClassName = WINDOWCLASSNAME; if (RegisterClass(&windowClass) == 0) { + dumpLastError(); printf("Failed to register window class\n"); return JNI_FALSE; }