added pref, "sdlrender", which can force a specific, SDL2 renderer (software can be faster in some cases, such as on VirtualBox hosts)

This commit is contained in:
David Ludwig 2017-09-09 16:48:30 +00:00
parent cbda5759bb
commit 1eb824a04e
3 changed files with 19 additions and 1 deletions

View File

@ -31,6 +31,7 @@
// Platform-specific preferences items // Platform-specific preferences items
prefs_desc platform_prefs_items[] = { prefs_desc platform_prefs_items[] = {
{"idlewait", TYPE_BOOLEAN, false, "sleep when idle"}, {"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
{"sdlrender", TYPE_STRING, false, "SDL_Renderer driver (\"auto\", \"software\" (may be faster), etc.)"},
{NULL, TYPE_END, false} // End of list {NULL, TYPE_END, false} // End of list
}; };

View File

@ -754,12 +754,26 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags
} }
if (!sdl_renderer) { if (!sdl_renderer) {
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_ACCELERATED); const char *render_driver = PrefsFindString("sdlrender");
if (render_driver) {
if (SDL_strcmp(render_driver, "auto") == 0) {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "");
} else {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, render_driver);
}
}
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
if (!sdl_renderer) { if (!sdl_renderer) {
shutdown_sdl_video(); shutdown_sdl_video();
return NULL; return NULL;
} }
sdl_renderer_thread_id = SDL_ThreadID(); sdl_renderer_thread_id = SDL_ThreadID();
SDL_RendererInfo info;
memset(&info, 0, sizeof(info));
SDL_GetRendererInfo(sdl_renderer, &info);
printf("Using SDL_Renderer driver: %s\n", (info.name ? info.name : "(null)"));
} }
SDL_assert(sdl_texture == NULL); SDL_assert(sdl_texture == NULL);

View File

@ -42,6 +42,9 @@ prefs_desc platform_prefs_items[] = {
{"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"}, {"ignoresegv", TYPE_BOOLEAN, false, "ignore illegal memory accesses"},
#endif #endif
{"idlewait", TYPE_BOOLEAN, false, "sleep when idle"}, {"idlewait", TYPE_BOOLEAN, false, "sleep when idle"},
#ifdef USE_SDL_VIDEO
{"sdlrender", TYPE_STRING, false, "SDL_Renderer driver (\"auto\", \"software\" (may be faster), etc.)"},
#endif
{NULL, TYPE_END, false, NULL} // End of list {NULL, TYPE_END, false, NULL} // End of list
}; };