From b864489f3bef3a6722c4f4a8ed041fb033c2faaf Mon Sep 17 00:00:00 2001 From: res Date: Thu, 10 Jan 2008 09:05:03 +0000 Subject: [PATCH] Fix runaway mipmap upload when NULL texture data was specified. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7946 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_textures.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gl_textures.c b/gl_textures.c index f2fac414..b4649e05 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -874,6 +874,12 @@ static void R_Upload(gltexture_t *glt, const unsigned char *data, int fragx, int Image_MipReduce32(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1); prevbuffer = resizebuffer; } + else + { + if (width > 1) width >>= 1; + if (height > 1) height >>= 1; + if (depth > 1) depth >>= 1; + } qglTexImage1D(GL_TEXTURE_1D, mip++, glt->glinternalformat, width, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR } } @@ -889,6 +895,12 @@ static void R_Upload(gltexture_t *glt, const unsigned char *data, int fragx, int Image_MipReduce32(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1); prevbuffer = resizebuffer; } + else + { + if (width > 1) width >>= 1; + if (height > 1) height >>= 1; + if (depth > 1) depth >>= 1; + } qglTexImage2D(GL_TEXTURE_2D, mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR } } @@ -904,6 +916,12 @@ static void R_Upload(gltexture_t *glt, const unsigned char *data, int fragx, int Image_MipReduce32(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1); prevbuffer = resizebuffer; } + else + { + if (width > 1) width >>= 1; + if (height > 1) height >>= 1; + if (depth > 1) depth >>= 1; + } qglTexImage3D(GL_TEXTURE_3D, mip++, glt->glinternalformat, width, height, depth, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR } } @@ -941,6 +959,12 @@ static void R_Upload(gltexture_t *glt, const unsigned char *data, int fragx, int Image_MipReduce32(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1); prevbuffer = resizebuffer; } + else + { + if (width > 1) width >>= 1; + if (height > 1) height >>= 1; + if (depth > 1) depth >>= 1; + } qglTexImage2D(cubemapside[i], mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR } } -- 2.39.2