Skip to content

Commit d335c94

Browse files
committed
tr_image: detect RED images
1 parent a441628 commit d335c94

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/engine/renderer/tr_image.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,31 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
10651065
}
10661066
}
10671067

1068-
if ( internalFormat == GL_RGBA8 )
1068+
if ( internalFormat == GL_RGB8 )
1069+
{
1070+
c = image->width * image->height;
1071+
scan = dataArray[0];
1072+
1073+
bool hasRGB = false;
1074+
1075+
for ( i = 0; i < c * 4; i += 4 )
1076+
{
1077+
if ( scan[ i + 1 ] != 0 )
1078+
{
1079+
hasRGB = true;
1080+
break;
1081+
}
1082+
1083+
if ( scan[ i + 2 ] != 0 )
1084+
{
1085+
hasRGB = true;
1086+
break;
1087+
}
1088+
}
1089+
1090+
internalFormat = hasRGB ? GL_RGB8 : GL_RED;
1091+
}
1092+
else if ( internalFormat == GL_RGBA8 )
10691093
{
10701094
// scan the texture for each channel's max values
10711095
// and verify if the alpha channel is being used or not

0 commit comments

Comments
 (0)