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 3825

Summary: provide access to SDL_Surface of already-created software renderer(s)
Product: SDL Reporter: David Ludwig <dll>
Component: renderAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: dll
Version: HG 2.0   
Hardware: All   
OS: All   
Attachments: possible implementation, #1

Description David Ludwig 2017-09-13 17:22:36 UTC
Created attachment 2932 [details]
possible implementation, #1

If and when a software SDL_Renderer is created, there does not appear to be any means to get its inner SDL_Surface, once the renderer has been created.  An SDL_Surface can be passed into SDL_CreateSoftwareRenderer, and that SDL_Surface may be used later on, however, if one is created through other means, such as a user setting the SDL_RENDER_DRIVER environment variable, there is no public API to retrieve this surface.

Proposal: add an API to retrieve the SDL_Surface of an existing software SDL_Renderer.

Attached is a potential implementation of such a function.  The function itself is:

SDL_Surface * SDL_GetSoftwareRendererSurface(SDL_Renderer * renderer);

This function will return NULL for non-software renderers, or on error.  If the renderer is a software renderer, it'll return its SDL_Surface.
Comment 1 David Ludwig 2017-09-13 17:48:06 UTC
To note, the use case I am looking into here, involves:

1. an SDL_Renderer being created, with users, potentially, adjusting what type of renderer is used
2. if and when a software renderer is being used, have an app use custom routines to scale images, to the destination surface