Calling love.window.setMode with fullscreen=true and a width or height larger than the largest fullscreen mode now falls back to the largest fullscreen mode instead of failing and returning false.

This commit is contained in:
Alex Szpakowski
2014-07-30 01:22:01 -03:00
parent c6c32dee17
commit eaad102f5c
+12 -3
View File
@@ -98,11 +98,20 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
else
{
sdlflags |= SDL_WINDOW_FULLSCREEN;
SDL_DisplayMode mode = {0, width, height, 0, 0};
// Fullscreen window creation will bug out if no mode can be used.
SDL_DisplayMode mode = {0, width, height, 0, 0};
if (SDL_GetClosestDisplayMode(f.display, &mode, &mode) == 0)
return false;
if (SDL_GetClosestDisplayMode(f.display, &mode, &mode) == nullptr)
{
// GetClosestDisplayMode will fail if we request a size larger
// than the largest available display mode, so we'll try to use
// the largest (first) mode in that case.
if (SDL_GetDisplayMode(f.display, 0, &mode) < 0)
return false;
}
width = mode.w;
height = mode.h;
}
}