mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-14 08:31:00 +00:00
OpenGL2: Support picmip for DDS textures.
This commit is contained in:
parent
e25035672d
commit
06feb6115b
1 changed files with 24 additions and 20 deletions
|
@ -1868,7 +1868,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei
|
||||||
int dataFormat, dataType;
|
int dataFormat, dataType;
|
||||||
qboolean rgtc = (internalFormat == GL_COMPRESSED_RG_RGTC2);
|
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 bytesPer4x4Block = 0;
|
||||||
int miplevel = 0;
|
int miplevel = 0;
|
||||||
|
@ -1876,6 +1876,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei
|
||||||
switch (picFormat)
|
switch (picFormat)
|
||||||
{
|
{
|
||||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||||
|
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||||
case GL_COMPRESSED_RED_RGTC1:
|
case GL_COMPRESSED_RED_RGTC1:
|
||||||
|
@ -1900,11 +1901,26 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & IMGFLAG_PICMIP)
|
||||||
|
{
|
||||||
|
for (miplevel = r_picmip->integer; miplevel > 0 && numMips > 1; miplevel--, numMips--)
|
||||||
|
{
|
||||||
|
int 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++)
|
for (miplevel = 0; miplevel < numMips; miplevel++)
|
||||||
{
|
{
|
||||||
int size;
|
int size = ((width + 3) / 4) * ((height + 3) / 4) * bytesPer4x4Block;
|
||||||
|
|
||||||
size = ((width + 3) / 4) * ((height + 3) / 4) * bytesPer4x4Block;
|
|
||||||
|
|
||||||
if (subtexture)
|
if (subtexture)
|
||||||
qglCompressedTexSubImage2DARB(GL_TEXTURE_2D, miplevel, x, y, width, height, internalFormat, size, data);
|
qglCompressedTexSubImage2DARB(GL_TEXTURE_2D, miplevel, x, y, width, height, internalFormat, size, data);
|
||||||
|
@ -1913,9 +1929,6 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei
|
||||||
|
|
||||||
x >>= 1;
|
x >>= 1;
|
||||||
y >>= 1;
|
y >>= 1;
|
||||||
x -= x % 4;
|
|
||||||
y -= y % 4;
|
|
||||||
|
|
||||||
width = MAX(1, width >> 1);
|
width = MAX(1, width >> 1);
|
||||||
height = MAX(1, height >> 1);
|
height = MAX(1, height >> 1);
|
||||||
data += size;
|
data += size;
|
||||||
|
@ -1955,29 +1968,20 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei
|
||||||
|
|
||||||
if (flags & IMGFLAG_MIPMAP)
|
if (flags & IMGFLAG_MIPMAP)
|
||||||
{
|
{
|
||||||
int miplevel;
|
int miplevel = 0;
|
||||||
|
|
||||||
miplevel = 0;
|
|
||||||
while (width > 1 || height > 1)
|
while (width > 1 || height > 1)
|
||||||
{
|
{
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)
|
if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)
|
||||||
{
|
|
||||||
R_MipMapNormalHeight( data, data, width, height, glRefConfig.swizzleNormalmap );
|
R_MipMapNormalHeight( data, data, width, height, glRefConfig.swizzleNormalmap );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
R_MipMapsRGB( data, width, height );
|
R_MipMapsRGB( data, width, height );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
width >>= 1;
|
width = MAX(1, width >> 1);
|
||||||
height >>= 1;
|
height = MAX(1, height >> 1);
|
||||||
if (width < 1)
|
|
||||||
width = 1;
|
|
||||||
if (height < 1)
|
|
||||||
height = 1;
|
|
||||||
miplevel++;
|
miplevel++;
|
||||||
|
|
||||||
if ( data && r_colorMipLevels->integer )
|
if ( data && r_colorMipLevels->integer )
|
||||||
|
@ -2028,7 +2032,7 @@ static void Upload32(byte *data, int x, int y, int width, int height, GLenum pic
|
||||||
}
|
}
|
||||||
else if (!subtexture)
|
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);
|
RawImage_UploadTexture(data, 0, 0, width, height, picFormat, numMips, internalFormat, type, flags, qfalse);
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Reference in a new issue