From 35a8dd0de73e0b8f9175600785e2af74b6a03395 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 1 Apr 2020 14:26:37 +0400 Subject: [PATCH] sdl2: keep surface of same size while window resize --- src/sdl2/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sdl2/main.c b/src/sdl2/main.c index 66b6680..81ecaa1 100644 --- a/src/sdl2/main.c +++ b/src/sdl2/main.c @@ -127,11 +127,13 @@ static int Y_resize_window (int w, int h, int fullscreen) { assert(h > 0); assert(window != NULL); if (surf != NULL) { - SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, 8, 0, 0, 0, 0); - if (s != NULL) { - SDL_SetPaletteColors(s->format->palette, surf->format->palette->colors, 0, surf->format->palette->ncolors); - SDL_FreeSurface(surf); - surf = s; + if (surf->w != w || surf->h != h) { + SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, 8, 0, 0, 0, 0); + if (s != NULL) { + SDL_SetPaletteColors(s->format->palette, surf->format->palette->colors, 0, surf->format->palette->ncolors); + SDL_FreeSurface(surf); + surf = s; + } } } SDL_SetWindowSize(window, w, h); -- 2.29.2