Skip to content

Commit

Permalink
Fixed bug 3349 - GLES2_RenderReadPixels doesn't use target texture fo…
Browse files Browse the repository at this point in the history
…rmat

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.
  • Loading branch information
slouken committed Oct 1, 2016
1 parent 51d6371 commit 061cc5e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/render/opengl/SDL_render_gl.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/render/opengles/SDL_render_gles.c
Expand Up @@ -1069,7 +1069,7 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 pixel_format, void * pixels, int pitch)
{
GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
void *temp_pixels;
int temp_pitch;
Uint8 *src, *dst, *tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/render/opengles2/SDL_render_gles2.c
Expand Up @@ -1817,7 +1817,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 pixel_format, void * pixels, int pitch)
{
GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
void *temp_pixels;
int temp_pitch;
Uint8 *src, *dst, *tmp;
Expand Down

0 comments on commit 061cc5e

Please sign in to comment.