togles: don't use alpha channel in dxt1 decompression for textures without it

This commit is contained in:
nillerusr
2023-04-06 14:36:14 +03:00
parent ceda7d8ad0
commit dcdcf6b733
3 changed files with 113 additions and 681 deletions
+12 -12
View File
@@ -3409,8 +3409,8 @@ GLvoid *uncompressDXTc(GLsizei width, GLsizei height, GLenum format, GLsizei ima
// uncompress a DXTc image
// get pixel size of uncompressed image => fixed RGBA
int pixelsize = 4;
/* if (format==COMPRESSED_RGB_S3TC_DXT1_EXT)
pixelsize = 3;*/
if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || format == GL_COMPRESSED_SRGB_S3TC_DXT1_EXT)
pixelsize = 3;
// check with the size of the input data stream if the stream is in fact uncompressed
if (imageSize == width*height*pixelsize || data==NULL) {
// uncompressed stream
@@ -3469,16 +3469,16 @@ void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
if ((width<=0) || (height<=0)) {
return;
}
GLenum format = GL_RGBA;
GLenum intformat = GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
GLvoid *pixels = NULL;
if (isDXTc(internalformat)) {
pixels = NULL;
type = GL_UNSIGNED_BYTE;
bool hasAlpha = (internalformat != GL_COMPRESSED_RGB_S3TC_DXT1_EXT) && (internalformat != GL_COMPRESSED_SRGB_S3TC_DXT1_EXT);
GLenum format = hasAlpha ? GL_RGBA : GL_RGB;
GLenum intformat = hasAlpha ? GL_RGBA8 : GL_RGB8;
GLenum type = GL_UNSIGNED_BYTE;
GLvoid *pixels = NULL;
if (isDXTc(internalformat))
{
int srgb = isDXTcSRGB(internalformat);
int simpleAlpha = 0;
int complexAlpha = 0;
@@ -3492,7 +3492,7 @@ void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
}
if( srgb )
intformat = GL_SRGB8_ALPHA8;
intformat = hasAlpha ? GL_SRGB8_ALPHA8 : GL_SRGB8;
}
gGL->glTexImage2D(target, level, intformat, width, height, border, format, type, pixels);