mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed bug 3829 - Don't FOURCC format for target textures
FOURCC isn't supported by renderer back-ends for target access So use a correct format and fallback to with native/yuv path
This commit is contained in:
parent
9ef0b97c6d
commit
e87c7940f5
@ -1086,6 +1086,7 @@ SDL_Texture *
|
|||||||
SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h)
|
SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h)
|
||||||
{
|
{
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
|
SDL_bool texture_is_fourcc_and_target;
|
||||||
|
|
||||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||||
|
|
||||||
@ -1131,15 +1132,24 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int
|
|||||||
}
|
}
|
||||||
renderer->textures = texture;
|
renderer->textures = texture;
|
||||||
|
|
||||||
if (IsSupportedFormat(renderer, format)) {
|
/* FOURCC format cannot be used directly by renderer back-ends for target texture */
|
||||||
|
texture_is_fourcc_and_target = (access == SDL_TEXTUREACCESS_TARGET && SDL_ISPIXELFORMAT_FOURCC(texture->format));
|
||||||
|
|
||||||
|
if (texture_is_fourcc_and_target == SDL_FALSE && IsSupportedFormat(renderer, format)) {
|
||||||
if (renderer->CreateTexture(renderer, texture) < 0) {
|
if (renderer->CreateTexture(renderer, texture) < 0) {
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
texture->native = SDL_CreateTexture(renderer,
|
int closest_format;
|
||||||
GetClosestSupportedFormat(renderer, format),
|
|
||||||
access, w, h);
|
if (texture_is_fourcc_and_target == SDL_FALSE) {
|
||||||
|
closest_format = GetClosestSupportedFormat(renderer, format);
|
||||||
|
} else {
|
||||||
|
closest_format = renderer->info.texture_formats[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
texture->native = SDL_CreateTexture(renderer, closest_format, access, w, h);
|
||||||
if (!texture->native) {
|
if (!texture->native) {
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user