Added a renderer flag to expose whether a renderer supports render to texture.
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Jan 2012 21:06:47 -0500
changeset 6237240f1bced46b
parent 6236 4a7abc1b6b0e
child 6241 5051407a46d3
Added a renderer flag to expose whether a renderer supports render to texture.
include/SDL_render.h
src/render/SDL_render.c
src/render/direct3d/SDL_render_d3d.c
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/include/SDL_render.h	Thu Jan 19 20:25:09 2012 -0500
     1.2 +++ b/include/SDL_render.h	Thu Jan 19 21:06:47 2012 -0500
     1.3 @@ -65,8 +65,10 @@
     1.4      SDL_RENDERER_SOFTWARE = 0x00000001,         /**< The renderer is a software fallback */ 
     1.5      SDL_RENDERER_ACCELERATED = 0x00000002,      /**< The renderer uses hardware 
     1.6                                                       acceleration */
     1.7 -    SDL_RENDERER_PRESENTVSYNC = 0x00000004      /**< Present is synchronized 
     1.8 +    SDL_RENDERER_PRESENTVSYNC = 0x00000004,     /**< Present is synchronized 
     1.9                                                       with the refresh rate */
    1.10 +    SDL_RENDERER_TARGETTEXTURE = 0x00000008     /**< The renderer supports
    1.11 +                                                     rendering to texture */
    1.12  } SDL_RendererFlags;
    1.13  
    1.14  /**
     2.1 --- a/src/render/SDL_render.c	Thu Jan 19 20:25:09 2012 -0500
     2.2 +++ b/src/render/SDL_render.c	Thu Jan 19 21:06:47 2012 -0500
     2.3 @@ -1153,10 +1153,10 @@
     2.4  SDL_bool
     2.5  SDL_RenderTargetSupported(SDL_Renderer *renderer)
     2.6  {
     2.7 -    if ((!renderer) || (!renderer->SetTargetTexture)) {
     2.8 +    if (!renderer || !renderer->SetTargetTexture) {
     2.9          return SDL_FALSE;
    2.10      }
    2.11 -    return SDL_TRUE;
    2.12 +    return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
    2.13  }
    2.14  
    2.15  int
     3.1 --- a/src/render/direct3d/SDL_render_d3d.c	Thu Jan 19 20:25:09 2012 -0500
     3.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Thu Jan 19 21:06:47 2012 -0500
     3.3 @@ -122,7 +122,7 @@
     3.4      D3D_CreateRenderer,
     3.5      {
     3.6       "direct3d",
     3.7 -     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     3.8 +     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
     3.9       1,
    3.10       {SDL_PIXELFORMAT_ARGB8888},
    3.11       0,
    3.12 @@ -406,7 +406,7 @@
    3.13      renderer->info = D3D_RenderDriver.info;
    3.14      renderer->driverdata = data;
    3.15  
    3.16 -    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    3.17 +    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
    3.18  
    3.19      SDL_VERSION(&windowinfo.version);
    3.20      SDL_GetWindowWMInfo(window, &windowinfo);
     4.1 --- a/src/render/opengl/SDL_render_gl.c	Thu Jan 19 20:25:09 2012 -0500
     4.2 +++ b/src/render/opengl/SDL_render_gl.c	Thu Jan 19 21:06:47 2012 -0500
     4.3 @@ -76,7 +76,7 @@
     4.4      GL_CreateRenderer,
     4.5      {
     4.6       "opengl",
     4.7 -     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     4.8 +     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
     4.9       1,
    4.10       {SDL_PIXELFORMAT_ARGB8888},
    4.11       0,
    4.12 @@ -321,7 +321,7 @@
    4.13      renderer->DestroyTexture = GL_DestroyTexture;
    4.14      renderer->DestroyRenderer = GL_DestroyRenderer;
    4.15      renderer->info = GL_RenderDriver.info;
    4.16 -    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    4.17 +    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
    4.18      renderer->driverdata = data;
    4.19      renderer->window = window;
    4.20  
     5.1 --- a/src/render/opengles/SDL_render_gles.c	Thu Jan 19 20:25:09 2012 -0500
     5.2 +++ b/src/render/opengles/SDL_render_gles.c	Thu Jan 19 21:06:47 2012 -0500
     5.3 @@ -89,7 +89,7 @@
     5.4      GLES_CreateRenderer,
     5.5      {
     5.6       "opengles",
     5.7 -     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     5.8 +     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
     5.9       1,
    5.10       {SDL_PIXELFORMAT_ABGR8888},
    5.11       0,
    5.12 @@ -372,7 +372,7 @@
    5.13      renderer->DestroyTexture = GLES_DestroyTexture;
    5.14      renderer->DestroyRenderer = GLES_DestroyRenderer;
    5.15      renderer->info = GLES_RenderDriver.info;
    5.16 -    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    5.17 +    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
    5.18      renderer->driverdata = data;
    5.19      renderer->window = window;
    5.20      renderer->SetTargetTexture = GLES_SetTargetTexture;
     6.1 --- a/src/render/opengles2/SDL_render_gles2.c	Thu Jan 19 20:25:09 2012 -0500
     6.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Thu Jan 19 21:06:47 2012 -0500
     6.3 @@ -40,7 +40,7 @@
     6.4      GLES2_CreateRenderer,
     6.5      {
     6.6          "opengles2",
     6.7 -        (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     6.8 +        (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
     6.9          4,
    6.10          {SDL_PIXELFORMAT_ABGR8888,
    6.11          SDL_PIXELFORMAT_ARGB8888,
    6.12 @@ -1447,7 +1447,7 @@
    6.13          return NULL;
    6.14      }
    6.15      renderer->info = GLES2_RenderDriver.info;
    6.16 -    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    6.17 +    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
    6.18      renderer->driverdata = rdata;
    6.19      renderer->window = window;
    6.20