Allow SDL_HINT_FRAMEBUFFER_ACCELERATION to specify the renderer to use.
authorSam Lantinga <slouken@libsdl.org>
Sat, 05 Feb 2011 10:11:27 -0800
changeset 5191 93052810ceb5
parent 5190 82a48f4d65f6
child 5192 ef5a61ea3202
Allow SDL_HINT_FRAMEBUFFER_ACCELERATION to specify the renderer to use.
src/video/SDL_video.c
--- 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;
         }