From 067472d61b6caf898e472fc1b6703c0c52ba9817 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Tue, 12 Jan 2021 14:05:22 +0100 Subject: [PATCH] avoid creating a (0,0)-sized window at the start --- BBGE/Window_SDL2.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/BBGE/Window_SDL2.cpp b/BBGE/Window_SDL2.cpp index 1534527..ac1027c 100644 --- a/BBGE/Window_SDL2.cpp +++ b/BBGE/Window_SDL2.cpp @@ -74,14 +74,27 @@ void Window::_open(unsigned w, unsigned h, bool full, unsigned bpp, bool vsync, Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; if(full) { - if(!w && !h) + if(!w || !h) flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; else flags |= SDL_WINDOW_FULLSCREEN; } + unsigned usew = w; + unsigned useh = h; + + if(!usew || !useh) + { + SDL_DisplayMode displaymode; + if(SDL_GetDesktopDisplayMode(display, &displaymode) == 0) + { + usew = displaymode.w; + useh = displaymode.h; + } + } + int pos = SDL_WINDOWPOS_CENTERED_DISPLAY(display); - WIN = SDL_CreateWindow("", pos, pos, w, h, flags); + WIN = SDL_CreateWindow("", pos, pos, usew, useh, flags); if(!WIN) exit_error("Failed to create window");