From 40fc9f00005eb163181ce4922d29c93f9ff6bd48 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 19 Jan 2021 10:30:37 +0900 Subject: [PATCH] [model] Make Mod_LoadExternalTextures private It never really needed to be externally accessible as it has always been gl-specific and can be called by Mod_ProcessTexture anyway. --- include/QF/plugin/vid_render.h | 1 - include/mod_internal.h | 3 - libs/models/brush/gl_model_brush.c | 91 ++++++++++++------------- libs/models/model.c | 4 -- libs/video/renderer/vid_render_gl.c | 1 - libs/video/renderer/vid_render_glsl.c | 1 - libs/video/renderer/vid_render_sw.c | 1 - libs/video/renderer/vid_render_sw32.c | 1 - libs/video/renderer/vid_render_vulkan.c | 6 -- 9 files changed, 45 insertions(+), 64 deletions(-) diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index 462aaabf4..447bc8ce6 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -80,7 +80,6 @@ typedef struct vid_particle_funcs_s { } vid_particle_funcs_t; typedef struct vid_model_funcs_s { - void (*Mod_LoadExternalTextures) (model_t *mod); void (*Mod_LoadLighting) (bsp_t *bsp); void (*Mod_SubdivideSurface) (msurface_t *fa); void (*Mod_ProcessTexture) (texture_t *tx); diff --git a/include/mod_internal.h b/include/mod_internal.h index 7f6be3e4e..2dbf624bf 100644 --- a/include/mod_internal.h +++ b/include/mod_internal.h @@ -32,17 +32,14 @@ void sw_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr); void sw_Mod_LoadExternalSkins (model_t *mod); void sw_Mod_IQMFinish (model_t *mod); -void gl_Mod_LoadExternalTextures (model_t *mod); void gl_Mod_LoadLighting (bsp_t *bsp); void gl_Mod_SubdivideSurface (msurface_t *fa); void gl_Mod_ProcessTexture(texture_t *tx); -void glsl_Mod_LoadExternalTextures (model_t *mod); void glsl_Mod_LoadLighting (bsp_t *bsp); void glsl_Mod_SubdivideSurface (msurface_t *fa); void glsl_Mod_ProcessTexture(texture_t *tx); -void sw_Mod_LoadExternalTextures (model_t *mod); void sw_Mod_LoadLighting (bsp_t *bsp); void sw_Mod_SubdivideSurface (msurface_t *fa); void sw_Mod_ProcessTexture(texture_t *tx); diff --git a/libs/models/brush/gl_model_brush.c b/libs/models/brush/gl_model_brush.c index 9c1057226..2c95cbe64 100644 --- a/libs/models/brush/gl_model_brush.c +++ b/libs/models/brush/gl_model_brush.c @@ -51,22 +51,6 @@ #include "mod_internal.h" #include "r_internal.h" - -void -gl_Mod_ProcessTexture (texture_t *tx) -{ - const char *name; - - if (!strncmp (tx->name, "sky", 3)) - return; - name = va ("fb_%s", tx->name); - tx->gl_fb_texturenum = - Mod_Fullbright ((byte *) (tx + 1), tx->width, tx->height, name); - tx->gl_texturenum = - GL_LoadTexture (tx->name, tx->width, tx->height, (byte *) (tx + 1), - true, false, 1); -} - static tex_t * Mod_LoadAnExternalTexture (char *tname, char *mname) { @@ -92,44 +76,59 @@ Mod_LoadAnExternalTexture (char *tname, char *mname) return image; } -void -gl_Mod_LoadExternalTextures (model_t *mod) +static int +Mod_LoadExternalTextures (model_t *mod, texture_t *tx) { - int i; tex_t *base, *luma; - texture_t *tx; + int external = 0; + if ((base = Mod_LoadAnExternalTexture (tx->name, mod->name))) { + external = 1; + tx->gl_texturenum = + GL_LoadTexture (tx->name, base->width, base->height, + base->data, true, false, + base->format > 2 ? base->format : 1); - for (i = 0; i < mod->numtextures; i++) { - tx = mod->textures[i]; - if (!tx) - continue; - - if ((base = Mod_LoadAnExternalTexture (tx->name, mod->name))) { - tx->gl_texturenum = - GL_LoadTexture (tx->name, base->width, base->height, - base->data, true, false, - base->format > 2 ? base->format : 1); - - luma = Mod_LoadAnExternalTexture (va ("%s_luma", tx->name), + luma = Mod_LoadAnExternalTexture (va ("%s_luma", tx->name), + mod->name); + if (!luma) + luma = Mod_LoadAnExternalTexture (va ("%s_glow", tx->name), mod->name); - if (!luma) - luma = Mod_LoadAnExternalTexture (va ("%s_glow", tx->name), - mod->name); - tx->gl_fb_texturenum = 0; + tx->gl_fb_texturenum = 0; - if (luma) { - tx->gl_fb_texturenum = - GL_LoadTexture (va ("fb_%s", tx->name), luma->width, - luma->height, luma->data, true, true, - luma->format > 2 ? luma->format : 1); - } else if (base->format < 3) { - tx->gl_fb_texturenum = - Mod_Fullbright (base->data, base->width, base->height, - va ("fb_%s", tx->name)); - } + if (luma) { + tx->gl_fb_texturenum = + GL_LoadTexture (va ("fb_%s", tx->name), luma->width, + luma->height, luma->data, true, true, + luma->format > 2 ? luma->format : 1); + } else if (base->format < 3) { + tx->gl_fb_texturenum = + Mod_Fullbright (base->data, base->width, base->height, + va ("fb_%s", tx->name)); } } + return external; +} + +void +gl_Mod_ProcessTexture (texture_t *tx) +{ + const char *name; + + if (gl_textures_external && gl_textures_external->int_val) { + if (Mod_LoadExternalTextures (loadmodel, tx)) { + return; + } + } + if (strncmp (tx->name, "sky", 3) == 0) { + return; + } + name = va ("fb_%s", tx->name); + tx->gl_fb_texturenum = + Mod_Fullbright ((byte *) (tx + 1), tx->width, tx->height, name); + tx->gl_texturenum = + GL_LoadTexture (tx->name, tx->width, tx->height, (byte *) (tx + 1), + true, false, 1); } void diff --git a/libs/models/model.c b/libs/models/model.c index bac0223de..d8ce5df03 100644 --- a/libs/models/model.c +++ b/libs/models/model.c @@ -231,10 +231,6 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator) default: // Version 29: Quake 1 .bsp // Version 38: Quake 2 .bsp Mod_LoadBrushModel (mod, buf); - - if (gl_textures_external && gl_textures_external->int_val - && mod_funcs && mod_funcs->Mod_LoadExternalTextures) - mod_funcs->Mod_LoadExternalTextures (mod); break; } free (buf); diff --git a/libs/video/renderer/vid_render_gl.c b/libs/video/renderer/vid_render_gl.c index 852a0a423..8e12a67ec 100644 --- a/libs/video/renderer/vid_render_gl.c +++ b/libs/video/renderer/vid_render_gl.c @@ -46,7 +46,6 @@ gl_ctx_t *gl_ctx; static vid_model_funcs_t model_funcs = { - gl_Mod_LoadExternalTextures, gl_Mod_LoadLighting, gl_Mod_SubdivideSurface, gl_Mod_ProcessTexture, diff --git a/libs/video/renderer/vid_render_glsl.c b/libs/video/renderer/vid_render_glsl.c index 6d6c87b3a..be427f3ca 100644 --- a/libs/video/renderer/vid_render_glsl.c +++ b/libs/video/renderer/vid_render_glsl.c @@ -46,7 +46,6 @@ gl_ctx_t *glsl_ctx; static vid_model_funcs_t model_funcs = { - 0,//Mod_LoadExternalTextures, glsl_Mod_LoadLighting, 0,//Mod_SubdivideSurface, glsl_Mod_ProcessTexture, diff --git a/libs/video/renderer/vid_render_sw.c b/libs/video/renderer/vid_render_sw.c index 8c5360701..e30ef9e2e 100644 --- a/libs/video/renderer/vid_render_sw.c +++ b/libs/video/renderer/vid_render_sw.c @@ -39,7 +39,6 @@ sw_ctx_t *sw_ctx; static vid_model_funcs_t model_funcs = { - 0,//Mod_LoadExternalTextures, sw_Mod_LoadLighting, 0,//Mod_SubdivideSurface, 0,//Mod_ProcessTexture, diff --git a/libs/video/renderer/vid_render_sw32.c b/libs/video/renderer/vid_render_sw32.c index af72bc0df..895098065 100644 --- a/libs/video/renderer/vid_render_sw32.c +++ b/libs/video/renderer/vid_render_sw32.c @@ -44,7 +44,6 @@ sw_ctx_t *sw32_ctx; static vid_model_funcs_t model_funcs = { - 0,//Mod_LoadExternalTextures, sw_Mod_LoadLighting, 0,//Mod_SubdivideSurface, 0,//Mod_ProcessTexture, diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 80ccf0127..8cfb7926a 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -385,11 +385,6 @@ vulkan_r_particles_style_f (struct cvar_s *var) Vulkan_r_particles_style_f (var, vulkan_ctx); } -static void -vulkan_Mod_LoadExternalTextures (model_t *mod) -{ -} - static void vulkan_Mod_LoadLighting (bsp_t *bsp) { @@ -454,7 +449,6 @@ vulkan_Skin_InitTranslations (void) } static vid_model_funcs_t model_funcs = { - vulkan_Mod_LoadExternalTextures, vulkan_Mod_LoadLighting, vulkan_Mod_SubdivideSurface, vulkan_Mod_ProcessTexture,