changeset 5194:93052810ceb5

Allow SDL_HINT_FRAMEBUFFER_ACCELERATION to specify the renderer to use.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Feb 2011 10:11:27 -0800
parents 82a48f4d65f6
children ef5a61ea3202
files src/video/SDL_video.c
diffstat 1 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_video.c	Sat Feb 05 10:03:12 2011 -0800
+++ b/src/video/SDL_video.c	Sat Feb 05 10:11:27 2011 -0800
@@ -203,17 +203,31 @@
     if (!renderer) {
         SDL_RendererInfo info;
         int i;
+        const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
 
-        /* We need to make sure we don't get a software renderer */
-        for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
-            SDL_GetRenderDriverInfo(i, &info);
-            if (SDL_strcmp(info.name, "software") != 0) {
-                renderer = SDL_CreateRenderer(window, i, 0);
-                if (renderer) {
+        /* Check to see if there's a specific driver requested */
+        if (hint && *hint != '0' && *hint != '1' &&
+            SDL_strcasecmp(hint, "software") != 0) {
+            for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+                SDL_GetRenderDriverInfo(i, &info);
+                if (SDL_strcasecmp(info.name, hint) == 0) {
+                    renderer = SDL_CreateRenderer(window, i, 0);
                     break;
                 }
             }
         }
+
+        if (!renderer) {
+            for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+                SDL_GetRenderDriverInfo(i, &info);
+                if (SDL_strcmp(info.name, "software") != 0) {
+                    renderer = SDL_CreateRenderer(window, i, 0);
+                    if (renderer) {
+                        break;
+                    }
+                }
+            }
+        }
         if (!renderer) {
             return -1;
         }