diff options
-rw-r--r-- | src/sdl/sprites.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/sdl/sprites.c b/src/sdl/sprites.c index 4f3360d..6fe8df0 100644 --- a/src/sdl/sprites.c +++ b/src/sdl/sprites.c @@ -18,17 +18,18 @@ sprite_set_init( const asset_id_t asset_id ) { sprite_set_t set; + // get asset const asset_t * const asset = asset_get(asset_id); - // load image + // load backing image data int im_w, im_h; set.im_data = stbi_load_from_memory(asset->buf, asset->len, &im_w, &im_h, NULL, 4); if (!set.im_data) { die("stbi_load(): %s", stbi_failure_reason()); } - // create surface + // create surface from backing image data set.surface = SDL_CreateRGBSurfaceWithFormatFrom(set.im_data, im_w, im_h, 32, 4 * im_w, SDL_PIXELFORMAT_RGBA32); if (!set.surface) { die("SDLCreateRGBSurfaceFrom(): %s", SDL_GetError()); @@ -45,7 +46,7 @@ sprite_set_fini( // free main surface SDL_FreeSurface(set->surface); - // free image data + // free backing image data stbi_image_free(set->im_data); } |