From 5c1e350d79bdcbf38b72df43d0f306026473335b Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 25 Oct 2018 23:32:00 +0000 Subject: [PATCH] sdlayer: don't add windowed modes that are larger than the monitor's actual resolution git-svn-id: https://svn.eduke32.com/eduke32@7115 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/sdlayer.cpp | 14 ++++++++++---- source/build/src/sdlayer12.cpp | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index b3c8c28ed..1cab8d2cb 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1184,19 +1184,25 @@ void videoGetModes(void) SDL_CHECKFSMODES(maxx, maxy); // add windowed modes next + // SDL sorts display modes largest to smallest, so we can just compare with mode 0 + // to make sure we aren't adding modes that are larger than the actual screen res + SDL_GetDisplayMode(0, 0, &dispmode); + for (i = 0; g_defaultVideoModes[i].x; i++) { - if (!SDL_CHECKMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y)) + auto const &mode = g_defaultVideoModes[i]; + + if (mode.x > dispmode.w || mode.y > dispmode.h || !SDL_CHECKMODE(mode.x, mode.y)) continue; - // HACK: 8-bit == Software, 32-bit == OpenGL - SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, 8, 0); + // 8-bit == Software, 32-bit == OpenGL + SDL_ADDMODE(mode.x, mode.y, 8, 0); #ifdef USE_OPENGL if (nogl) continue; - SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, 32, 0); + SDL_ADDMODE(mode.x, mode.y, 32, 0); #endif } diff --git a/source/build/src/sdlayer12.cpp b/source/build/src/sdlayer12.cpp index b70d68c7a..73bed584d 100644 --- a/source/build/src/sdlayer12.cpp +++ b/source/build/src/sdlayer12.cpp @@ -298,10 +298,11 @@ void videoGetModes(void) for (i = 0; g_defaultVideoModes[i].x; i++) { - if (!SDL_CHECKMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y)) + auto &mode = g_defaultVideoModes[i]; + if (mode.x > maxx || mode.y > maxy || !SDL_CHECKMODE(mode.x, mode.y)) continue; - SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, cdepths[j], 0); + SDL_ADDMODE(mode.x, mode.y, cdepths[j], 0); } }