From 9eca67c0bf0b005374190839de80235bab054450 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 21 Mar 2006 09:55:27 +0000 Subject: [PATCH] fix a crash that could occur if resizing the resize buffer twice in one upload call, and also fix a bug where the player setup menu's translated player pic was being treated as a subimage update which doesn't work because that image is scaled up, not a natural power of 2 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6160 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_textures.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gl_textures.c b/gl_textures.c index 7a53cd30..cf4131c2 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -639,6 +639,12 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum); CHECKGLERROR + // these are rounded up versions of the size to do better resampling + for (width = 1;width < glt->inputwidth ;width <<= 1); + for (height = 1;height < glt->inputheight;height <<= 1); + for (depth = 1;depth < glt->inputdepth ;depth <<= 1); + + R_MakeResizeBufferBigger(width * height * depth * glt->sides * glt->bytesperpixel); R_MakeResizeBufferBigger(fragwidth * fragheight * fragdepth * glt->sides * glt->bytesperpixel); if (prevbuffer == NULL) @@ -654,14 +660,7 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy prevbuffer = colorconvertbuffer; } - // these are rounded up versions of the size to do better resampling - for (width = 1;width < glt->inputwidth ;width <<= 1); - for (height = 1;height < glt->inputheight;height <<= 1); - for (depth = 1;depth < glt->inputdepth ;depth <<= 1); - - R_MakeResizeBufferBigger(width * height * depth * glt->sides * glt->bytesperpixel); - - if ((glt->flags & (TEXF_MIPMAP | TEXF_PICMIP | GLTEXF_UPLOAD)) == 0) + if ((glt->flags & (TEXF_MIPMAP | TEXF_PICMIP | GLTEXF_UPLOAD)) == 0 && glt->inputwidth == glt->tilewidth && glt->inputheight == glt->tileheight && glt->inputdepth == glt->tiledepth) { // update a portion of the image switch(glt->texturetype) -- 2.39.2