1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-03 18:14:01 +00:00

avoid creating a (0,0)-sized window at the start

This commit is contained in:
fgenesis 2021-01-12 14:05:22 +01:00
parent a1f92433d8
commit 067472d61b

View file

@ -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; Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
if(full) if(full)
{ {
if(!w && !h) if(!w || !h)
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
else else
flags |= SDL_WINDOW_FULLSCREEN; 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); 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) if(!WIN)
exit_error("Failed to create window"); exit_error("Failed to create window");