diff options
author | SmileTheory <SmileTheory@gmail.com> | 2015-12-21 20:24:19 -0800 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2016-04-07 11:46:05 +0100 |
commit | e78dc015d1c94fbe4fa5014d412a2cdf23f2dc7d (patch) | |
tree | f14fe1f1968b83ef94ee6b468c957605b4e4f439 /src/renderergl2 | |
parent | 5e21024a3ce91664273d61f26de679e6a5e9a213 (diff) |
OpenGL2: Support picmip for DDS textures.
Diffstat (limited to 'src/renderergl2')
-rw-r--r-- | src/renderergl2/tr_image.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/renderergl2/tr_image.c b/src/renderergl2/tr_image.c index c35af4c2..74eddfe0 100644 --- a/src/renderergl2/tr_image.c +++ b/src/renderergl2/tr_image.c @@ -1869,7 +1869,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei int dataFormat, dataType; qboolean rgtc = (internalFormat == GL_COMPRESSED_RG_RGTC2); - if (picFormat != GL_RGBA8 && picFormat != GL_SRGB8_ALPHA8_EXT) + if (data && picFormat != GL_RGBA8 && picFormat != GL_SRGB8_ALPHA8_EXT) { int bytesPer4x4Block = 0; int miplevel = 0; @@ -1877,6 +1877,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei switch (picFormat) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_RED_RGTC1: @@ -1901,11 +1902,26 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei break; } - for (miplevel = 0; miplevel < numMips; miplevel++) + if (flags & IMGFLAG_PICMIP) { - int size; + for (miplevel = r_picmip->integer; miplevel > 0 && numMips > 1; miplevel--, numMips--) + { + int size = ((width + 3) / 4) * ((height + 3) / 4) * bytesPer4x4Block; - size = ((width + 3) / 4) * ((height + 3) / 4) * bytesPer4x4Block; + x >>= 1; + y >>= 1; + width = MAX(1, width >> 1); + height = MAX(1, height >> 1); + data += size; + } + } + + if (!(flags & IMGFLAG_MIPMAP)) + numMips = 1; + + for (miplevel = 0; miplevel < numMips; miplevel++) + { + int size = ((width + 3) / 4) * ((height + 3) / 4) * bytesPer4x4Block; if (subtexture) qglCompressedTexSubImage2DARB(GL_TEXTURE_2D, miplevel, x, y, width, height, internalFormat, size, data); @@ -1914,9 +1930,6 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei x >>= 1; y >>= 1; - x -= x % 4; - y -= y % 4; - width = MAX(1, width >> 1); height = MAX(1, height >> 1); data += size; @@ -1956,29 +1969,20 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei if (flags & IMGFLAG_MIPMAP) { - int miplevel; + int miplevel = 0; - miplevel = 0; while (width > 1 || height > 1) { if (data) { if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) - { R_MipMapNormalHeight( data, data, width, height, glRefConfig.swizzleNormalmap ); - } else - { R_MipMapsRGB( data, width, height ); - } } - width >>= 1; - height >>= 1; - if (width < 1) - width = 1; - if (height < 1) - height = 1; + width = MAX(1, width >> 1); + height = MAX(1, height >> 1); miplevel++; if ( data && r_colorMipLevels->integer ) @@ -2029,7 +2033,7 @@ static void Upload32(byte *data, int x, int y, int width, int height, GLenum pic } else if (!subtexture) { - if (picFormat != GL_RGBA8) + if (picFormat != GL_RGBA8 && picFormat != GL_SRGB8_ALPHA8_EXT) { RawImage_UploadTexture(data, 0, 0, width, height, picFormat, numMips, internalFormat, type, flags, qfalse); goto done; |