@@ -1234,146 +1234,161 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
12341234
12351235 GL_CheckErrors ();
12361236
1237+ switch ( image->internalFormat ) {
1238+ case GL_RGBA:
1239+ case GL_RGBA8:
1240+ case GL_RGBA16:
1241+ case GL_RGBA16F:
1242+ case GL_RGBA32F:
1243+ case GL_RGBA32UI:
1244+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1245+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1246+ image->bits |= IF_ALPHA;
1247+ }
1248+
1249+ if ( samples ) {
1250+ ASSERT_EQ ( scaledBuffer, nullptr );
1251+
1252+ GL_Unbind ( image );
1253+ return ;
1254+ }
1255+
12371256 // set filter type
1238- if ( !samples ) {
1239- switch ( image->filterType ) {
1240- case filterType_t::FT_DEFAULT:
1257+ switch ( image->filterType ) {
1258+ case filterType_t::FT_DEFAULT:
12411259
1242- // set texture anisotropy
1243- if ( glConfig.textureAnisotropyAvailable )
1244- {
1245- glTexParameterf ( image->type , GL_TEXTURE_MAX_ANISOTROPY_EXT, glConfig.textureAnisotropy );
1246- }
1260+ // set texture anisotropy
1261+ if ( glConfig.textureAnisotropyAvailable )
1262+ {
1263+ glTexParameterf ( image->type , GL_TEXTURE_MAX_ANISOTROPY_EXT, glConfig.textureAnisotropy );
1264+ }
12471265
1248- glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, gl_filter_min );
1249- glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, gl_filter_max );
1250- break ;
1266+ glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, gl_filter_min );
1267+ glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, gl_filter_max );
1268+ break ;
12511269
1252- case filterType_t::FT_LINEAR:
1253- glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1254- glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1255- break ;
1270+ case filterType_t::FT_LINEAR:
1271+ glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1272+ glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1273+ break ;
12561274
1257- case filterType_t::FT_NEAREST:
1258- glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, GL_NEAREST );
1259- glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, GL_NEAREST );
1260- break ;
1275+ case filterType_t::FT_NEAREST:
1276+ glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, GL_NEAREST );
1277+ glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, GL_NEAREST );
1278+ break ;
12611279
1262- default :
1263- Log::Warn ( " unknown filter type for image '%s'" , image->name );
1264- glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1265- glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1266- break ;
1267- }
1280+ default :
1281+ Log::Warn ( " unknown filter type for image '%s'" , image->name );
1282+ glTexParameterf ( image->type , GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1283+ glTexParameterf ( image->type , GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1284+ break ;
12681285 }
12691286
12701287 GL_CheckErrors ();
12711288
12721289 // set wrap type
1273- if ( !samples ) {
1274- if ( image->wrapType .s == image->wrapType .t ) {
1275- switch ( image->wrapType .s ) {
1276- case wrapTypeEnum_t::WT_REPEAT:
1277- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1278- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1279- break ;
1290+ if ( image->wrapType .s == image->wrapType .t ) {
1291+ switch ( image->wrapType .s ) {
1292+ case wrapTypeEnum_t::WT_REPEAT:
1293+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1294+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1295+ break ;
12801296
1281- case wrapTypeEnum_t::WT_CLAMP:
1282- case wrapTypeEnum_t::WT_EDGE_CLAMP:
1283- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1284- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1285- break ;
1286- case wrapTypeEnum_t::WT_ONE_CLAMP:
1287- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1288- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1289- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, oneClampBorder );
1290- break ;
1291- case wrapTypeEnum_t::WT_ZERO_CLAMP:
1292- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1293- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1294- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, zeroClampBorder );
1295- break ;
1297+ case wrapTypeEnum_t::WT_CLAMP:
1298+ case wrapTypeEnum_t::WT_EDGE_CLAMP:
1299+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1300+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1301+ break ;
1302+ case wrapTypeEnum_t::WT_ONE_CLAMP:
1303+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1304+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1305+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, oneClampBorder );
1306+ break ;
1307+ case wrapTypeEnum_t::WT_ZERO_CLAMP:
1308+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1309+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1310+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, zeroClampBorder );
1311+ break ;
12961312
1297- case wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP:
1298- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1299- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1300- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, alphaZeroClampBorder );
1301- break ;
1313+ case wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP:
1314+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1315+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1316+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, alphaZeroClampBorder );
1317+ break ;
13021318
1303- default :
1304- Log::Warn ( " unknown wrap type for image '%s'" , image->name );
1305- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1306- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1307- break ;
1308- }
1309- } else {
1310- // warn about mismatched clamp types if both require a border colour to be set
1311- if ( ( image->wrapType .s == wrapTypeEnum_t::WT_ZERO_CLAMP || image->wrapType .s == wrapTypeEnum_t::WT_ONE_CLAMP || image->wrapType .s == wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP ) &&
1312- ( image->wrapType .t == wrapTypeEnum_t::WT_ZERO_CLAMP || image->wrapType .t == wrapTypeEnum_t::WT_ONE_CLAMP || image->wrapType .t == wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP ) ) {
1313- Log::Warn ( " mismatched wrap types for image '%s'" , image->name );
1314- }
1319+ default :
1320+ Log::Warn ( " unknown wrap type for image '%s'" , image->name );
1321+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1322+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1323+ break ;
1324+ }
1325+ } else {
1326+ // warn about mismatched clamp types if both require a border colour to be set
1327+ if ( ( image->wrapType .s == wrapTypeEnum_t::WT_ZERO_CLAMP || image->wrapType .s == wrapTypeEnum_t::WT_ONE_CLAMP || image->wrapType .s == wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP ) &&
1328+ ( image->wrapType .t == wrapTypeEnum_t::WT_ZERO_CLAMP || image->wrapType .t == wrapTypeEnum_t::WT_ONE_CLAMP || image->wrapType .t == wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP ) ) {
1329+ Log::Warn ( " mismatched wrap types for image '%s'" , image->name );
1330+ }
13151331
1316- switch ( image->wrapType .s ) {
1317- case wrapTypeEnum_t::WT_REPEAT:
1318- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1319- break ;
1332+ switch ( image->wrapType .s ) {
1333+ case wrapTypeEnum_t::WT_REPEAT:
1334+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1335+ break ;
13201336
1321- case wrapTypeEnum_t::WT_CLAMP:
1322- case wrapTypeEnum_t::WT_EDGE_CLAMP:
1323- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1324- break ;
1337+ case wrapTypeEnum_t::WT_CLAMP:
1338+ case wrapTypeEnum_t::WT_EDGE_CLAMP:
1339+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1340+ break ;
13251341
1326- case wrapTypeEnum_t::WT_ONE_CLAMP:
1327- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1328- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, oneClampBorder );
1329- break ;
1342+ case wrapTypeEnum_t::WT_ONE_CLAMP:
1343+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1344+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, oneClampBorder );
1345+ break ;
13301346
1331- case wrapTypeEnum_t::WT_ZERO_CLAMP:
1332- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1333- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, zeroClampBorder );
1334- break ;
1347+ case wrapTypeEnum_t::WT_ZERO_CLAMP:
1348+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1349+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, zeroClampBorder );
1350+ break ;
13351351
1336- case wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP:
1337- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1338- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, alphaZeroClampBorder );
1339- break ;
1352+ case wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP:
1353+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
1354+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, alphaZeroClampBorder );
1355+ break ;
13401356
1341- default :
1342- Log::Warn ( " unknown wrap type for image '%s' axis S" , image->name );
1343- glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1344- break ;
1345- }
1357+ default :
1358+ Log::Warn ( " unknown wrap type for image '%s' axis S" , image->name );
1359+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_S, GL_REPEAT );
1360+ break ;
1361+ }
13461362
1347- switch ( image->wrapType .t ) {
1348- case wrapTypeEnum_t::WT_REPEAT:
1349- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1350- break ;
1363+ switch ( image->wrapType .t ) {
1364+ case wrapTypeEnum_t::WT_REPEAT:
1365+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1366+ break ;
13511367
1352- case wrapTypeEnum_t::WT_CLAMP:
1353- case wrapTypeEnum_t::WT_EDGE_CLAMP:
1354- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1355- break ;
1368+ case wrapTypeEnum_t::WT_CLAMP:
1369+ case wrapTypeEnum_t::WT_EDGE_CLAMP:
1370+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1371+ break ;
13561372
1357- case wrapTypeEnum_t::WT_ONE_CLAMP:
1358- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1359- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, oneClampBorder );
1360- break ;
1373+ case wrapTypeEnum_t::WT_ONE_CLAMP:
1374+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1375+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, oneClampBorder );
1376+ break ;
13611377
1362- case wrapTypeEnum_t::WT_ZERO_CLAMP:
1363- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1364- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, zeroClampBorder );
1365- break ;
1378+ case wrapTypeEnum_t::WT_ZERO_CLAMP:
1379+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1380+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, zeroClampBorder );
1381+ break ;
13661382
1367- case wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP:
1368- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1369- glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, alphaZeroClampBorder );
1370- break ;
1383+ case wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP:
1384+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
1385+ glTexParameterfv ( image->type , GL_TEXTURE_BORDER_COLOR, alphaZeroClampBorder );
1386+ break ;
13711387
1372- default :
1373- Log::Warn ( " unknown wrap type for image '%s' axis T" , image->name );
1374- glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1375- break ;
1376- }
1388+ default :
1389+ Log::Warn ( " unknown wrap type for image '%s' axis T" , image->name );
1390+ glTexParameterf ( image->type , GL_TEXTURE_WRAP_T, GL_REPEAT );
1391+ break ;
13771392 }
13781393 }
13791394
@@ -1384,19 +1399,6 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
13841399 ri.Hunk_FreeTempMemory ( scaledBuffer );
13851400 }
13861401
1387- switch ( image->internalFormat )
1388- {
1389- case GL_RGBA:
1390- case GL_RGBA8:
1391- case GL_RGBA16:
1392- case GL_RGBA16F:
1393- case GL_RGBA32F:
1394- case GL_RGBA32UI:
1395- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1396- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1397- image->bits |= IF_ALPHA;
1398- }
1399-
14001402 GL_Unbind ( image );
14011403}
14021404
0 commit comments