[skin] Fix up dynamic library issues

And further clean up skin api.

It turns out that skin functions must all be in the render libs, and
this results in Skin_Set (was Skin_SetSkin) needs to be accessed via a
function pointer rather than directly :(
This commit is contained in:
Bill Currie 2024-01-15 15:26:09 +09:00
parent d39630580e
commit fcd094ef04
14 changed files with 40 additions and 23 deletions

View file

@ -70,7 +70,8 @@ typedef struct vid_model_funcs_s {
int alias_cache;
void (*Mod_SpriteLoadFrames) (struct mod_sprite_ctx_s *sprite_ctx);
void (*skin_setupskin) (skin_t *skin, int cmap);
uint32_t (*skin_set) (const char *skinname);
void (*skin_setupskin) (skin_t *skin);
void (*skin_destroy) (skin_t *skin);
} vid_model_funcs_t;

View file

@ -62,8 +62,4 @@ enum {
#define nullskin (0u)
void Skin_Init (void);
uint32_t Skin_SetSkin (const char *skinname, int cmap);
void Skin_SetTranslation (int cmap, int top, int bottom);
#endif//__QF_skin_h

View file

@ -129,17 +129,19 @@ typedef struct glskin_s {
uint32_t fb;
} glskin_t;
void Skin_Init (void);
uint32_t Skin_Set (const char *skinname);
skin_t *Skin_Get (uint32_t skin) __attribute__((pure));
void sw_Skin_SetupSkin (skin_t *skin, int cmap);
void sw_Skin_SetupSkin (skin_t *skin);
void sw_Skin_Destroy (skin_t *skin);
const byte *sw_Skin_Colormap (const colormap_t *colormap);
void glsl_Skin_SetupSkin (skin_t *skin, int cmap);
void glsl_Skin_SetupSkin (skin_t *skin);
void glsl_Skin_Destroy (skin_t *skin);
uint32_t glsl_Skin_Colormap (const colormap_t *colormap);
void gl_Skin_SetupSkin (skin_t *skin, int cmap);
void gl_Skin_SetupSkin (skin_t *skin);
void gl_Skin_Destroy (skin_t *skin);
glskin_t gl_Skin_Get (const tex_t *tex, const colormap_t *colormap,
const byte *texel_base);

View file

@ -14,7 +14,6 @@ EXTRA_LTLIBRARIES += \
models_sources = \
libs/models/clip_hull.c \
libs/models/fullbright.c \
libs/models/model.c \
libs/models/portal.c \
libs/models/trace.c \
@ -30,7 +29,11 @@ libs_models_libQFmodels_la_LIBADD= $(models_libs)
libs_models_libQFmodels_la_DEPENDENCIES= $(models_libs)
libs_models_libQFmodels_la_SOURCES= $(models_sources)
gl_sources=libs/models/gl_model_fullbright.c libs/models/gl_skin.c libs/models/skin.c
gl_sources= \
libs/models/fullbright.c \
libs/models/gl_model_fullbright.c \
libs/models/gl_skin.c \
libs/models/skin.c
gl_libs= \
libs/models/alias/libalias_gl.la \
libs/models/brush/libbrush_gl.la \
@ -42,6 +45,10 @@ libs_models_libmodels_gl_la_LIBADD= $(gl_libs)
libs_models_libmodels_gl_la_DEPENDENCIES= $(gl_libs)
libs_models_libmodels_gl_la_SOURCES= $(gl_sources)
glsl_sources = \
libs/models/fullbright.c \
libs/models/glsl_skin.c \
libs/models/skin.c
glsl_libs= \
libs/models/alias/libalias_glsl.la \
libs/models/brush/libbrush_glsl.la \
@ -51,8 +58,12 @@ glsl_libs= \
libs_models_libmodels_glsl_la_LDFLAGS=
libs_models_libmodels_glsl_la_LIBADD= $(glsl_libs)
libs_models_libmodels_glsl_la_DEPENDENCIES= $(glsl_libs)
libs_models_libmodels_glsl_la_SOURCES= libs/models/glsl_skin.c libs/models/skin.c
libs_models_libmodels_glsl_la_SOURCES= $(glsl_sources)
sw_sources = \
libs/models/fullbright.c \
libs/models/sw_skin.c \
libs/models/skin.c
sw_libs= \
libs/models/alias/libalias_sw.la \
libs/models/brush/libbrush_sw.la \
@ -62,7 +73,12 @@ sw_libs= \
libs_models_libmodels_sw_la_LDFLAGS=
libs_models_libmodels_sw_la_LIBADD= $(sw_libs)
libs_models_libmodels_sw_la_DEPENDENCIES= $(sw_libs)
libs_models_libmodels_sw_la_SOURCES= libs/models/sw_skin.c libs/models/skin.c
libs_models_libmodels_sw_la_SOURCES= $(sw_sources)
vulkan_sources= \
libs/models/vulkan_skin.c \
libs/models/fullbright.c \
libs/models/skin.c
vulkan_libs= \
libs/models/alias/libalias_vulkan.la \
@ -73,4 +89,4 @@ vulkan_libs= \
libs_models_libmodels_vulkan_la_LDFLAGS=
libs_models_libmodels_vulkan_la_LIBADD= $(vulkan_libs)
libs_models_libmodels_vulkan_la_DEPENDENCIES= $(vulkan_libs)
libs_models_libmodels_vulkan_la_SOURCES= libs/models/vulkan_skin.c libs/models/skin.c libs/models/fullbright.c
libs_models_libmodels_vulkan_la_SOURCES= $(vulkan_sources)

View file

@ -198,7 +198,7 @@ gl_Skin_Get (const tex_t *tex, const colormap_t *colormap,
}
void
gl_Skin_SetupSkin (skin_t *skin, int cmap)
gl_Skin_SetupSkin (skin_t *skin)
{
skin->tex = Skin_DupTex (skin->tex);
}

View file

@ -88,7 +88,7 @@ glsl_Skin_Colormap (const colormap_t *colormap)
}
void
glsl_Skin_SetupSkin (skin_t *skin, int cmap)
glsl_Skin_SetupSkin (skin_t *skin)
{
tex_t *tex = skin->tex;
skin->tex = nullptr; // tex memory is only temporarily allocated

View file

@ -150,7 +150,7 @@ freestr (char **strptr)
}
VISIBLE uint32_t
Skin_SetSkin (const char *skinname, int cmap)
Skin_Set (const char *skinname)
{
if (!skinname || !*skinname) {
return nullskin;
@ -188,7 +188,7 @@ Skin_SetSkin (const char *skinname, int cmap)
skin_t skin = {
.tex = tex,
};
m_funcs->skin_setupskin (&skin, cmap);
m_funcs->skin_setupskin (&skin);
Ent_SetComponent (skinent, skinsys.base + skin_skin, skinsys.reg, &skin);
return skinent;

View file

@ -52,7 +52,7 @@ sw_Skin_Colormap (const colormap_t *colormap)
}
void
sw_Skin_SetupSkin (skin_t *skin, int cmap)
sw_Skin_SetupSkin (skin_t *skin)
{
skin->tex = Skin_DupTex (skin->tex);
}

View file

@ -171,6 +171,7 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 1,
.Mod_SpriteLoadFrames = gl_Mod_SpriteLoadFrames,
.skin_set = Skin_Set,
.skin_setupskin = gl_Skin_SetupSkin,
.skin_destroy = gl_Skin_Destroy,
};

View file

@ -82,6 +82,7 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 0,
.Mod_SpriteLoadFrames = glsl_Mod_SpriteLoadFrames,
.skin_set = Skin_Set,
.skin_setupskin = glsl_Skin_SetupSkin,
.skin_destroy = glsl_Skin_Destroy,
};

View file

@ -91,6 +91,7 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 1,
.Mod_SpriteLoadFrames = sw_Mod_SpriteLoadFrames,
.skin_set = Skin_Set,
.skin_setupskin = sw_Skin_SetupSkin,
.skin_destroy = sw_Skin_Destroy,
};

View file

@ -452,7 +452,7 @@ vulkan_Mod_SpriteLoadFrames (mod_sprite_ctx_t *sprite_ctx)
}
static void
vulkan_Skin_SetupSkin (struct skin_s *skin, int cmap)
vulkan_Skin_SetupSkin (struct skin_s *skin)
{
}
@ -513,6 +513,7 @@ static vid_model_funcs_t model_funcs = {
.alias_cache = 0,
.Mod_SpriteLoadFrames = vulkan_Mod_SpriteLoadFrames,
.skin_set = Skin_Set,
.skin_setupskin = vulkan_Skin_SetupSkin,
};

View file

@ -221,8 +221,7 @@ CL_LinkPacketEntities (void)
.top = player->topcolor,
.bottom = player->bottomcolor,
});
renderer->skin = Skin_SetSkin (player->skinname->value,
new->colormap);
renderer->skin = mod_funcs->skin_set (player->skinname->value);
} else {
Entity_RemoveColormap (ent);
}

View file

@ -324,7 +324,6 @@ 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 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,7 +1020,7 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
const char *spec = Info_ValueForKey (player->userinfo, "*spectator");
player->spectator = spec && *spec;
player->skin = Skin_SetSkin (player->skinname->value, slot + 1);
player->skin = mod_funcs->skin_set (player->skinname->value);
Sbar_UpdateInfo (slot);
}