Browse Source

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.

Alex Szpakowski 11 years ago
parent
commit
eaad102f5c
1 changed files with 12 additions and 3 deletions
  1. 12 3
      src/modules/window/sdl/Window.cpp

+ 12 - 3
src/modules/window/sdl/Window.cpp

@@ -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;
 		}
 	}