From: Holger Schemel Date: Sun, 7 Feb 2016 22:52:03 +0000 (+0100) Subject: added re-initialization of textures after change of renderer X-Git-Tag: 4.0.0.0-rc1~85 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fe4ae2ae6dd24628a3141093d8cddea7b57812e1;p=rocksndiamonds.git added re-initialization of textures after change of renderer --- diff --git a/src/init.c b/src/init.c index e33a5adb..ca5d16b6 100644 --- a/src/init.c +++ b/src/init.c @@ -226,7 +226,7 @@ void InitBitmapPointers() graphic_info[i].bitmap = graphic_info[i].bitmaps[IMG_BITMAP_STANDARD]; } -static void InitGlobalAnimImages() +void InitImageTextures() { int i, j, k; @@ -241,8 +241,8 @@ static void InitGlobalAnimImages() if (graphic == IMG_UNDEFINED) continue; - // create textures from images for fast GPU blitting, if possible - CreateImageTextures(graphic); + // (re)create textures from images for fast GPU blitting, if possible + ReCreateImageTextures(graphic); } } } @@ -2026,8 +2026,9 @@ static void ReinitializeGraphics() print_timestamp_time("InitFontGraphicInfo"); InitGlobalAnimGraphicInfo(); /* initialize global animation config */ print_timestamp_time("InitGlobalAnimGraphicInfo"); - InitGlobalAnimImages(); /* initialize global animation images */ - print_timestamp_time("InitGlobalAnimImages"); + + InitImageTextures(); /* create textures for certain images */ + print_timestamp_time("InitImageTextures"); InitGraphicInfo_EM(); /* graphic mapping for EM engine */ print_timestamp_time("InitGraphicInfo_EM"); diff --git a/src/init.h b/src/init.h index 9c6185f7..ab14b75d 100644 --- a/src/init.h +++ b/src/init.h @@ -43,6 +43,7 @@ void KeyboardAutoRepeatOffUnlessAutoplay(); void InitGfxBuffers(); void InitGadgets(); +void InitImageTextures(); void DisplayExitMessage(char *, va_list); diff --git a/src/libgame/image.c b/src/libgame/image.c index 2275bc73..16b4574d 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -351,11 +351,11 @@ void CreateImageWithSmallImages(int pos, int zoom_factor, int tile_size) setString(&img_info->leveldir, leveldir_current->identifier); } -void CreateImageTextures(int pos) +static void CreateImageTexturesExt(int pos, boolean force) { ImageInfo *img_info = getImageInfoEntryFromImageID(pos); - if (img_info == NULL || img_info->contains_textures) + if (img_info == NULL || (img_info->contains_textures && !force)) return; CreateBitmapTextures(img_info->bitmaps); @@ -363,6 +363,16 @@ void CreateImageTextures(int pos) img_info->contains_textures = TRUE; } +void CreateImageTextures(int pos) +{ + CreateImageTexturesExt(pos, FALSE); +} + +void ReCreateImageTextures(int pos) +{ + CreateImageTexturesExt(pos, TRUE); +} + void ScaleImage(int pos, int zoom_factor) { ImageInfo *img_info = getImageInfoEntryFromImageID(pos); diff --git a/src/libgame/image.h b/src/libgame/image.h index 627694c0..2d970823 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -68,6 +68,7 @@ void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *, void ReloadCustomImages(); void CreateImageWithSmallImages(int, int, int); void CreateImageTextures(int); +void ReCreateImageTextures(int); void ScaleImage(int, int); void FreeAllImages(); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 0b2e1c16..0759b549 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -317,6 +317,11 @@ void SDLCreateBitmapTextures(Bitmap *bitmap) if (bitmap == NULL) return; + if (bitmap->texture) + SDL_DestroyTexture(bitmap->texture); + if (bitmap->texture_masked) + SDL_DestroyTexture(bitmap->texture_masked); + bitmap->texture = SDLCreateTextureFromSurface(bitmap->surface); bitmap->texture_masked = SDLCreateTextureFromSurface(bitmap->surface_masked); #endif diff --git a/src/tools.c b/src/tools.c index e2352d18..dbeba50c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -8330,6 +8330,7 @@ void ChangeViewportPropertiesIfNeeded() // printf("::: init_video_buffer\n"); InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); + InitImageTextures(); } if (init_gadgets_and_toons)