changeset 88:8b34eab13549

Add -p -option for pausing at specific cycle frame.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 18 Oct 2020 14:15:07 +0300
parents 036e9d737ba9
children ff739727dfec
files gldragon.cpp
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gldragon.cpp	Mon Jul 06 18:49:21 2020 +0300
+++ b/gldragon.cpp	Sun Oct 18 14:15:07 2020 +0300
@@ -103,7 +103,8 @@
 
     int optWidth = SET_DEF_WIDTH,
         optHeight = SET_DEF_HEIGHT,
-        optVSyncMode = 1;
+        optVSyncMode = 1,
+        optPauseFrame = -1;
 
     std::string optInputFilename = "dragon.scene", basePath;
     DMGLSimpleRenderer renderer;
@@ -140,6 +141,7 @@
                 case 's':
                 case 'm':
                 case 'v':
+                case 'p':
                     {
                         std::string marg;
                         if (opt[1] == 0)
@@ -172,7 +174,13 @@
                                 }
                                 break;
 
-                            case 'v': optVSyncMode = std::stoi(marg, 0, 0); break;
+                            case 'v':
+                                optVSyncMode = std::stoi(marg, 0, 0);
+                                break;
+
+                            case 'p':
+                                optPauseFrame = std::stoi(marg, 0, 0);
+                                break;
                         }
                     }
                     break;
@@ -215,13 +223,15 @@
             "               Using vsync (2) will result in FPS being approximately\n"
             "               whatever your monitor refresh rate is. The default\n"
             "               value is 1 (no vsync).\n"
+            " -p<frameN>    Pause at cycle frame (max %d).\n"
             "\n"
             "Keyboard controls during runtime:\n"
             " p / space    Toggle pause (does not/should not affect fps measurement)\n"
             " q / esc      Quit\n"
             "\n",
             argv[0],
-            SET_DEF_WIDTH, SET_DEF_HEIGHT
+            SET_DEF_WIDTH, SET_DEF_HEIGHT,
+            SET_FRAMES
             );
 
         goto exit;
@@ -326,6 +336,9 @@
         // Draw the current frame
         renderer.swapWindow();
 
+        if (optPauseFrame >= 0 && cycleFrames == optPauseFrame)
+            pauseFlag = true;
+
         // Rotate for 2 degrees
         if (!pauseFlag)
             renderer.animate(scene, totalTime);