Use a valid window when creating the default renderer
authorSam Lantinga <slouken@libsdl.org>
Wed, 12 Jan 2011 13:38:10 -0800
changeset 4977 85969cc5098c
parent 4976 3811132c584f
child 4978 4a7f284a82b2
Use a valid window when creating the default renderer
src/video/SDL_video.c
--- a/src/video/SDL_video.c	Wed Jan 12 12:40:11 2011 -0800
+++ b/src/video/SDL_video.c	Wed Jan 12 13:38:10 2011 -0800
@@ -1046,11 +1046,19 @@
         return NULL;
     }
     if (!SDL_CurrentRenderer) {
+        SDL_Window *window = NULL;
+
         if (!create) {
             SDL_SetError("Use SDL_CreateRenderer() to create a renderer");
             return NULL;
         }
-        if (SDL_CreateRenderer(0, -1, 0) < 0) {
+
+        /* Get the first window on the first display */
+        if (_this->num_displays > 0) {
+            window = _this->displays[0].windows;
+        }
+
+        if (SDL_CreateRenderer(window, -1, 0) < 0) {
             return NULL;
         }
     }