From d4aa34e4f581dc7f3e6fc3946540c562cf60be1e Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 3 Jul 2004 16:07:00 +0000 Subject: [PATCH] *** empty log message *** --- src/java/org/lwjgl/opengl/Display.java | 1 + src/native/win32/org_lwjgl_opengl_Display.cpp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index b07cd4d6..9261d83a 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -508,6 +508,7 @@ public final class Display { context = null; if (fullscreen) resetDisplayMode(); + throw e; } makeCurrent(); initContext(); diff --git a/src/native/win32/org_lwjgl_opengl_Display.cpp b/src/native/win32/org_lwjgl_opengl_Display.cpp index fb449482..266fc251 100644 --- a/src/native/win32/org_lwjgl_opengl_Display.cpp +++ b/src/native/win32/org_lwjgl_opengl_Display.cpp @@ -615,7 +615,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nCreateWindow(JNIEnv *env, return; } - wglMakeCurrent(hdc, hglrc); + BOOL result = wglMakeCurrent(hdc, hglrc); + if (!result) { + printf("Could not bind context to window %d %d\n", GetLastError(), pixel_format_index); + throwException(env, "Could not bind context to window"); + closeWindow(); + return; + } extgl_InitWGL(env); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); @@ -685,13 +691,20 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_createContext(JNIEnv *env, extgl_Close(); return; } - wglMakeCurrent(hdc, hglrc); + BOOL result = wglMakeCurrent(hdc, hglrc); + if (!result) { + throwException(env, "Could not bid context to dummy window"); + wglDeleteContext(hglrc); + closeWindow(); + return; + } // Some crazy strangeness here so we can use ARB_pixel_format to specify the number // of multisamples we want. If the extension is present we'll delete the existing // rendering context and start over, using the ARB extension instead to pick the context. extgl_InitWGL(env); if (extgl_Extensions.WGL_ARB_pixel_format) { pixel_format_index = findPixelFormatARB(env, pixel_format, NULL, true, true, true); + printf("pixel format %d\n", pixel_format_index); wglMakeCurrent(NULL, NULL); wglDeleteContext(hglrc); hglrc = wglCreateContext(hdc);