make textures_dump_atlases work again and expose it as a utility function

This commit is contained in:
2024-09-26 21:32:08 -03:00
parent 0e68ecbc88
commit f4b52b5450
6 changed files with 42 additions and 28 deletions

View File

@ -300,31 +300,6 @@ void textures_cache_deinit(TextureCache *cache) {
}
void textures_dump_atlases(TextureCache *cache) {
PHYSFS_mkdir("/dump");
const char string_template[] = "/dump/atlas%zd.png";
char buf[2048]; /* larger than will ever be necessary */
size_t i = 0;
for (; i < arrlenu(cache->atlas_surfaces); ++i) {
SDL_snprintf(buf, sizeof buf, string_template, i);
SDL_RWops *handle = PHYSFSRWOPS_openWrite(buf);
if (handle == NULL) {
CRY("Texture atlas dump failed.", "File could not be opened");
return;
}
/* TODO: */
// IMG_SavePNG_RW(cache->atlas_surfaces[i], handle, true);
CRY("Unimplemented", "textures_dump_atlases dumping is not there, sorry");
log_info("Dumped atlas %s", buf);
}
}
static enum TextureMode infer_texture_mode(SDL_Surface *surface) {
const uint32_t amask = surface->format->Amask;
if (amask == 0)