changeset 7:95dd5417e7de

Add simple help.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 27 Oct 2019 22:20:17 +0200
parents 4d6fec8f0c64
children 628c42e94149
files glxdragon.cpp
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/glxdragon.cpp	Sun Oct 27 22:09:38 2019 +0200
+++ b/glxdragon.cpp	Sun Oct 27 22:20:17 2019 +0200
@@ -294,15 +294,31 @@
     struct Mesh dragonMesh;
     std::string dragonVS, dragonFS;
     std::clock_t startTime;
-    bool exitFlag = false;
+    bool exitFlag = false, opt_showhelp = false;
     int steps = 0;
 
     // Check commandline argument for enabling shaders
-    if (argc > 1 &&
-        (strstr(argv[1], "glsl") != NULL ||
-        strstr(argv[1], "sha") != NULL))
-        opt_shaders = true;
 
+    for (int narg = 1; narg < argc; narg++)
+    {
+        char *arg = argv[narg];
+        if (strstr(arg, "help") != NULL ||
+            strstr(arg, "?") != NULL)
+            opt_showhelp = true;
+        else
+        if (strstr(arg, "glsl") != NULL ||
+            strstr(arg, "sha") != NULL)
+            opt_shaders = true;
+    }
+
+    if (opt_showhelp)
+    {
+        printf(
+            "Usage: %s [glsl]\n"
+            "glsl argument will turn on GLSL shader mode instead of basic OpenGL lighting.\n"
+            , argv[0]);
+        goto exit;
+    }
 
     if (!dmLoadMesh("dragon.mesh", dragonMesh, 100139, 200198))
         goto exit;