mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-12 20:18:00 +01:00
character: Take ownership of frame bitmaps when preloading streamed spritesheets
Since a non-owned frame is valid only until the next invocation of stream callback, we need to clone it and take ownership.
This commit is contained in:
parent
7cb7c361f0
commit
21f7424f89
1 changed files with 5 additions and 0 deletions
|
@ -230,6 +230,11 @@ SYMBOL_EXPORT void PreloadStreamedSpritesheet(struct Game* game, struct Characte
|
|||
PrintConsole(game, " - frame %d", i);
|
||||
spritesheet->frames[i] = spritesheet->stream(game, delta, spritesheet->stream_data);
|
||||
|
||||
if (!spritesheet->frames[i].owned) {
|
||||
spritesheet->frames[i].bitmap = al_clone_bitmap(spritesheet->frames[i].bitmap);
|
||||
spritesheet->frames[i].owned = true;
|
||||
}
|
||||
|
||||
spritesheet->frames[i]._priv.image = al_create_sub_bitmap(spritesheet->frames[i].bitmap, spritesheet->frames[i].sx * spritesheet->scale, spritesheet->frames[i].sy * spritesheet->scale, (spritesheet->frames[i].sw > 0) ? (spritesheet->frames[i].sw * spritesheet->scale) : al_get_bitmap_width(spritesheet->frames[i].bitmap), (spritesheet->frames[i].sh > 0) ? (spritesheet->frames[i].sh * spritesheet->scale) : al_get_bitmap_height(spritesheet->frames[i].bitmap));
|
||||
|
||||
int width = al_get_bitmap_width(spritesheet->frames[i]._priv.image) / spritesheet->scale + spritesheet->frames[i].x;
|
||||
|
|
Loading…
Reference in a new issue