X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=gl_textures.c;h=558b1f59cb457bfab6721dec5a539c06e0e5c99e;hp=a502f81a84e00773f8f057e535f4d0e2de93804d;hb=fabdca42b48cc4acf214c06adda9814e5cce8577;hpb=279f0872533dc81f28514584be5e41481fc106da diff --git a/gl_textures.c b/gl_textures.c index a502f81a..558b1f59 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -554,8 +554,7 @@ static void GL_SetupTextureParameters(int flags, int texturetype) CHECKGLERROR qglTexParameteri(textureenum, GL_TEXTURE_WRAP_S, wrapmode); - if (gltexturetypedimensions[texturetype] >= 2) - qglTexParameteri(textureenum, GL_TEXTURE_WRAP_T, wrapmode); + qglTexParameteri(textureenum, GL_TEXTURE_WRAP_T, wrapmode); if (gltexturetypedimensions[texturetype] >= 3) qglTexParameteri(textureenum, GL_TEXTURE_WRAP_R, wrapmode); @@ -621,7 +620,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data) { // promote paletted to RGBA, so we only have to worry about RGB and // RGBA in the rest of this code - R_MakeResizeBufferBigger(glt->image->width * glt->image->height * glt->image->depth * glt->image->bytesperpixel); + R_MakeResizeBufferBigger(glt->image->width * glt->image->height * glt->image->depth * glt->image->sides * glt->image->bytesperpixel); Image_Copy8bitRGBA(prevbuffer, colorconvertbuffer, glt->width * glt->height * glt->depth, glt->palette); prevbuffer = colorconvertbuffer; } @@ -655,7 +654,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data) for (height = 1;height < glt->height;height <<= 1); for (depth = 1;depth < glt->depth ;depth <<= 1); - R_MakeResizeBufferBigger(width * height * depth * glt->image->bytesperpixel); + R_MakeResizeBufferBigger(width * height * depth * glt->image->sides * glt->image->bytesperpixel); if (prevbuffer == NULL) { @@ -671,29 +670,31 @@ static void R_Upload(gltexture_t *glt, qbyte *data) { // promote paletted to RGBA, so we only have to worry about RGB and // RGBA in the rest of this code - Image_Copy8bitRGBA(prevbuffer, colorconvertbuffer, glt->width * glt->height * glt->depth, glt->palette); + Image_Copy8bitRGBA(prevbuffer, colorconvertbuffer, glt->width * glt->height * glt->depth * glt->image->sides, glt->palette); prevbuffer = colorconvertbuffer; } + } + // 3 and 4 are converted by the driver to it's preferred format for the current display mode + internalformat = 3; + if (glt->flags & TEXF_ALPHA) + internalformat = 4; + + // cubemaps contain multiple images and thus get processed a bit differently + if (glt->image->texturetype != GLTEXTURETYPE_CUBEMAP) + { if (glt->width != width || glt->height != height || glt->depth != depth) { Image_Resample(prevbuffer, glt->width, glt->height, glt->depth, resizebuffer, width, height, depth, glt->image->bytesperpixel, r_lerpimages.integer); prevbuffer = resizebuffer; } - - // apply picmip/max_size limitations + // picmip/max_size while (width > glt->image->width || height > glt->image->height || depth > glt->image->depth) { Image_MipReduce(prevbuffer, resizebuffer, &width, &height, &depth, glt->image->width, glt->image->height, glt->image->depth, glt->image->bytesperpixel); prevbuffer = resizebuffer; } } - - // 3 and 4 are converted by the driver to it's preferred format for the current display mode - internalformat = 3; - if (glt->flags & TEXF_ALPHA) - internalformat = 4; - mip = 0; switch(glt->image->texturetype) { @@ -747,6 +748,18 @@ static void R_Upload(gltexture_t *glt, qbyte *data) { prevbuffer = texturebuffer; texturebuffer += width * height * depth * glt->textype->inputbytesperpixel; + if (glt->width != width || glt->height != height || glt->depth != depth) + { + Image_Resample(prevbuffer, glt->width, glt->height, glt->depth, resizebuffer, width, height, depth, glt->image->bytesperpixel, r_lerpimages.integer); + prevbuffer = resizebuffer; + } + // picmip/max_size + while (width > glt->image->width || height > glt->image->height || depth > glt->image->depth) + { + Image_MipReduce(prevbuffer, resizebuffer, &width, &height, &depth, glt->image->width, glt->image->height, glt->image->depth, glt->image->bytesperpixel); + prevbuffer = resizebuffer; + } + mip = 0; qglTexImage2D(cubemapside[i], mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer); CHECKGLERROR if (glt->flags & TEXF_MIPMAP)