Added an environment variable to select which driver the software renderer will use.
authorSam Lantinga <slouken@libsdl.org>
Sun, 23 Jul 2006 00:48:12 +0000
changeset 1929 595ac54a8f9f
parent 1928 861bc36f0ab3
child 1930 9483df98e011
Added an environment variable to select which driver the software renderer will use.
src/video/SDL_renderer_sw.c
--- a/src/video/SDL_renderer_sw.c	Sun Jul 23 00:19:12 2006 +0000
+++ b/src/video/SDL_renderer_sw.c	Sun Jul 23 00:48:12 2006 +0000
@@ -159,6 +159,7 @@
     int bpp;
     Uint32 Rmask, Gmask, Bmask, Amask;
     Uint32 renderer_flags;
+    const char *desired_driver;
 
     if (!SDL_PixelFormatEnumToMasks
         (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
@@ -216,13 +217,19 @@
     if (flags & SDL_Renderer_PresentVSync) {
         renderer_flags |= SDL_Renderer_PresentVSync;
     }
+    desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER");
     for (i = 0; i < display->num_render_drivers; ++i) {
         SDL_RenderDriver *driver = &display->render_drivers[i];
-        if (driver->info.name != SW_RenderDriver.info.name) {
-            data->renderer = driver->CreateRenderer(window, renderer_flags);
-            if (data->renderer) {
-                break;
-            }
+        if (driver->info.name == SW_RenderDriver.info.name) {
+            continue;
+        }
+        if (desired_driver
+            && SDL_strcasecmp(desired_driver, driver->info.name) != 0) {
+            continue;
+        }
+        data->renderer = driver->CreateRenderer(window, renderer_flags);
+        if (data->renderer) {
+            break;
         }
     }
     if (i == display->num_render_drivers) {