make textures_dump_atlases work again and expose it as a utility function
This commit is contained in:
@ -165,6 +165,30 @@ char *file_to_str(const char *path) {
|
||||
}
|
||||
|
||||
|
||||
void textures_dump_atlases(void) {
|
||||
PHYSFS_mkdir("/dump");
|
||||
|
||||
/* TODO: png instead of bmp */
|
||||
const char string_template[] = "/dump/atlas%zd.bmp";
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < arrlenu(ctx.texture_cache.atlas_surfaces); ++i) {
|
||||
char *buf = NULL;
|
||||
SDL_asprintf(&buf, string_template, i);
|
||||
|
||||
SDL_RWops *handle = PHYSFSRWOPS_openWrite(buf);
|
||||
|
||||
if (handle == NULL) {
|
||||
CRY("Texture atlas dump failed.", "File could not be opened");
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SaveBMP_RW(ctx.texture_cache.atlas_surfaces[i], handle, true);
|
||||
log_info("Dumped atlas %zu to %s", i, buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool strends(const char *str, const char *suffix) {
|
||||
size_t str_length = SDL_strlen(str);
|
||||
size_t suffix_length = SDL_strlen(suffix);
|
||||
|
Reference in New Issue
Block a user