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 2640 - Unable to SDL_SetRenderTarget to original surface for software renderer without a window
Summary: Unable to SDL_SetRenderTarget to original surface for software renderer witho...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-12 23:45 UTC by Damian Kaczmarek
Modified: 2014-07-13 16:05 UTC (History)
0 users

See Also:


Attachments
Test showing the reported problem (3.42 KB, text/x-c++src)
2014-07-12 23:45 UTC, Damian Kaczmarek
Details
Fix the issue by explicitly setting renderer's window to backing surface (407 bytes, patch)
2014-07-13 09:22 UTC, Damian Kaczmarek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Damian Kaczmarek 2014-07-12 23:45:17 UTC
Created attachment 1748 [details]
Test showing the reported problem

Basically this bug is probably not a common use case. My goal is to allow rendering totally without a window, for example to a screenshot and I need to rely on SDL_SetRenderTarget to properly work for a purely software renderer created by SDL_CreateSoftwareRenderer.

Some facts:
0) Possibly does not work for SDL 2.0.0
1) WORKS properly for SDL 2.0.3
2) Does not work for latest HG
Could be bisected probably, can HG do this?

I attach a test case which properly renders on SDL 2.0.3 (it has rendering from bug #1743) but the window is totally black for latest SDL from hg.

g++ sdl2_software_set_render_target_bug.cpp -lSDL2 && ./a.out

Expected: Green screen with moving rectangle
Comment 1 Damian Kaczmarek 2014-07-13 09:22:20 UTC
Created attachment 1749 [details]
Fix the issue by explicitly setting renderer's window to backing surface

Actually please scratch the "WORKS properly for SDL 2.0.3" part. I actually have fixed this problem in SDL sources before but couldn't connect the dots due to the other bug also occurring at the same time. I attach a patch which fixes the problem. Please review if doesn't break anything else. In my opinion it makes sense as "window" is assumed for all renderers so for the software renderer setting window to its backing surface makes only sense.
Comment 2 Sam Lantinga 2014-07-13 16:05:39 UTC
Your patch looks good, thanks!
https://hg.libsdl.org/SDL/rev/f061a86fbb08