diff src/render/SDL_render.c @ 5195:ef5a61ea3202

Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Feb 2011 10:35:36 -0800
parents 4d098d286794
children bb45ecd958d8
line wrap: on
line diff
--- a/src/render/SDL_render.c	Sat Feb 05 10:11:27 2011 -0800
+++ b/src/render/SDL_render.c	Sat Feb 05 10:35:36 2011 -0800
@@ -23,6 +23,7 @@
 
 /* The SDL 2D rendering system */
 
+#include "SDL_hints.h"
 #include "SDL_render.h"
 #include "SDL_sysrender.h"
 #include "../video/SDL_pixels_c.h"
@@ -94,21 +95,32 @@
 {
     SDL_Renderer *renderer = NULL;
     int n = SDL_GetNumRenderDrivers();
+    const char *hint;
+
+    hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
+    if (hint) {
+        if (*hint == '0') {
+            flags &= ~SDL_RENDERER_PRESENTVSYNC;
+        } else {
+            flags |= SDL_RENDERER_PRESENTVSYNC;
+        }
+    }
 
     if (index < 0) {
-        char *override = SDL_getenv("SDL_VIDEO_RENDERER");
-
-        if (override) {
+        hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
+        if (hint) {
             for (index = 0; index < n; ++index) {
                 const SDL_RenderDriver *driver = render_drivers[index];
 
-                if (SDL_strcasecmp(override, driver->info.name) == 0) {
+                if (SDL_strcasecmp(hint, driver->info.name) == 0) {
                     /* Create a new renderer instance */
                     renderer = driver->CreateRenderer(window, flags);
                     break;
                 }
             }
-        } else {
+        }
+
+        if (!renderer) {
             for (index = 0; index < n; ++index) {
                 const SDL_RenderDriver *driver = render_drivers[index];