diff --git a/test/controllermap.c b/test/controllermap.c index f81528ea2..144c60344 100644 --- a/test/controllermap.c +++ b/test/controllermap.c @@ -165,6 +165,7 @@ static Uint32 s_unPendingAdvanceTime; static SDL_bool s_bBindingComplete; static SDL_Window *window; +static SDL_Renderer *screen; static SDL_bool done = SDL_FALSE; SDL_Texture * @@ -375,7 +376,6 @@ BMergeAxisBindings(int iIndex) static void WatchJoystick(SDL_Joystick * joystick) { - SDL_Renderer *screen = NULL; SDL_Texture *background_front, *background_back, *button, *axis, *marker; const char *name = NULL; SDL_Event event; @@ -384,12 +384,6 @@ WatchJoystick(SDL_Joystick * joystick) Uint32 alpha_ticks = 0; SDL_JoystickID nJoystickID; - screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); - return; - } - background_front = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); background_back = LoadTexture(screen, "controllermap_back.bmp", SDL_FALSE); button = LoadTexture(screen, "button.bmp", SDL_TRUE); @@ -746,6 +740,12 @@ main(int argc, char *argv[]) return 2; } + screen = SDL_CreateRenderer(window, -1, 0); + if (screen == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); + return 2; + } + while (!done && SDL_NumJoysticks() == 0) { SDL_Event event; @@ -763,6 +763,7 @@ main(int argc, char *argv[]) break; } } + SDL_RenderPresent(screen); } /* Print information about the joysticks */