X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fimage.c;h=16b4574dab2022311cca9d25931efb07c16f56c5;hb=fe4ae2ae6dd24628a3141093d8cddea7b57812e1;hp=7f789cff7d28b14ce7e8b62dc4d0e934c7b59bfa;hpb=1926cad56976542d96a03888d899faac7c2bf442;p=rocksndiamonds.git diff --git a/src/libgame/image.c b/src/libgame/image.c index 7f789cff..16b4574d 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -25,6 +25,7 @@ struct ImageInfo int original_height; /* original image file height */ boolean contains_small_images; /* set after adding small images */ + boolean contains_textures; /* set after adding GPU textures */ boolean scaled_up; /* set after scaling up */ int conf_tile_size; /* tile size as defined in config */ @@ -56,6 +57,7 @@ static void *Load_Image(char *filename) img_info->original_height = img_info->bitmaps[IMG_BITMAP_STANDARD]->height; img_info->contains_small_images = FALSE; + img_info->contains_textures = FALSE; img_info->scaled_up = FALSE; img_info->conf_tile_size = 0; // will be set later @@ -270,7 +272,6 @@ static boolean CheckIfImageContainsSmallImages(ImageInfo *img_info, // custom artwork set redefines classic (or default) graphics with wrong tile // size (by mistake or by intention), it will be corrected to its original // tile size here by forcing complete re-creation of all small images again - // (this does not work if different tile sizes are used in same image file) if (!strEqual(img_info->leveldir, leveldir_current->identifier) && img_info->conf_tile_size != tile_size) @@ -304,6 +305,16 @@ static boolean CheckIfImageContainsSmallImages(ImageInfo *img_info, return FALSE; } + // special case 1 (continued): + // + // if different tile sizes are used in same image file (usually by mistake, + // like forgetting option ".tile_size" for one or more graphic definitions), + // make sure to use only the first tile size that is processed for this image + // (and ignore all subsequent, potentially different tile size definitions + // for this image within the current level set by disabling the above check) + + setString(&img_info->leveldir, leveldir_current->identifier); + // special case 2: // // graphic config setting "game.tile_size" has changed since last level set; @@ -340,6 +351,28 @@ void CreateImageWithSmallImages(int pos, int zoom_factor, int tile_size) setString(&img_info->leveldir, leveldir_current->identifier); } +static void CreateImageTexturesExt(int pos, boolean force) +{ + ImageInfo *img_info = getImageInfoEntryFromImageID(pos); + + if (img_info == NULL || (img_info->contains_textures && !force)) + return; + + CreateBitmapTextures(img_info->bitmaps); + + 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);