changeset 101:a3486ce56148

Add option '-q<n>' to quit execution at frame N.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 25 Feb 2022 15:30:00 +0200
parents 8059aad101d1
children 2b22a89dd811
files gldragon.cpp
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gldragon.cpp	Fri Feb 25 15:29:13 2022 +0200
+++ b/gldragon.cpp	Fri Feb 25 15:30:00 2022 +0200
@@ -108,7 +108,8 @@
     int optWidth = SET_DEF_WIDTH,
         optHeight = SET_DEF_HEIGHT,
         optVSyncMode = 1,
-        optPauseFrame = -1;
+        optPauseFrame = -1,
+        optQuitFrame = -1;
 
     std::string optInputFilename = "dragon.scene", basePath;
     DMGLSimpleRenderer renderer;
@@ -148,6 +149,7 @@
                 case 'm':
                 case 'v':
                 case 'p':
+                case 'q':
                     {
                         std::string marg;
                         if (opt[1] == 0)
@@ -187,6 +189,10 @@
                             case 'p':
                                 optPauseFrame = std::stoi(marg, 0, 0);
                                 break;
+
+                            case 'q':
+                                optQuitFrame = std::stoi(marg, 0, 0);
+                                break;
                         }
                     }
                     break;
@@ -230,6 +236,7 @@
             "               whatever your monitor refresh rate is. The default\n"
             "               value is 1 (no vsync).\n"
             " -p<frameN>    Start and pause at cycle frame (%d .. %d).\n"
+            " -q<frameN>    Quit at frame (%d .. %d).\n"
             "\n"
             "Keyboard controls during runtime:\n"
             " p / space    Toggle pause (does not/should not affect fps measurement)\n"
@@ -238,6 +245,7 @@
             "\n",
             argv[0],
             SET_DEF_WIDTH, SET_DEF_HEIGHT,
+            0, SET_FRAMES - 1,
             0, SET_FRAMES - 1
             );
 
@@ -251,6 +259,12 @@
         goto exit;
     }
 
+    if (optQuitFrame >= 0 && optPauseFrame >= 0)
+    {
+        dmError("Only one of 'quit frame' (-q) and 'pause frame' (-p) options can be set.\n");
+        goto exit;
+    }
+
     // Load the scene
     if (!scene.loadInfo(optInputFilename))
         goto exit;
@@ -369,6 +383,12 @@
 
         frameDelta = frameEnd - frameStart;
 
+        // Check for quit frame
+        if (optQuitFrame >= 0 && cycleFrames == optQuitFrame)
+        {
+            exitFlag = true;
+        }
+        else
         if (manualFlag)
         {
             // Handle manual control mode