Added SDL_GetRenderTarget() API function
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Oct 2012 02:20:10 -0700
changeset 657877d70ec131bc
parent 6577 d38491853506
child 6579 2390a7403b77
Added SDL_GetRenderTarget() API function
Also fixed a bug with setting logical size for a render target.
include/SDL_render.h
src/render/SDL_render.c
     1.1 --- a/include/SDL_render.h	Thu Oct 11 15:05:00 2012 -0700
     1.2 +++ b/include/SDL_render.h	Fri Oct 12 02:20:10 2012 -0700
     1.3 @@ -413,11 +413,22 @@
     1.4   * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
     1.5   *
     1.6   * \return 0 on success, or -1 on error
     1.7 + *
     1.8 + *  \sa SDL_GetRenderTarget()
     1.9   */
    1.10  extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
    1.11                                                  SDL_Texture *texture);
    1.12  
    1.13  /**
    1.14 + * \brief Get the current render target or NULL for the default render target.
    1.15 + *
    1.16 + * \return The current render target
    1.17 + *
    1.18 + *  \sa SDL_SetRenderTarget()
    1.19 + */
    1.20 +extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
    1.21 +
    1.22 +/**
    1.23   *  \brief Set device independent resolution for rendering
    1.24   *
    1.25   *  \param w      The width of the logical resolution
     2.1 --- a/src/render/SDL_render.c	Thu Oct 11 15:05:00 2012 -0700
     2.2 +++ b/src/render/SDL_render.c	Fri Oct 12 02:20:10 2012 -0700
     2.3 @@ -952,6 +952,12 @@
     2.4      return 0;
     2.5  }
     2.6  
     2.7 +SDL_Texture *
     2.8 +SDL_GetRenderTarget(SDL_Renderer *renderer)
     2.9 +{
    2.10 +    return renderer->target;
    2.11 +}
    2.12 +
    2.13  static int
    2.14  UpdateLogicalSize(SDL_Renderer *renderer)
    2.15  {
    2.16 @@ -961,7 +967,9 @@
    2.17      float scale;
    2.18      SDL_Rect viewport;
    2.19  
    2.20 -    if (renderer->window) {
    2.21 +    if (renderer->target) {
    2.22 +        SDL_QueryTexture(renderer->target, NULL, NULL, &w, &h);
    2.23 +    } else if (renderer->window) {
    2.24          SDL_GetWindowSize(renderer->window, &w, &h);
    2.25      } else {
    2.26          /* FIXME */