Skip to content

Commit

Permalink
fix love.window.setMode failing to set an exclusive fullscreen mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Aug 18, 2024
1 parent 654585c commit ccdd789
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/window/sdl/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
Uint32 sdlflags = 0;
#if SDL_VERSION_ATLEAST(3, 0, 0)
const SDL_DisplayMode *fsmode = nullptr;
#else
SDL_DisplayMode fsmode = {0, width, height, 0, nullptr};
#endif

if (f.fullscreen)
Expand Down Expand Up @@ -608,8 +610,6 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
#else
if (f.fstype == FULLSCREEN_EXCLUSIVE)
{
SDL_DisplayMode fsmode = {0, width, height, 0, nullptr};

// Fullscreen window creation will bug out if no mode can be used.
if (SDL_GetClosestDisplayMode(f.displayindex, &fsmode, &fsmode) == nullptr)
{
Expand Down Expand Up @@ -642,12 +642,13 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
SDL_SetWindowFullscreenMode(window, fsmode);
if (SDL_SetWindowFullscreen(window, (sdlflags & SDL_WINDOW_FULLSCREEN) != 0) == 0 && renderer == graphics::RENDERER_OPENGL)
#else
if (f.fullscreen && f.fstype == FULLSCREEN_EXCLUSIVE)
SDL_SetWindowDisplayMode(window, &fsmode);
if (SDL_SetWindowFullscreen(window, sdlflags) == 0 && renderer == graphics::RENDERER_OPENGL)
#endif
SDL_GL_MakeCurrent(window, glcontext);

if (!f.fullscreen)
SDL_SetWindowSize(window, width, height);
SDL_SetWindowSize(window, width, height);

if (this->settings.resizable != f.resizable)
SDL_SetWindowResizable(window, f.resizable ? SDL_TRUE : SDL_FALSE);
Expand Down

0 comments on commit ccdd789

Please sign in to comment.