mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-13 15:23:34 +00:00
render: Fix texture format selection for color-keyed indexed surfaces
015cc6abroke texture format selection for this kind of surface if the renderer's first texture format doesn't happen to have an alpha channel. This happens for on-screen software renderers on Windows, whose preferred format is the window's own `SDL_PIXELFORMAT_XRGB8888`. This fixed check also cover the intent behind015cc6a, assuming that indexed and alpha formats are mutually exclusive.
This commit is contained in:
@@ -1844,10 +1844,13 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
|
||||
}
|
||||
}
|
||||
|
||||
// Indexed formats don't support the transparency needed for color-keyed surfaces
|
||||
bool preferIndexed = SDL_ISPIXELFORMAT_INDEXED(surface->format) && !needAlpha;
|
||||
|
||||
for (i = 0; i < renderer->num_texture_formats; ++i) {
|
||||
if (!SDL_ISPIXELFORMAT_FOURCC(renderer->texture_formats[i]) &&
|
||||
SDL_ISPIXELFORMAT_ALPHA(renderer->texture_formats[i]) == needAlpha &&
|
||||
SDL_ISPIXELFORMAT_INDEXED(renderer->texture_formats[i]) == SDL_ISPIXELFORMAT_INDEXED(surface->format)) {
|
||||
SDL_ISPIXELFORMAT_INDEXED(renderer->texture_formats[i]) == preferIndexed) {
|
||||
format = renderer->texture_formats[i];
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user