comparison 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
comparison
equal deleted inserted replaced
5194:93052810ceb5 5195:ef5a61ea3202
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 /* The SDL 2D rendering system */ 24 /* The SDL 2D rendering system */
25 25
26 #include "SDL_hints.h"
26 #include "SDL_render.h" 27 #include "SDL_render.h"
27 #include "SDL_sysrender.h" 28 #include "SDL_sysrender.h"
28 #include "../video/SDL_pixels_c.h" 29 #include "../video/SDL_pixels_c.h"
29 #include "software/SDL_renderer_sw_c.h" 30 #include "software/SDL_renderer_sw_c.h"
30 31
92 SDL_Renderer * 93 SDL_Renderer *
93 SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) 94 SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
94 { 95 {
95 SDL_Renderer *renderer = NULL; 96 SDL_Renderer *renderer = NULL;
96 int n = SDL_GetNumRenderDrivers(); 97 int n = SDL_GetNumRenderDrivers();
98 const char *hint;
99
100 hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
101 if (hint) {
102 if (*hint == '0') {
103 flags &= ~SDL_RENDERER_PRESENTVSYNC;
104 } else {
105 flags |= SDL_RENDERER_PRESENTVSYNC;
106 }
107 }
97 108
98 if (index < 0) { 109 if (index < 0) {
99 char *override = SDL_getenv("SDL_VIDEO_RENDERER"); 110 hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
100 111 if (hint) {
101 if (override) {
102 for (index = 0; index < n; ++index) { 112 for (index = 0; index < n; ++index) {
103 const SDL_RenderDriver *driver = render_drivers[index]; 113 const SDL_RenderDriver *driver = render_drivers[index];
104 114
105 if (SDL_strcasecmp(override, driver->info.name) == 0) { 115 if (SDL_strcasecmp(hint, driver->info.name) == 0) {
106 /* Create a new renderer instance */ 116 /* Create a new renderer instance */
107 renderer = driver->CreateRenderer(window, flags); 117 renderer = driver->CreateRenderer(window, flags);
108 break; 118 break;
109 } 119 }
110 } 120 }
111 } else { 121 }
122
123 if (!renderer) {
112 for (index = 0; index < n; ++index) { 124 for (index = 0; index < n; ++index) {
113 const SDL_RenderDriver *driver = render_drivers[index]; 125 const SDL_RenderDriver *driver = render_drivers[index];
114 126
115 if ((driver->info.flags & flags) == flags) { 127 if ((driver->info.flags & flags) == flags) {
116 /* Create a new renderer instance */ 128 /* Create a new renderer instance */