[model] Support freeing of skin data

I doubt it's enough, but it does seem to cover what's needed for glsl
(maybe not the actual textures, unsure there, but I think they're
recycled).
This commit is contained in:
Bill Currie 2022-05-12 22:46:31 +09:00
parent 4e526702dd
commit aabf3e14f8
8 changed files with 15 additions and 0 deletions

View file

@ -66,6 +66,7 @@ typedef struct vid_model_funcs_s {
int alias_cache;
void (*Mod_SpriteLoadFrames) (struct mod_sprite_ctx_s *sprite_ctx);
void (*Skin_Free) (struct skin_s *skin);
struct skin_s *(*Skin_SetColormap) (struct skin_s *skin, int cmap);
struct skin_s *(*Skin_SetSkin) (struct skin_s *skin, int cmap,
const char *skinname);

View file

@ -104,6 +104,7 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer,
void Mod_LoadSpriteModel (model_t *mod, void *buffer);
void Skin_Init (void);
void Skin_Free (skin_t *skin);
skin_t *Skin_SetColormap (skin_t *skin, int cmap);
skin_t *Skin_SetSkin (skin_t *skin, int cmap, const char *skinname);
void Skin_SetTranslation (int cmap, int top, int bottom);

View file

@ -71,6 +71,14 @@ new_skin (void)
return calloc (1, sizeof (skin_t));
}
VISIBLE void
Skin_Free (skin_t *skin)
{
if (skin) {
free (skin);
}
}
VISIBLE void
Skin_SetTranslation (int cmap, int top, int bottom)
{

View file

@ -170,6 +170,7 @@ static vid_model_funcs_t model_funcs = {
1,
gl_Mod_SpriteLoadFrames,
Skin_Free,
Skin_SetColormap,
Skin_SetSkin,
gl_Skin_SetupSkin,

View file

@ -81,6 +81,7 @@ static vid_model_funcs_t model_funcs = {
0,
glsl_Mod_SpriteLoadFrames,
Skin_Free,
Skin_SetColormap,
Skin_SetSkin,
glsl_Skin_SetupSkin,

View file

@ -90,6 +90,7 @@ static vid_model_funcs_t model_funcs = {
1,
sw_Mod_SpriteLoadFrames,
Skin_Free,
Skin_SetColormap,
Skin_SetSkin,
sw_Skin_SetupSkin,

View file

@ -654,6 +654,7 @@ static vid_model_funcs_t model_funcs = {
0,
vulkan_Mod_SpriteLoadFrames,
Skin_Free,
Skin_SetColormap,
Skin_SetSkin,
vulkan_Skin_SetupSkin,

View file

@ -73,6 +73,7 @@ CL_ClearEnts (void)
for (i = 0; i < MAX_EDICTS; i++) {
if (cl_entities[i]) {
mod_funcs->Skin_Free (cl_entities[i]->renderer.skin);
Scene_DestroyEntity (cl_world.scene, cl_entities[i]);
cl_entities[i] = 0;
}