From dd0917adca082762ceb25f77be3b863869ca4ce8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 20 Dec 2024 18:46:57 +0100 Subject: [PATCH] added command line option to list available SDL render drivers --- src/libgame/misc.c | 9 ++++++++- src/libgame/misc.h | 3 ++- src/main.c | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 2bd443a2..26c7a0e1 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1693,7 +1693,8 @@ boolean isURL(const char *s) void GetOptions(int argc, char *argv[], void (*print_usage_function)(void), - void (*print_version_function)(void)) + void (*print_version_function)(void), + void (*print_render_drivers_function)(void)) { char *base_path = getProgramMainDataPath(argv[0], BASE_PATH); char **argvplus = checked_calloc((argc + 1) * sizeof(char **)); @@ -1910,6 +1911,12 @@ void GetOptions(int argc, char *argv[], exit(0); } + else if (strncmp(option, "-list-render-drivers", option_len) == 0) + { + print_render_drivers_function(); + + exit(0); + } else if (strPrefix(option, "-D")) { options.special_flags = getStringCopy(&option[2]); diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 26a5168f..81d27d22 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -207,7 +207,8 @@ boolean isURL(const char *); void GetOptions(int, char **, void (*print_usage_function)(void), - void (*print_version_function)(void)); + void (*print_version_function)(void), + void (*print_render_drivers_function)(void)); void *checked_malloc(unsigned int); void *checked_calloc(unsigned int); diff --git a/src/main.c b/src/main.c index ce506491..41257e93 100644 --- a/src/main.c +++ b/src/main.c @@ -9576,6 +9576,20 @@ static void print_version(void) } } +static void print_render_drivers(void) +{ + int num_render_drivers = SDL_GetNumRenderDrivers(); + int i; + + for (i = 0; i < num_render_drivers; i++) + { + SDL_RendererInfo info; + + if (SDL_GetRenderDriverInfo(i, &info) == 0) + Print("- SDL render driver #%d: '%s'\n", i, info.name); + } +} + static void InitProgramConfig(char *command_filename) { char *program_title = PROGRAM_TITLE_STRING; @@ -9640,7 +9654,7 @@ int main(int argc, char *argv[]) InitExitFunction(CloseAllAndExit); InitPlatformDependentStuff(); - GetOptions(argc, argv, print_usage, print_version); + GetOptions(argc, argv, print_usage, print_version, print_render_drivers); OpenAll(); EventLoop(); -- 2.34.1