mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 18:07:40 +00:00
render: SDL_RenderPresent now behaves when a render target is currently set.
It'll temporarily unbind it, draw letterboxing if necessary, present, and then rebind the previous render target.
This commit is contained in:
parent
7a6a0becb8
commit
4c48ff51f8
2 changed files with 13 additions and 7 deletions
|
@ -2061,10 +2061,12 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *ren
|
||||||
* pixel.
|
* pixel.
|
||||||
*
|
*
|
||||||
* Please note, that in case of rendering to a texture - there is **no need**
|
* Please note, that in case of rendering to a texture - there is **no need**
|
||||||
* to call `SDL_RenderPresent` after drawing needed objects to a texture, you
|
* to call `SDL_RenderPresent` after drawing needed objects to a texture, and
|
||||||
* are only required to change back the rendering target to default via
|
* should not be done; you are only required to change back the rendering
|
||||||
* `SDL_SetRenderTarget(renderer, NULL)` afterwards, as textures by themselves
|
* target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
|
||||||
* do not have a concept of backbuffers.
|
* textures by themselves do not have a concept of backbuffers. Calling
|
||||||
|
* SDL_RenderPresent while rendering to a texture will still update the
|
||||||
|
* screen with any current drawing that has been done _to the window itself_.
|
||||||
*
|
*
|
||||||
* \param renderer the rendering context.
|
* \param renderer the rendering context.
|
||||||
* \returns true on success or false on failure; call SDL_GetError() for more
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
|
|
@ -4949,9 +4949,9 @@ bool SDL_RenderPresent(SDL_Renderer *renderer)
|
||||||
|
|
||||||
CHECK_RENDERER_MAGIC(renderer, false);
|
CHECK_RENDERER_MAGIC(renderer, false);
|
||||||
|
|
||||||
// !!! FIXME: fail if using a render target? Or just implicitly set the render target to NULL now?
|
SDL_Texture *target = renderer->target;
|
||||||
if (renderer->view != &renderer->main_view) {
|
if (target) {
|
||||||
return SDL_SetError("Cannot present a render target");
|
SDL_SetRenderTarget(renderer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RenderLogicalPresentation(renderer);
|
SDL_RenderLogicalPresentation(renderer);
|
||||||
|
@ -4972,6 +4972,10 @@ bool SDL_RenderPresent(SDL_Renderer *renderer)
|
||||||
presented = false;
|
presented = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target) {
|
||||||
|
SDL_SetRenderTarget(renderer, target);
|
||||||
|
}
|
||||||
|
|
||||||
if (renderer->simulate_vsync ||
|
if (renderer->simulate_vsync ||
|
||||||
(!presented && renderer->wanted_vsync)) {
|
(!presented && renderer->wanted_vsync)) {
|
||||||
SDL_SimulateRenderVSync(renderer);
|
SDL_SimulateRenderVSync(renderer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue