From 4123d74e5e8978dffd4fc6b2544728bfe5be44a3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 9 Aug 2002 06:07:25 +0000 Subject: [PATCH] don't segfault when a surface uses the `null' texture (r_notexture_mip) --- libs/video/renderer/gl/gl_rmisc.c | 7 ++++++- libs/video/renderer/gl/gl_rsurf.c | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/video/renderer/gl/gl_rmisc.c b/libs/video/renderer/gl/gl_rmisc.c index b0c8f7f70..f25461207 100644 --- a/libs/video/renderer/gl/gl_rmisc.c +++ b/libs/video/renderer/gl/gl_rmisc.c @@ -170,6 +170,7 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models) { cvar_t *r_skyname; int i; + texture_t *tex; for (i = 0; i < 256; i++) d_lightstylevalue[i] = 264; // normal light value @@ -190,7 +191,7 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models) skytexturenum = -1; mirrortexturenum = -1; for (i = 0; i < r_worldentity.model->numtextures; i++) { - texture_t *tex = r_worldentity.model->textures[i]; + tex = r_worldentity.model->textures[i]; if (!tex) continue; if (!strncmp (tex->name, "sky", 3)) @@ -200,6 +201,10 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models) tex->texturechain = NULL; tex->texturechain_tail = &tex->texturechain; } + tex = r_notexture_mip; + tex->texturechain = NULL; + tex->texturechain_tail = &tex->texturechain; + r_skyname = Cvar_FindVar ("r_skyname"); if (r_skyname != NULL) R_LoadSkys (r_skyname->string); diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index 8b0dfd02a..320c80d6e 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -244,11 +244,12 @@ DrawTextureChains (void) { int i; msurface_t *s; + texture_t *tex; qfglDisable (GL_BLEND); for (i = 0; i < r_worldentity.model->numtextures; i++) { - texture_t *tex = r_worldentity.model->textures[i]; + tex = r_worldentity.model->textures[i]; if (!tex) continue; qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); @@ -258,6 +259,9 @@ DrawTextureChains (void) tex->texturechain = NULL; tex->texturechain_tail = &tex->texturechain; } + tex = r_notexture_mip; + tex->texturechain = NULL; + tex->texturechain_tail = &tex->texturechain; qfglEnable (GL_BLEND); }