summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-11-25 12:14:13 +0000
committermichi_cc <michi_cc@openttd.org>2012-11-25 12:14:13 +0000
commite67c717c2f167e5763ebc8dc730d8681ea768e6e (patch)
tree4f6e0f9684fba2d0054cb4aba5ddf2e22fd3552c /src/video
parent1791551391805d9f5b8e959f568ccfc03f33dc21 (diff)
downloadopenttd-e67c717c2f167e5763ebc8dc730d8681ea768e6e.tar.xz
(svn r24762) -Fix [FS#5359]: [Win32] Don't crash when switching to an unsupported fullscreen display mode (like 8 bpp modes in Windows 8).
Diffstat (limited to 'src/video')
-rw-r--r--src/video/win32_v.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index beeef29fe..6fb8a6b9d 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -282,11 +282,20 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen)
settings.dmPelsHeight = _wnd.height_org;
settings.dmDisplayFrequency = _display_hz;
+ /* Check for 8 bpp support. */
+ if (settings.dmBitsPerPel != 32 && ChangeDisplaySettings(&settings, CDS_FULLSCREEN | CDS_TEST) != DISP_CHANGE_SUCCESSFUL) {
+ settings.dmBitsPerPel = 32;
+ }
+
/* Test fullscreen with current resolution, if it fails use desktop resolution. */
if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN | CDS_TEST) != DISP_CHANGE_SUCCESSFUL) {
RECT r;
GetWindowRect(GetDesktopWindow(), &r);
- return this->ChangeResolution(r.right - r.left, r.bottom - r.top);
+ /* Guard against recursion. If we already failed here once, just fall through to
+ * the next ChangeDisplaySettings call which will fail and error out appropriately. */
+ if (settings.dmPelsWidth != r.right - r.left || settings.dmPelsHeight != r.bottom - r.top) {
+ return this->ChangeResolution(r.right - r.left, r.bottom - r.top);
+ }
}
if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {