# HG changeset patch # User Matti Hamalainen # Date 1645795800 -7200 # Node ID a3486ce561483b933ac2ffa4b56b695301cc5a6a # Parent 8059aad101d19d1dd2ba34ac5e525bed1790789e Add option '-q' to quit execution at frame N. diff -r 8059aad101d1 -r a3486ce56148 gldragon.cpp --- 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 Start and pause at cycle frame (%d .. %d).\n" + " -q 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