mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-24 21:31:46 +00:00
sdl2: Fix changing between fullscreen/windowed
This commit is contained in:
parent
beb2672f40
commit
ad1b9f93c8
1 changed files with 17 additions and 3 deletions
|
@ -196,21 +196,35 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||||
realheight = (Uint16)height;
|
realheight = (Uint16)height;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static SDL_bool wasfullscreen = SDL_FALSE;
|
||||||
int rmask;
|
int rmask;
|
||||||
int gmask;
|
int gmask;
|
||||||
int bmask;
|
int bmask;
|
||||||
int amask;
|
int amask;
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen && !wasfullscreen)
|
||||||
{
|
{
|
||||||
|
// Recreate window in fullscreen
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
renderer = NULL;
|
renderer = NULL;
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
window = NULL;
|
window = NULL;
|
||||||
Impl_CreateWindow(fullscreen);
|
Impl_CreateWindow(SDL_TRUE);
|
||||||
|
wasfullscreen = SDL_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else if (!fullscreen && wasfullscreen)
|
||||||
{
|
{
|
||||||
|
// Recreate window in windowed mode
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
renderer = NULL;
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
window = NULL;
|
||||||
|
Impl_CreateWindow(SDL_FALSE);
|
||||||
|
wasfullscreen = SDL_FALSE;
|
||||||
|
}
|
||||||
|
else if (!wasfullscreen)
|
||||||
|
{
|
||||||
|
// Reposition window only in windowed mode
|
||||||
SDL_SetWindowSize(window, width, height);
|
SDL_SetWindowSize(window, width, height);
|
||||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue