Account for indexed formats when matching texture formats
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled

Fixes https://github.com/libsdl-org/SDL/issues/14569
This commit is contained in:
Sam Lantinga
2025-12-03 21:21:52 -08:00
parent d83fa92d58
commit c61497b744
+3 -1
View File
@@ -1476,11 +1476,13 @@ static SDL_PixelFormat GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_Pix
}
} else {
bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format);
bool isIndexed = SDL_ISPIXELFORMAT_INDEXED(format);
// We just want to match the first format that has the same channels
for (i = 0; i < renderer->num_texture_formats; ++i) {
if (!SDL_ISPIXELFORMAT_FOURCC(renderer->texture_formats[i]) &&
SDL_ISPIXELFORMAT_ALPHA(renderer->texture_formats[i]) == hasAlpha) {
SDL_ISPIXELFORMAT_ALPHA(renderer->texture_formats[i]) == hasAlpha &&
SDL_ISPIXELFORMAT_INDEXED(renderer->texture_formats[i]) == isIndexed) {
return renderer->texture_formats[i];
}
}