Skip to content

Commit 7042d99

Browse files
committed
tr_image: add some GL format checks and asserts
1 parent 8c1730e commit 7042d99

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/engine/renderer/tr_image.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,29 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
11641164
}
11651165
}
11661166

1167+
// Make sure we prefer GL_R8 when ARB_texture_rg is available.
1168+
ASSERT( !( internalFormat == GL_RED && glConfig.textureRGAvailable ) );
1169+
// Make sure we only use GL_R8 when ARB_texture_rg is available.
1170+
ASSERT( !( internalFormat == GL_R8 && !glConfig.textureRGAvailable ) );
1171+
// Make sure we only use GL_RG8 when ARB_texture_rg is available.
1172+
ASSERT( !( internalFormat == GL_RG8 && !glConfig.textureRGAvailable ) );
1173+
// Make sure we only use GL_SR8_EXT when EXT_texture_sRGB_R8 is available.
1174+
ASSERT( !( internalFormat == GL_R8 && isSRGB && !glConfig.textureSrgbR8Available ) );
1175+
// Make sure we only use GL_SRG8_EXT when EXT_texture_sRGB_RG8 is available.
1176+
ASSERT( !( internalFormat == GL_RG8 && isSRGB && !glConfig.textureSrgbRG8Available ) );
1177+
1178+
// Make sure we prefer GL_RGB but don't enforce it yet.
1179+
if ( internalFormat == GL_RGB )
1180+
{
1181+
Log::Warn( "Supposedly, you should use an explicit format instead of GL_RGB for image %s", name );
1182+
}
1183+
1184+
// Make sure we prefer GL_RGBA but don't enforce it yet.
1185+
if ( internalFormat == GL_RGBA )
1186+
{
1187+
Log::Warn( "Supposedly, you should use an explicit format instead of GL_RGBA for image %s", name );
1188+
}
1189+
11671190
Log::Debug( "Uploading image %s (%d×%d, %d layers, %0#x type, %0#x format)", name, scaledWidth, scaledHeight, numLayers, image->type, internalFormat );
11681191

11691192
// 3D textures are uploaded in slices via glTexSubImage3D,

0 commit comments

Comments
 (0)