Fixed bug #2962 - when SDL_RenderReadPixels format = 0, used format of the target texture

include/SDL_render.h, format:
"0 to use the format of the rendering target "
main
Sylvain 2022-03-21 10:41:14 +01:00
parent 7f1feee02a
commit 9dc201d448
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E
1 changed files with 5 additions and 1 deletions

View File

@ -4177,7 +4177,11 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
FlushRenderCommands(renderer); /* we need to render before we read the results. */ FlushRenderCommands(renderer); /* we need to render before we read the results. */
if (!format) { if (!format) {
if (renderer->target == NULL) {
format = SDL_GetWindowPixelFormat(renderer->window); format = SDL_GetWindowPixelFormat(renderer->window);
} else {
format = renderer->target->format;
}
} }
real_rect.x = (int)SDL_floor(renderer->viewport.x); real_rect.x = (int)SDL_floor(renderer->viewport.x);