Update of /cvsroot/java-game-lib/LWJGL/src/native/win32
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32376/src/native/win32
Modified Files:
display.cpp display.h org_lwjgl_opengl_Display.cpp
Log Message:
Win32: reset/restore display mode when activated/deactivated
Index: display.cpp
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/display.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- display.cpp 15 Sep 2004 17:07:06 -0000 1.4
+++ display.cpp 22 Sep 2004 18:21:28 -0000 1.5
@@ -232,48 +232,6 @@
modeSet = true;
}
-/*
- * Temporarily reset display settings. This is called when the window is minimized.
- */
-/*static void tempResetDisplayMode() {
- // Return device gamma to normal
- HDC screenDC = GetDC(NULL);
- if (!SetDeviceGammaRamp(screenDC, originalGamma)) {
- printfDebug("Could not reset device gamma\n");
- }
- ReleaseDC(NULL, screenDC);
-
- if (modeSet) {
- printfDebug("Attempting to temporarily reset the display mode\n");
- modeSet = false;
- // Under Win32, all we have to do is:
- ChangeDisplaySettings(NULL, 0);
- }
-}
-*/
-/*
- * Put display settings back to what they were when the window is maximized.
- */
-/*static void tempRestoreDisplayMode() {
- // Restore gamma
- HDC screenDC = GetDC(NULL);
- if (!SetDeviceGammaRamp(screenDC, currentGamma)) {
- printfDebug("Could not restore device gamma\n");
- }
- ReleaseDC(NULL, screenDC);
-
- if (!modeSet) {
- printfDebug("Attempting to restore the display mode\n");
- modeSet = true;
- LONG cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);
-
- if (cdsret != DISP_CHANGE_SUCCESSFUL) {
- printfDebug("Failed to restore display mode\n");
- }
- }
-}
-*/
-
int getGammaRampLength(void)
{
return 256;
@@ -328,9 +286,7 @@
return newMode;
}
-void resetDisplayMode(JNIEnv * env)
-{
-
+void resetDisplayMode(JNIEnv * env) {
// Return device gamma to normal
HDC screenDC = GetDC(NULL);
if (!SetDeviceGammaRamp(screenDC, originalGamma)) {
@@ -344,7 +300,30 @@
ChangeDisplaySettings(NULL, 0);
// And we'll call init() again to put the correct mode back in Display
- initDisplay(env);
+ if (env != NULL)
+ initDisplay(env);
+ }
+}
+
+/*
+ * Put display settings back to what they were when the window is maximized.
+ */
+void restoreDisplayMode(void) {
+ // Restore gamma
+ HDC screenDC = GetDC(NULL);
+ if (!SetDeviceGammaRamp(screenDC, currentGamma)) {
+ printfDebug("Could not restore device gamma\n");
+ }
+ ReleaseDC(NULL, screenDC);
+
+ if (!modeSet) {
+ printfDebug("Attempting to restore the display mode\n");
+ modeSet = true;
+ LONG cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);
+
+ if (cdsret != DISP_CHANGE_SUCCESSFUL) {
+ printfDebug("Failed to restore display mode\n");
+ }
}
}
Index: display.h
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/display.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- display.h 3 Jul 2004 14:41:06 -0000 1.2
+++ display.h 22 Sep 2004 18:21:28 -0000 1.3
@@ -47,6 +47,7 @@
extern jobjectArray getAvailableDisplayModes(JNIEnv *env);
extern void switchDisplayMode(JNIEnv * env, jobject mode);
extern void resetDisplayMode(JNIEnv * env);
+extern void restoreDisplayMode(void);
extern int getGammaRampLength(void);
extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer);
extern jobject initDisplay(JNIEnv * env);
Index: org_lwjgl_opengl_Display.cpp
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- org_lwjgl_opengl_Display.cpp 22 Sep 2004 15:06:27 -0000 1.25
+++ org_lwjgl_opengl_Display.cpp 22 Sep 2004 18:21:28 -0000 1.26
@@ -284,10 +284,13 @@
static void appActivate(bool active)
{
if (active) {
+ if (isFullScreen)
+ restoreDisplayMode();
SetForegroundWindow(display_hwnd);
ShowWindow(display_hwnd, SW_RESTORE);
} else if (isFullScreen) {
ShowWindow(display_hwnd, SW_MINIMIZE);
+ resetDisplayMode(NULL);
}
}
|