Skip to content

Commit ea83cc7

Browse files
committed
tr_image: detect RED images
1 parent a8782f0 commit ea83cc7

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
@@ -1090,8 +1090,32 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
10901090
break;
10911091
}
10921092
}
1093+
}
1094+
1095+
if ( internalFormat == GL_RGB8 )
1096+
{
1097+
/* Scan the texture for green and blue channels' max values
1098+
and verify if the green and blue channels are being used or not. */
1099+
1100+
c = image->width * image->height;
1101+
scan = dataArray[0];
1102+
1103+
internalFormat = GL_RED;
1104+
1105+
for ( i = 0; i < c * 4; i += 4 )
1106+
{
1107+
if ( scan[ i + 1 ] != 0 )
1108+
{
1109+
internalFormat = GL_RGB8;
1110+
break;
1111+
}
10931112

1094-
internalFormat = hasAlpha ? GL_RGBA8 : GL_RGB8;
1113+
if ( scan[ i + 2 ] != 0 )
1114+
{
1115+
internalFormat = GL_RGB8;
1116+
break;
1117+
}
1118+
}
10951119
}
10961120
}
10971121

0 commit comments

Comments
 (0)