Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added SDL_GetRenderTarget() API function

Also fixed a bug with setting logical size for a render target.
  • Loading branch information
slouken committed Oct 12, 2012
1 parent 32ee6c0 commit 03c04b07e8315d1867b33003b23f9afa87c97053
Showing with 20 additions and 1 deletion.
  1. +11 −0 include/SDL_render.h
  2. +9 −1 src/render/SDL_render.c
@@ -413,10 +413,21 @@ extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *rendere
* \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
*
* \return 0 on success, or -1 on error
*
* \sa SDL_GetRenderTarget()
*/
extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
SDL_Texture *texture);

/**
* \brief Get the current render target or NULL for the default render target.
*
* \return The current render target
*
* \sa SDL_SetRenderTarget()
*/
extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);

/**
* \brief Set device independent resolution for rendering
*
@@ -952,6 +952,12 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
return 0;
}

SDL_Texture *
SDL_GetRenderTarget(SDL_Renderer *renderer)
{
return renderer->target;
}

static int
UpdateLogicalSize(SDL_Renderer *renderer)
{
@@ -961,7 +967,9 @@ UpdateLogicalSize(SDL_Renderer *renderer)
float scale;
SDL_Rect viewport;

if (renderer->window) {
if (renderer->target) {
SDL_QueryTexture(renderer->target, NULL, NULL, &w, &h);
} else if (renderer->window) {
SDL_GetWindowSize(renderer->window, &w, &h);
} else {
/* FIXME */

0 comments on commit 03c04b0

Please sign in to comment.