added command line option to list available SDL render drivers
authorHolger Schemel <holger.schemel@virtion.de>
Fri, 20 Dec 2024 17:46:57 +0000 (18:46 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Fri, 20 Dec 2024 11:55:12 +0000 (12:55 +0100)
src/libgame/misc.c
src/libgame/misc.h
src/main.c

index 2bd443a22dd6e8ee985b0f9fdb7e2bea1274838b..26c7a0e1aa82fb4379380e5108d9afa966933e28 100644 (file)
@@ -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]);
index 26a5168fd6c3d9faa7391eb05dcbb7ee526d9cee..81d27d22c8f38490da6c7c14245ccc6ea77f3824 100644 (file)
@@ -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);
index ce5064916cf21d8e630929d4af67ba57dc4b09a2..41257e939ba1249ff36e7bb2e6901bb252fff525 100644 (file)
@@ -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();