We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2006 - Image Renders upside down with RenderTarget set and SDL_RenderCopyEx()
Summary: Image Renders upside down with RenderTarget set and SDL_RenderCopyEx()
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.1
Hardware: x86 iOS (All)
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
: 1851 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-08-02 02:39 UTC by Pallav Nawani
Modified: 2013-12-04 13:00 UTC (History)
2 users (show)

See Also:


Attachments
Patch to solve Bug2006 (1.21 KB, patch)
2013-09-02 13:17 UTC, Pallav Nawani
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pallav Nawani 2013-08-02 02:39:16 UTC
Steps to reproduce. 

1. Set render target and render to it using SDL_RenderCopyEx().
SDL_SetRenderTarget(aRenderer, aTexture);
SDL_RenderCopyEx(aRenderer, aNotherTexture, ...);

2. Remove render target
SDL_SetRenderTarget(aRenderer, NULL);

3. Now draw render target texture onscreen
SDL_RenderCopy(aRenderer, aTexture, ...);

4.
Result: aTexture is upside down. Happens on all opengles1 targets (iOS/Android).
Comment 1 Gabriel Jacobo 2013-08-02 10:01:42 UTC
I can not reproduce this, I just tried it on my Nexus 4 by forcing the OpenGL ES 1 renderer and it seems to work fine. Can you provide a working example to verify?
Comment 2 Pallav Nawani 2013-08-02 12:34:33 UTC
This bug was observed on iPad2. I assumed that it would exist on android devices too, but I guess not. I will attempt to add more information when I am back in the office.
Comment 3 Pallav Nawani 2013-08-08 23:13:44 UTC
On additional testing, the bug is not present on Android devices. It shows up only   on iOS.
Comment 4 Pallav Nawani 2013-09-02 13:17:40 UTC
Created attachment 1317 [details]
Patch to solve Bug2006

First we disable useDrawTexture because this is a direct pixel copy and does not respect  viewport orientation. Then we add code to flip the viewport mapping (Something like this is already being done in the standard opengl renderer).
Comment 5 Pallav Nawani 2013-09-02 13:18:49 UTC
The issue shows on Sony Xperia Play and Samsung Galaxy Tab 2 as well.
Comment 6 Gabriel Jacobo 2013-09-02 15:33:30 UTC
I think the proper fix for this would be to copy the code in GLES_RenderCopy which correctly accounts for all cases.

See here: http://hg.libsdl.org/SDL/annotate/e978048ced60/src/render/opengles/SDL_render_gles.c#l829


BTW, the mRenderingToTexture variable is redundant, you can check if there's a render target active by verifying 

SDL_Renderer *renderer
renderer->target != NULL
Comment 7 Pallav Nawani 2013-09-03 04:54:42 UTC
True, copying the code from GLES_RenderCopy() would be a better fix.
Comment 8 Sam Lantinga 2013-09-05 13:46:48 UTC
Can you provide a patch based on GLES_RenderCopy() that has been tested on both Android and iOS?

Thanks!
Comment 9 Sam Lantinga 2013-09-05 13:49:05 UTC
*** Bug 1851 has been marked as a duplicate of this bug. ***
Comment 10 Josef Vanzura 2013-11-24 23:25:05 UTC
I have same problem on Lenovo A1000 with SDL_RenderCopy (no Ex).
Comment 11 Sam Lantinga 2013-11-28 11:46:16 UTC
I think this may be fixed, can you try in the latest SDL snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip
Comment 12 Josef Vanzura 2013-12-02 19:33:43 UTC
(In reply to Sam Lantinga from comment #11)
> I think this may be fixed, can you try in the latest SDL snapshot?
> http://www.libsdl.org/tmp/SDL-2.0.zip

Yes, works like a charm. Thank you
Comment 13 Gabriel Jacobo 2013-12-04 13:00:07 UTC
Marking as fixed based on feedback from Josef Vanzura. Feel free to reopen if the problem persists.