Skip to content

Commit 09d4064

Browse files
committed
GPU Display: Fix creating unrequested screenshot, when enabling saving of an animation without running an animation
1 parent 7202794 commit 09d4064

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎GPU/GPUTracking/display/GPUDisplay.cxx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,9 @@ void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool re
638638
mCfgC.mAnimateScreenshot = 0;
639639
}
640640
}
641-
bool doScreenshot = (mCfgC.mRequestScreenshot || mCfgC.mAnimateScreenshot) && animateTime < 0;
641+
const bool animateScreenshot = mCfgC.mAnimateScreenshot && mAnimate; // Copy, the animation resets mAnimateScreenshot in its last frame
642+
const bool screenshotFrame = mCfgC.mRequestScreenshot || animateScreenshot; // Also for the mix pass (animateTime >= 0), which must use the same render size
643+
const bool doScreenshot = screenshotFrame && animateTime < 0;
642644

643645
updateOptions();
644646
if (animateTime < 0 && (mUpdateEventData || mCfgC.mResetScene.load() || mUpdateVertexLists) && mIOPtrs) {
@@ -680,7 +682,7 @@ void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool re
680682
const float zFar = ((mParam->par.continuousTracking ? (mMaxClusterZ * GL_SCALE_FACTOR) : 8.f) + 50.f) * 2.f;
681683
const float aspect = mBackend->mRenderHeight ? (float)mBackend->mRenderWidth / (float)mBackend->mRenderHeight : 1.f; // No render size with the None backend
682684
const hmm_mat4 proj = HMM_Perspective(mCfgR.fov, aspect, 0.1f, zFar);
683-
if (!mBackend->prepareDraw(proj, nextViewMatrix, doScreenshot || mCfgC.mRequestScreenshot, renderToMixBuffer, mixSlaveImage)) {
685+
if (!mBackend->prepareDraw(proj, nextViewMatrix, screenshotFrame, renderToMixBuffer, mixSlaveImage)) {
684686
return; // No image available (e.g. hidden window), retry with the next frame
685687
}
686688
mBackend->pointSizeFactor(1);
@@ -726,15 +728,15 @@ void GPUDisplay::DrawGLScene_internal(bool suspended, float animateTime, bool re
726728
}
727729
}
728730

729-
mBackend->finishFrame(mCfgC.mRequestScreenshot, renderToMixBuffer, mixSlaveImage);
731+
mBackend->finishFrame(doScreenshot, renderToMixBuffer, mixSlaveImage);
730732
if (doScreenshot) {
731733
mCfgC.mRequestScreenshot = false;
732734
std::vector<char> pixels = mBackend->getPixels();
733735
char tmpFileName[48];
734-
if (mCfgC.mAnimateScreenshot) {
736+
if (animateScreenshot) {
735737
snprintf(tmpFileName, 48, "mAnimation%d_%05d.bmp", mAnimationExport, mAnimationFrame);
736738
}
737-
DoScreenshot(mCfgC.mAnimateScreenshot ? tmpFileName : mScreenshotFile.c_str(), pixels);
739+
DoScreenshot(animateScreenshot ? tmpFileName : mScreenshotFile.c_str(), pixels);
738740
}
739741
}
740742

0 commit comments

Comments
 (0)