From a87383b8e9eb3e1c47a62db9c8a3120eb073b8d3 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 23 Apr 2007 19:39:18 +0000 Subject: [PATCH] modified Mod_LoadSkinFrame to not attempt to generate a fogging mask if not given the TEXF_ALPHA flag (in which case the fog mask would not be used anyway) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7160 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/model_shared.c b/model_shared.c index 090c93d1..a796f3f7 100644 --- a/model_shared.c +++ b/model_shared.c @@ -1070,22 +1070,25 @@ int Mod_LoadSkinFrame(skinframe_t *skinframe, const char *basename, int texturef basepixels_height = image_height; skinframe->base = R_LoadTexture2D (loadmodel->texturepool, basename, basepixels_width, basepixels_height, basepixels, TEXTYPE_RGBA, textureflags, NULL); - for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4) - if (basepixels[j] < 255) - break; - if (j < basepixels_width * basepixels_height * 4) + if (textureflags & TEXF_ALPHA) { - // has transparent pixels - pixels = (unsigned char *)Mem_Alloc(loadmodel->mempool, image_width * image_height * 4); - for (j = 0;j < image_width * image_height * 4;j += 4) + for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4) + if (basepixels[j] < 255) + break; + if (j < basepixels_width * basepixels_height * 4) { - pixels[j+0] = 255; - pixels[j+1] = 255; - pixels[j+2] = 255; - pixels[j+3] = basepixels[j+3]; + // has transparent pixels + pixels = (unsigned char *)Mem_Alloc(loadmodel->mempool, image_width * image_height * 4); + for (j = 0;j < image_width * image_height * 4;j += 4) + { + pixels[j+0] = 255; + pixels[j+1] = 255; + pixels[j+2] = 255; + pixels[j+3] = basepixels[j+3]; + } + skinframe->fog = R_LoadTexture2D (loadmodel->texturepool, va("%s_mask", basename), image_width, image_height, pixels, TEXTYPE_RGBA, textureflags, NULL); + Mem_Free(pixels); } - skinframe->fog = R_LoadTexture2D (loadmodel->texturepool, va("%s_mask", basename), image_width, image_height, pixels, TEXTYPE_RGBA, textureflags, NULL); - Mem_Free(pixels); } // _luma is supported for tenebrae compatibility -- 2.39.2