diff --git a/src/java/org/lwjgl/opengl/BaseGL.java b/src/java/org/lwjgl/opengl/BaseGL.java index 24b35dc1..107c4312 100644 --- a/src/java/org/lwjgl/opengl/BaseGL.java +++ b/src/java/org/lwjgl/opengl/BaseGL.java @@ -131,13 +131,14 @@ public class BaseGL extends Window { } protected void doCreate() throws Exception { - nCreate(x, y, getWidth(), getHeight(), color, alpha, depth, stencil, fullscreen); + nCreate(getTitle(), x, y, getWidth(), getHeight(), color, alpha, depth, stencil, fullscreen); } /** * Native method to create a windowed GL */ private native void nCreate( + String title, int x, int y, int width, diff --git a/src/java/org/lwjgl/opengl/GL.java b/src/java/org/lwjgl/opengl/GL.java index 7d6f1757..20ae8bbc 100644 --- a/src/java/org/lwjgl/opengl/GL.java +++ b/src/java/org/lwjgl/opengl/GL.java @@ -1669,8 +1669,10 @@ public class GL extends CoreGL implements GLConstants { final String exts; if (WGL_ARB_extensions_string) - exts = wglGetExtensionsStringARB(Display.getHandle()); - // Remember - this is an HWND not an HDC, which is what's required + exts = wglGetExtensionsStringARB(getHandle()); + // Remember - this is an HWND not an HDC, which is what's required. The native + // code on the other side of wglGetExtensionsStringARB gets the HDC from the HWND + // behind the scenes. else exts = wglGetExtensionsStringEXT(); diff --git a/src/native/common/org_lwjgl_opengl_BaseGL.h b/src/native/common/org_lwjgl_opengl_BaseGL.h index 6653ec57..ea7568c0 100644 --- a/src/native/common/org_lwjgl_opengl_BaseGL.h +++ b/src/native/common/org_lwjgl_opengl_BaseGL.h @@ -11,10 +11,10 @@ extern "C" { /* * Class: org_lwjgl_opengl_BaseGL * Method: nCreate - * Signature: (IIIIIIIIZ)V + * Signature: (Ljava/lang/String;IIIIIIIIZ)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate - (JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jint, jint, jboolean); + (JNIEnv *, jobject, jstring, jint, jint, jint, jint, jint, jint, jint, jint, jboolean); /* * Class: org_lwjgl_opengl_BaseGL diff --git a/src/native/win32/org_lwjgl_Window.cpp b/src/native/win32/org_lwjgl_Window.cpp index a550d20e..b727bb66 100644 --- a/src/native/win32/org_lwjgl_Window.cpp +++ b/src/native/win32/org_lwjgl_Window.cpp @@ -49,7 +49,7 @@ HDC hdc = NULL; // Device context LPDIRECTINPUT lpdi = NULL; // DirectInput bool isFullScreen = false; // Whether we're fullscreen or not bool isMinimized = false; // Whether we're minimized or not -JNIEnv * environment; // Cached environment +JNIEnv * environment = NULL; // Cached environment jobject window; // Cached Java Window instance handle extern HINSTANCE dll_handle; // Handle to the LWJGL dll @@ -106,7 +106,7 @@ void closeWindow() } // Release device context - if (hdc != NULL) { + if (hdc != NULL && hwnd != NULL) { ReleaseDC(hwnd, hdc); } @@ -143,6 +143,10 @@ LRESULT CALLBACK lwjglWindowProc(HWND hWnd, WPARAM wParam, LPARAM lParam) { + if (environment == NULL) { + printf("No environment!\n"); + return DefWindowProc(hWnd, msg, wParam, lParam); + } switch (msg) { // disable screen saver and monitor power down messages which wreak havoc @@ -289,6 +293,10 @@ bool createWindow(const char * title, int x, int y, int width, int height, bool return false; } +#ifdef _DEBUG + printf("Created window\n"); +#endif + ShowWindow(hwnd, SW_SHOWNORMAL); UpdateWindow(hwnd); SetForegroundWindow(hwnd); @@ -298,9 +306,6 @@ bool createWindow(const char * title, int x, int y, int width, int height, bool // Success! Now you need to initialize a GL object, which creates a GL rendering context; // and then to issue commands to it, you need to call gl::makeCurrent(). -#ifdef _DEBUG - printf("Created window\n"); -#endif // 3. Hide the mouse if necessary isFullScreen = fullscreen; diff --git a/src/native/win32/org_lwjgl_opengl_BaseGL.h b/src/native/win32/org_lwjgl_opengl_BaseGL.h deleted file mode 100644 index c7e0978f..00000000 --- a/src/native/win32/org_lwjgl_opengl_BaseGL.h +++ /dev/null @@ -1,23 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_lwjgl_opengl_BaseGL */ - -#ifndef _Included_org_lwjgl_opengl_BaseGL -#define _Included_org_lwjgl_opengl_BaseGL -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: currentWindow */ -/* Inaccessible static: currentContext */ -/* - * Class: org_lwjgl_opengl_BaseGL - * Method: nCreate - * Signature: (Ljava/lang/String;IIIIZ)V - */ -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate - (JNIEnv *, jobject, jstring, jint, jint, jint, jint, jboolean); - -#ifdef __cplusplus -} -#endif -#endif