1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Rewritten video mode check.

* check only for current desktop display mode, because we are not using actual fullscreen
* also old check was wrong
This commit is contained in:
AlexVinS 2016-08-30 03:27:53 +03:00
parent fb7ff8c7fa
commit 2018b4d406

View File

@ -927,16 +927,25 @@ void dispose()
} }
} }
static bool checkVideoMode(int monitorIndex, int w, int h, int& bpp, bool fullscreen) static bool checkVideoMode(int monitorIndex, int w, int h)
{ {
//we only check that our desired window size fits on screen
SDL_DisplayMode mode; SDL_DisplayMode mode;
const int modeCount = SDL_GetNumDisplayModes(monitorIndex);
for (int i = 0; i < modeCount; i++) { if (0 != SDL_GetDesktopDisplayMode(monitorIndex, &mode))
SDL_GetDisplayMode(0, i, &mode); {
if (!mode.w || !mode.h || (w >= mode.w && h >= mode.h)) { logGlobal->error("SDL_GetDesktopDisplayMode failed");
return true; logGlobal->error(SDL_GetError());
} return false;
} }
logGlobal->info("Check display mode: requested %d x %d; available up to %d x %d ", w, h, mode.w, mode.h);
if (!mode.w || !mode.h || (w <= mode.w && h <= mode.h))
{
return true;
}
return false; return false;
} }
@ -948,9 +957,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
if(bpp>16) if(bpp>16)
bpp = 32; bpp = 32;
int suggestedBpp = bpp; if(!checkVideoMode(0,w,h))
if(!checkVideoMode(0,w,h,suggestedBpp,fullscreen))
{ {
logGlobal->errorStream() << "Error: SDL says that " << w << "x" << h << " resolution is not available!"; logGlobal->errorStream() << "Error: SDL says that " << w << "x" << h << " resolution is not available!";
return false; return false;