Support fullscreen with SDL2

This commit is contained in:
Thomas Bernard
2018-06-26 13:32:33 +02:00
parent 099301721e
commit 18e942d486
2 changed files with 36 additions and 10 deletions

View File

@@ -151,8 +151,11 @@ void GFX2_Set_mode(int *width, int *height, int fullscreen)
SDL_SetWindowIcon(Window_SDL, icon);
Renderer_SDL = SDL_CreateRenderer(Window_SDL, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
}
//else
// SDL_SetWindowSize(Window_SDL, *width, *height);
else
{
SDL_SetWindowSize(Window_SDL, *width, *height);
SDL_SetWindowFullscreen(Window_SDL, fullscreen?SDL_WINDOW_FULLSCREEN:0);
}
//SDL_GetWindowSize(Window_SDL, width, height);
if (Texture_SDL != NULL)
SDL_DestroyTexture(Texture_SDL);
@@ -199,7 +202,13 @@ static void GFX2_UpdateRect(int x, int y, int width, int height)
source_rect.h = height;
}
if (RGBcopy == NULL)
if (RGBcopy != NULL && (Screen_SDL->w > RGBcopy->w || Screen_SDL->h > RGBcopy->h))
{
SDL_FreeSurface(RGBcopy);
RGBcopy = NULL;
}
if (RGBcopy == NULL)
{
RGBcopy = SDL_CreateRGBSurface(0,
Screen_SDL->w, Screen_SDL->h,