diff --git a/include/QF/GLSL/qf_bsp.h b/include/QF/GLSL/qf_bsp.h index f79d1cf66..49435c6a0 100644 --- a/include/QF/GLSL/qf_bsp.h +++ b/include/QF/GLSL/qf_bsp.h @@ -55,6 +55,7 @@ typedef struct elechain_s { void R_ClearElements (void); void R_DrawWorld (void); +void R_RegisterTextures (model_t **models, int num_models); void R_BuildDisplayLists (model_t **models, int num_models); void R_InitBsp (void); diff --git a/libs/video/renderer/glsl/glsl_bsp.c b/libs/video/renderer/glsl/glsl_bsp.c index 074daca40..d93142613 100644 --- a/libs/video/renderer/glsl/glsl_bsp.c +++ b/libs/video/renderer/glsl/glsl_bsp.c @@ -198,12 +198,6 @@ R_AddTexture (texture_t *tex) tex->elechain_tail = &tex->elechain; } -void -R_ClearTextures (void) -{ - r_num_texture_chains = 0; -} - void R_InitSurfaceChains (model_t *model) { @@ -282,6 +276,37 @@ register_textures (model_t *model) } } +void +R_ClearTextures (void) +{ + r_num_texture_chains = 0; +} + +void +R_RegisterTextures (model_t **models, int num_models) +{ + int i; + model_t *m; + + R_ClearTextures (); + R_InitSurfaceChains (r_worldentity.model); + R_AddTexture (r_notexture_mip); + register_textures (r_worldentity.model); + for (i = 0; i < num_models; i++) { + m = models[i]; + if (!m) + continue; + // sub-models are done as part of the main model + if (*m->name == '*') + continue; + // world has already been done, not interested in non-brush models + if (m == r_worldentity.model || m->type != mod_brush) + continue; + m->numsubmodels = 1; // no support for submodels in non-world model + register_textures (m); + } +} + static elechain_t * add_elechain (texture_t *tex, int ec_index) { @@ -387,22 +412,6 @@ R_BuildDisplayLists (model_t **models, int num_models) msurface_t *surf; dstring_t *vertices; - R_InitSurfaceChains (r_worldentity.model); - R_AddTexture (r_notexture_mip); - register_textures (r_worldentity.model); - for (i = 0; i < num_models; i++) { - m = models[i]; - if (!m) - continue; - // sub-models are done as part of the main model - if (*m->name == '*') - continue; - // world has already been done, not interested in non-brush models - if (m == r_worldentity.model || m->type != mod_brush) - continue; - m->numsubmodels = 1; // no support for submodels in non-world model - register_textures (m); - } // now run through all surfaces, chaining them to their textures, thus // effectively sorting the surfaces by texture (without worrying about // surface order on the same texture chain). diff --git a/libs/video/renderer/glsl/glsl_main.c b/libs/video/renderer/glsl/glsl_main.c index 17975cd9f..5b72d94a0 100644 --- a/libs/video/renderer/glsl/glsl_main.c +++ b/libs/video/renderer/glsl/glsl_main.c @@ -222,6 +222,7 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models) R_FreeAllEntities (); R_ClearParticles (); + R_RegisterTextures (models, num_models); R_BuildLightmaps (models, num_models); R_BuildDisplayLists (models, num_models); }