Use a valid window when creating the default renderer
authorSam Lantinga <slouken@libsdl.org>
Wed, 12 Jan 2011 13:38:10 -0800
changeset 497785969cc5098c
parent 4976 3811132c584f
child 4978 4a7f284a82b2
Use a valid window when creating the default renderer
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Wed Jan 12 12:40:11 2011 -0800
     1.2 +++ b/src/video/SDL_video.c	Wed Jan 12 13:38:10 2011 -0800
     1.3 @@ -1046,11 +1046,19 @@
     1.4          return NULL;
     1.5      }
     1.6      if (!SDL_CurrentRenderer) {
     1.7 +        SDL_Window *window = NULL;
     1.8 +
     1.9          if (!create) {
    1.10              SDL_SetError("Use SDL_CreateRenderer() to create a renderer");
    1.11              return NULL;
    1.12          }
    1.13 -        if (SDL_CreateRenderer(0, -1, 0) < 0) {
    1.14 +
    1.15 +        /* Get the first window on the first display */
    1.16 +        if (_this->num_displays > 0) {
    1.17 +            window = _this->displays[0].windows;
    1.18 +        }
    1.19 +
    1.20 +        if (SDL_CreateRenderer(window, -1, 0) < 0) {
    1.21              return NULL;
    1.22          }
    1.23      }