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 6237 240f1bced46b
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
--- a/include/SDL_render.h	Thu Jan 19 20:25:09 2012 -0500
+++ b/include/SDL_render.h	Thu Jan 19 21:06:47 2012 -0500
@@ -65,8 +65,10 @@
     SDL_RENDERER_SOFTWARE = 0x00000001,         /**< The renderer is a software fallback */ 
     SDL_RENDERER_ACCELERATED = 0x00000002,      /**< The renderer uses hardware 
                                                      acceleration */
-    SDL_RENDERER_PRESENTVSYNC = 0x00000004      /**< Present is synchronized 
+    SDL_RENDERER_PRESENTVSYNC = 0x00000004,     /**< Present is synchronized 
                                                      with the refresh rate */
+    SDL_RENDERER_TARGETTEXTURE = 0x00000008     /**< The renderer supports
+                                                     rendering to texture */
 } SDL_RendererFlags;
 
 /**
--- a/src/render/SDL_render.c	Thu Jan 19 20:25:09 2012 -0500
+++ b/src/render/SDL_render.c	Thu Jan 19 21:06:47 2012 -0500
@@ -1153,10 +1153,10 @@
 SDL_bool
 SDL_RenderTargetSupported(SDL_Renderer *renderer)
 {
-    if ((!renderer) || (!renderer->SetTargetTexture)) {
+    if (!renderer || !renderer->SetTargetTexture) {
         return SDL_FALSE;
     }
-    return SDL_TRUE;
+    return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
 }
 
 int
--- a/src/render/direct3d/SDL_render_d3d.c	Thu Jan 19 20:25:09 2012 -0500
+++ b/src/render/direct3d/SDL_render_d3d.c	Thu Jan 19 21:06:47 2012 -0500
@@ -122,7 +122,7 @@
     D3D_CreateRenderer,
     {
      "direct3d",
-     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
      1,
      {SDL_PIXELFORMAT_ARGB8888},
      0,
@@ -406,7 +406,7 @@
     renderer->info = D3D_RenderDriver.info;
     renderer->driverdata = data;
 
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
 
     SDL_VERSION(&windowinfo.version);
     SDL_GetWindowWMInfo(window, &windowinfo);
--- a/src/render/opengl/SDL_render_gl.c	Thu Jan 19 20:25:09 2012 -0500
+++ b/src/render/opengl/SDL_render_gl.c	Thu Jan 19 21:06:47 2012 -0500
@@ -76,7 +76,7 @@
     GL_CreateRenderer,
     {
      "opengl",
-     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
      1,
      {SDL_PIXELFORMAT_ARGB8888},
      0,
@@ -321,7 +321,7 @@
     renderer->DestroyTexture = GL_DestroyTexture;
     renderer->DestroyRenderer = GL_DestroyRenderer;
     renderer->info = GL_RenderDriver.info;
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
     renderer->driverdata = data;
     renderer->window = window;
 
--- a/src/render/opengles/SDL_render_gles.c	Thu Jan 19 20:25:09 2012 -0500
+++ b/src/render/opengles/SDL_render_gles.c	Thu Jan 19 21:06:47 2012 -0500
@@ -89,7 +89,7 @@
     GLES_CreateRenderer,
     {
      "opengles",
-     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
      1,
      {SDL_PIXELFORMAT_ABGR8888},
      0,
@@ -372,7 +372,7 @@
     renderer->DestroyTexture = GLES_DestroyTexture;
     renderer->DestroyRenderer = GLES_DestroyRenderer;
     renderer->info = GLES_RenderDriver.info;
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
     renderer->driverdata = data;
     renderer->window = window;
     renderer->SetTargetTexture = GLES_SetTargetTexture;
--- a/src/render/opengles2/SDL_render_gles2.c	Thu Jan 19 20:25:09 2012 -0500
+++ b/src/render/opengles2/SDL_render_gles2.c	Thu Jan 19 21:06:47 2012 -0500
@@ -40,7 +40,7 @@
     GLES2_CreateRenderer,
     {
         "opengles2",
-        (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
+        (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
         4,
         {SDL_PIXELFORMAT_ABGR8888,
         SDL_PIXELFORMAT_ARGB8888,
@@ -1447,7 +1447,7 @@
         return NULL;
     }
     renderer->info = GLES2_RenderDriver.info;
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
     renderer->driverdata = rdata;
     renderer->window = window;