[skin] Clean up the API a little

Only the renderer-specific functions are in the plugin functions struct,
and only the client functions are global.
This commit is contained in:
Bill Currie 2024-01-13 13:42:03 +09:00
parent 6c03d72c26
commit 739adad3d5
12 changed files with 43 additions and 63 deletions

View file

@ -38,7 +38,7 @@
struct plitem_s;
struct cvar_s;
struct scene_s;
struct skin_s;
typedef struct skin_s skin_t;
struct particle_s;
struct mod_alias_ctx_s;
@ -70,14 +70,9 @@ 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);
void (*Skin_SetupSkin) (struct skin_s *skin, int cmap);
void (*Skin_SetTranslation) (int cmap, int top, int bottom);
void (*Skin_ProcessTranslation) (int cmap, const byte *translation);
void (*Skin_InitTranslations) (void);
void (*skin_setupskin) (skin_t *skin, int cmap);
void (*skin_processtranslation) (int cmap, const byte *translation);
void (*skin_inittranslations) (void);
} vid_model_funcs_t;
struct tex_s;

View file

@ -59,4 +59,9 @@ typedef struct skin_s {
int auxtex;
} skin_t;
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);
#endif//__QF_skin_h

View file

@ -127,7 +127,7 @@ Skin_SetTranslation (int cmap, int top, int bottom)
else
dest[BOTTOM_RANGE + i] = bottom + 15 - i;
}
m_funcs->Skin_ProcessTranslation (cmap, translations[cmap - 1]);
m_funcs->skin_processtranslation (cmap, translations[cmap - 1]);
}
skin_t *
@ -142,7 +142,7 @@ Skin_SetColormap (skin_t *skin, int cmap)
}
if (cmap)
skin->colormap = translations[cmap - 1];
m_funcs->Skin_SetupSkin (skin, cmap);
m_funcs->skin_setupskin (skin, cmap);
return skin;
}
@ -228,7 +228,7 @@ Skin_SetSkin (skin_t *skin, int cmap, const char *skinname)
skin = new_skin ();
skin->texels = tex;
skin->name = name;
m_funcs->Skin_SetupSkin (skin, cmap);
m_funcs->skin_setupskin (skin, cmap);
return skin;
}
@ -260,7 +260,7 @@ Skin_Init (void)
qfZoneScoped (true);
Sys_RegisterShutdown (skin_shutdown, 0);
skin_cache = Hash_NewTable (127, skin_getkey, skin_free, 0, 0);
m_funcs->Skin_InitTranslations ();
m_funcs->skin_inittranslations ();
}
VISIBLE int

View file

@ -36,8 +36,9 @@
#endif
#include "QF/mathlib.h"
#include "QF/sys.h"
#include "QF/model.h"
#include "QF/skin.h"
#include "QF/sys.h"
#include "QF/plugin/vid_render.h"
@ -81,7 +82,7 @@ destroy_renderer (void *_renderer, ecs_registry_t *reg)
{
renderer_t *renderer = _renderer;
if (renderer->skin) {
mod_funcs->Skin_Free (renderer->skin);
Skin_Free (renderer->skin);
}
}

View file

@ -171,13 +171,9 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 1,
.Mod_SpriteLoadFrames = gl_Mod_SpriteLoadFrames,
.Skin_Free = Skin_Free,
.Skin_SetColormap = Skin_SetColormap,
.Skin_SetSkin = Skin_SetSkin,
.Skin_SetupSkin = gl_Skin_SetupSkin,
.Skin_SetTranslation = Skin_SetTranslation,
.Skin_ProcessTranslation = gl_Skin_ProcessTranslation,
.Skin_InitTranslations = gl_Skin_InitTranslations,
.skin_setupskin = gl_Skin_SetupSkin,
.skin_processtranslation = gl_Skin_ProcessTranslation,
.skin_inittranslations = gl_Skin_InitTranslations,
};
static void

View file

@ -82,13 +82,9 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 0,
.Mod_SpriteLoadFrames = glsl_Mod_SpriteLoadFrames,
.Skin_Free = Skin_Free,
.Skin_SetColormap = Skin_SetColormap,
.Skin_SetSkin = Skin_SetSkin,
.Skin_SetupSkin = glsl_Skin_SetupSkin,
.Skin_SetTranslation = Skin_SetTranslation,
.Skin_ProcessTranslation = glsl_Skin_ProcessTranslation,
.Skin_InitTranslations = glsl_Skin_InitTranslations,
.skin_setupskin = glsl_Skin_SetupSkin,
.skin_processtranslation = glsl_Skin_ProcessTranslation,
.skin_inittranslations = glsl_Skin_InitTranslations,
};
static void

View file

@ -91,13 +91,9 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 1,
.Mod_SpriteLoadFrames = sw_Mod_SpriteLoadFrames,
.Skin_Free = Skin_Free,
.Skin_SetColormap = Skin_SetColormap,
.Skin_SetSkin = Skin_SetSkin,
.Skin_SetupSkin = sw_Skin_SetupSkin,
.Skin_SetTranslation = Skin_SetTranslation,
.Skin_ProcessTranslation = sw_Skin_ProcessTranslation,
.Skin_InitTranslations = sw_Skin_InitTranslations,
.skin_setupskin = sw_Skin_SetupSkin,
.skin_processtranslation = sw_Skin_ProcessTranslation,
.skin_inittranslations = sw_Skin_InitTranslations,
};
static void

View file

@ -523,13 +523,9 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 0,
.Mod_SpriteLoadFrames = vulkan_Mod_SpriteLoadFrames,
.Skin_Free = Skin_Free,
.Skin_SetColormap = Skin_SetColormap,
.Skin_SetSkin = Skin_SetSkin,
.Skin_SetupSkin = vulkan_Skin_SetupSkin,
.Skin_SetTranslation = Skin_SetTranslation,
.Skin_ProcessTranslation = vulkan_Skin_ProcessTranslation,
.Skin_InitTranslations = vulkan_Skin_InitTranslations,
.skin_setupskin = vulkan_Skin_SetupSkin,
.skin_processtranslation = vulkan_Skin_ProcessTranslation,
.skin_inittranslations = vulkan_Skin_InitTranslations,
};
static void

View file

@ -158,7 +158,7 @@ set_entity_model (int ent_ind, int modelindex)
SET_ADD (&cl_forcelink, ent_ind);
animation->nolerp = 1; // don't try to lerp when the model has changed
if (ent_ind <= cl.maxclients) {
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin, ent_ind);
renderer->skin = Skin_SetColormap (renderer->skin, ent_ind);
}
}
@ -236,8 +236,7 @@ CL_RelinkEntities (void)
if (SET_TEST_MEMBER (&cl_forcelink, i)
|| new->colormap != old->colormap) {
old->colormap = new->colormap;
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
new->colormap);
renderer->skin = Skin_SetColormap (renderer->skin, new->colormap);
}
if (SET_TEST_MEMBER (&cl_forcelink, i)
|| new->skinnum != old->skinnum) {
@ -249,10 +248,9 @@ CL_RelinkEntities (void)
.bottom = cl.players[i - 1].bottomcolor,
};
Ent_SetComponent (ent.id, ent.base + scene_colormap, ent.reg, &colormap);
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
i);
mod_funcs->Skin_SetTranslation (i, cl.players[i - 1].topcolor,
cl.players[i - 1].bottomcolor);
renderer->skin = Skin_SetColormap (renderer->skin, i);
Skin_SetTranslation (i, cl.players[i - 1].topcolor,
cl.players[i - 1].bottomcolor);
}
}

View file

@ -938,11 +938,10 @@ CL_ParseServerMessage (void)
byte bot = col & 0xf;
if (top != cl.players[i].topcolor
|| bot != cl.players[i].bottomcolor)
mod_funcs->Skin_SetTranslation (i + 1, top, bot);
Skin_SetTranslation (i + 1, top, bot);
cl.players[i].topcolor = top;
cl.players[i].bottomcolor = bot;
renderer->skin
= mod_funcs->Skin_SetColormap (renderer->skin, i + 1);
renderer->skin = Skin_SetColormap (renderer->skin, i + 1);
Sbar_UpdateInfo (i);
}
break;

View file

@ -222,14 +222,12 @@ CL_LinkPacketEntities (void)
.bottom = player->bottomcolor,
};
Ent_SetComponent (ent.id, ent.base + scene_colormap, ent.reg, &colormap);
renderer->skin
= mod_funcs->Skin_SetSkin (renderer->skin, new->colormap,
renderer->skin = Skin_SetSkin (renderer->skin, new->colormap,
player->skinname->value);
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
new->colormap);
renderer->skin = Skin_SetColormap (renderer->skin,
new->colormap);
} else {
renderer->skin = mod_funcs->Skin_SetColormap (renderer->skin,
0);
renderer->skin = Skin_SetColormap (renderer->skin, 0);
Ent_RemoveComponent (ent.id, ent.base + scene_colormap, ent.reg);
}
}

View file

@ -324,7 +324,7 @@ Model_NextDownload (void)
if (strequal (cl.model_name[i], "progs/player.mdl")
&& cl_world.models.a[i]->type == mod_alias) {
info_key = pmodel_name;
//XXX mod_funcs->Skin_Player_Model (cl_world.models.a[i]);
//XXX Skin_Player_Model (cl_world.models.a[i]);
}
if (strequal (cl.model_name[i], "progs/eyes.mdl")
&& cl_world.models.a[i]->type == mod_alias)
@ -1021,11 +1021,11 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
const char *spec = Info_ValueForKey (player->userinfo, "*spectator");
player->spectator = spec && *spec;
mod_funcs->Skin_SetTranslation (slot + 1, player->topcolor,
Skin_SetTranslation (slot + 1, player->topcolor,
player->bottomcolor);
player->skin = mod_funcs->Skin_SetSkin (player->skin, slot + 1,
player->skin = Skin_SetSkin (player->skin, slot + 1,
player->skinname->value);
player->skin = mod_funcs->Skin_SetColormap (player->skin, slot + 1);
player->skin = Skin_SetColormap (player->skin, slot + 1);
Sbar_UpdateInfo (slot);
}