foxygit / doom Log in
commit 9de2b29cdc8e85c525589badc5af636005ca8e66
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Wed Nov 24 23:34:18 2010 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Wed Nov 24 23:34:18 2010 +0000

    Detect when running on Windows Vista or later, and switch to 32 bpp
    screen mode.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 2167
---
 setup/configfile.c | 21 +++++++++++++++++++++
 src/m_config.c     | 21 +++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/setup/configfile.c b/setup/configfile.c
index 885bbd8f..c4e8a408 100644
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -768,5 +768,26 @@ void M_ApplyPlatformDefaults(void)
         }
     }
 #endif
+
+    // Windows Vista or later?  Set screen color depth to
+    // 32 bits per pixel, as 8-bit palettized screen modes
+    // don't work properly in recent versions.
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+    {
+        OSVERSIONINFOEX version_info;
+
+        ZeroMemory(&version_info, sizeof(OSVERSIONINFOEX));
+        version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+
+        GetVersionEx((OSVERSIONINFO *) &version_info);
+
+        if (version_info.dwPlatformId == VER_PLATFORM_WIN32_NT
+         && version_info.dwMajorVersion >= 6)
+        {
+            screen_bpp = 32;
+        }
+    }
+#endif
 }

diff --git a/src/m_config.c b/src/m_config.c
index a4cacd95..3abe7c63 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1598,5 +1598,26 @@ void M_ApplyPlatformDefaults(void)
         }
     }
 #endif
+
+    // Windows Vista or later?  Set screen color depth to
+    // 32 bits per pixel, as 8-bit palettized screen modes
+    // don't work properly in recent versions.
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+    {
+        OSVERSIONINFOEX version_info;
+
+        ZeroMemory(&version_info, sizeof(OSVERSIONINFOEX));
+        version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+
+        GetVersionEx((OSVERSIONINFO *) &version_info);
+
+        if (version_info.dwPlatformId == VER_PLATFORM_WIN32_NT
+         && version_info.dwMajorVersion >= 6)
+        {
+            screen_bpp = 32;
+        }
+    }
+#endif
 }