src/video/SDL_video.c
changeset 3488 3d2f42580488
parent 3486 c87dbbde2bc2
child 3489 e1bd98b56e94
     1.1 --- a/src/video/SDL_video.c	Tue Nov 24 08:12:32 2009 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Nov 24 16:43:18 2009 +0000
     1.3 @@ -1490,31 +1490,35 @@
     1.4      SDL_DestroyRenderer(windowID);
     1.5  
     1.6      if (index < 0) {
     1.7 -        const char *override = SDL_getenv("SDL_VIDEO_RENDERER");
     1.8 +        char *override = SDL_getenv("SDL_VIDEO_RENDERER");
     1.9 +        int n = SDL_GetNumRenderDrivers();
    1.10 +
    1.11 +        if (!override && (window->flags & SDL_WINDOW_OPENGL)) {
    1.12 +            override = "opengl";
    1.13 +        }
    1.14          if (override) {
    1.15 -            int i, n = SDL_GetNumRenderDrivers();
    1.16 -            for (i = 0; i < n; ++i) {
    1.17 +            for (index = 0; index < n; ++index) {
    1.18                  SDL_RenderDriver *driver =
    1.19 -                    &SDL_CurrentDisplay.render_drivers[i];
    1.20 +                    &SDL_CurrentDisplay.render_drivers[index];
    1.21 +
    1.22                  if (SDL_strcasecmp(override, driver->info.name) == 0) {
    1.23 -                    index = i;
    1.24 +                    /* Create a new renderer instance */
    1.25 +                    window->renderer = driver->CreateRenderer(window, flags);
    1.26                      break;
    1.27                  }
    1.28              }
    1.29 -        }
    1.30 -    }
    1.31 -    if (index < 0) {
    1.32 -        int n = SDL_GetNumRenderDrivers();
    1.33 -        for (index = 0; index < n; ++index) {
    1.34 -            SDL_RenderDriver *driver =
    1.35 -                &SDL_CurrentDisplay.render_drivers[index];
    1.36 -
    1.37 -            if ((driver->info.flags & flags) == flags) {
    1.38 -                /* Create a new renderer instance */
    1.39 -                window->renderer = SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window, flags);
    1.40 -                if (window->renderer) {
    1.41 -                    /* Yay, we got one! */
    1.42 -                    break;
    1.43 +        } else {
    1.44 +            for (index = 0; index < n; ++index) {
    1.45 +                SDL_RenderDriver *driver =
    1.46 +                    &SDL_CurrentDisplay.render_drivers[index];
    1.47 +
    1.48 +                if ((driver->info.flags & flags) == flags) {
    1.49 +                    /* Create a new renderer instance */
    1.50 +                    window->renderer = driver->CreateRenderer(window, flags);
    1.51 +                    if (window->renderer) {
    1.52 +                        /* Yay, we got one! */
    1.53 +                        break;
    1.54 +                    }
    1.55                  }
    1.56              }
    1.57          }
    1.58 @@ -1528,7 +1532,6 @@
    1.59                           SDL_GetNumRenderDrivers() - 1);
    1.60              return -1;
    1.61          }
    1.62 -
    1.63          /* Create a new renderer instance */
    1.64          window->renderer = SDL_CurrentDisplay.render_drivers[index].CreateRenderer(window, flags);
    1.65      }