Commit 9ec38356 authored by Sam Lantinga's avatar Sam Lantinga

Use a valid window when creating the default renderer

parent 60c77bdc
...@@ -1046,11 +1046,19 @@ SDL_GetCurrentRenderer(SDL_bool create) ...@@ -1046,11 +1046,19 @@ SDL_GetCurrentRenderer(SDL_bool create)
return NULL; return NULL;
} }
if (!SDL_CurrentRenderer) { if (!SDL_CurrentRenderer) {
SDL_Window *window = NULL;
if (!create) { if (!create) {
SDL_SetError("Use SDL_CreateRenderer() to create a renderer"); SDL_SetError("Use SDL_CreateRenderer() to create a renderer");
return NULL; 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; return NULL;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment