Fixed bug 3349 - GLES2_RenderReadPixels doesn't use target texture format

Simon Hug

The OpenGL ES 2 renderer does not check the target texture format when using SDL_RenderReadPixels and just always uses ABGR8888. This can result in swapped or wrong colors.

The attached patch adds a check and selects the target texture format, if a texture is set as the target.
This commit is contained in:
Sam Lantinga 2016-10-01 11:38:53 -07:00
parent 225b99cc77
commit f1c567b2c1
3 changed files with 3 additions and 3 deletions

View file

@ -1414,7 +1414,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 pixel_format, void * pixels, int pitch)
{
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
Uint32 temp_format = SDL_PIXELFORMAT_ARGB8888;
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
void *temp_pixels;
int temp_pitch;
GLint internalFormat;