]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix a crash that could occur if resizing the resize buffer twice in one upload call...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 21 Mar 2006 09:55:27 +0000 (09:55 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 21 Mar 2006 09:55:27 +0000 (09:55 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6160 d7cf8633-e32d-0410-b094-e92efae38249

gl_textures.c

index 7a53cd30d2fd00646e69c6a88a74df6fdb9335c5..cf4131c2e45477862048a77458d962364e6ee4f3 100644 (file)
@@ -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)