Big changes for the new 0.6 LWJGL release

This commit is contained in:
Caspian Rychlik-Prince 2003-03-28 23:16:15 +00:00
parent 07fdc052e0
commit 157e7673cc
5 changed files with 42 additions and 9 deletions

View File

@ -139,7 +139,7 @@ public final class Display {
* Reset the display mode to whatever it was when LWJGL was initialized.
* Fails silently.
*/
public static native void resetDisplayMode() throws Exception;
public static native void resetDisplayMode();
/**
* Retrieves the width of the created display

View File

@ -184,7 +184,7 @@ public abstract class Window {
/**
* Destroy the window.
*/
public final void destroy() {
public final synchronized void destroy() {
if (!created)
return;
doDestroy();
@ -239,4 +239,10 @@ public abstract class Window {
return "Window["+title+"]";
}
/**
* @return the current window, or null, if there is no current window
*/
public static Window getCurrentWindow() {
return currentWindow;
}
}

View File

@ -46,7 +46,7 @@
jobjectArray GetAvailableDisplayModesNT(JNIEnv * env);
jobjectArray GetAvailableDisplayModes9x(JNIEnv * env);
bool modeSet = false; // Whether we've done a display mode change
/*
@ -254,6 +254,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode
env->SetStaticObjectField(clazz, fid_initialMode, newMode);
env->DeleteLocalRef(newMode);
modeSet = true;
}
/*
@ -264,11 +265,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode
JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode
(JNIEnv * env, jclass clazz)
{
// Under Win32, all we have to do is:
ChangeDisplaySettings(NULL, 0);
if (modeSet) {
modeSet = false;
// Under Win32, all we have to do is:
ChangeDisplaySettings(NULL, 0);
// And we'll call init() again to put the correct mode back in Display
Java_org_lwjgl_Display_init(env, clazz);
// And we'll call init() again to put the correct mode back in Display
Java_org_lwjgl_Display_init(env, clazz);
}
}
/*

View File

@ -101,19 +101,31 @@ void closeWindow()
{
// Release DirectInput
if (lpdi != NULL) {
#ifdef _DEBUG
printf("Destroying directinput\n");
#endif
lpdi->Release();
lpdi = NULL;
}
// Release device context
if (hdc != NULL && hwnd != NULL) {
#ifdef _DEBUG
printf("Releasing DC\n");
#endif
ReleaseDC(hwnd, hdc);
}
// Close the window
if (hwnd != NULL) {
#ifdef _DEBUG
printf("Destroy window\n");
#endif
// Vape the window
DestroyWindow(hwnd);
#ifdef _DEBUG
printf("Destroyed window\n");
#endif
hwnd = NULL;
}
@ -144,7 +156,6 @@ LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
LPARAM lParam)
{
if (environment == NULL) {
printf("No environment!\n");
return DefWindowProc(hWnd, msg, wParam, lParam);
}
@ -227,7 +238,9 @@ bool registerWindow()
printf("Failed to register window class\n");
return false;
}
#ifdef _DEBUG
printf("Window registered\n");
#endif
oneShotInitialised = true;
}
@ -308,7 +321,7 @@ bool createWindow(const char * title, int x, int y, int width, int height, bool
// and then to issue commands to it, you need to call gl::makeCurrent().
// 3. Hide the mouse if necessary
isFullScreen = fullscreen;
isFullScreen = fullscreen == JNI_TRUE;
if (isFullScreen) {
ShowCursor(FALSE);
}
@ -356,7 +369,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Window_swapBuffers
JNIEXPORT void JNICALL Java_org_lwjgl_Window_nDestroy
(JNIEnv * env, jobject obj)
{
// Cache env and obj
environment = env;
window = obj;
closeWindow();
environment = NULL;
window = NULL;
}
/*

View File

@ -198,6 +198,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nDestroyGL
// Delete the rendering context
if (hglrc != NULL) {
#ifdef _DEBUG
printf("Delete GL context\n");
#endif
wglDeleteContext(hglrc);
hglrc = NULL;
}