From 823218bb611adbbe07a1a4727a6f381cc7b896b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 14 Nov 2017 18:23:12 +0100 Subject: [PATCH] freeze screen during screenshot taking --- apps/openmw/mwrender/renderingmanager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index b2d97e81d..a1b508f01 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -890,6 +890,13 @@ namespace MWRender mRootNode->addChild(rttCamera); + rttCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + GLbitfield maskBackup = mViewer->getCamera()->getClearMask(); + double clearDepthBackup = mViewer->getCamera()->getClearDepth(); + mViewer->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT); + mViewer->getCamera()->setClearDepth(0); + // The draw needs to complete before we can copy back our image. osg::ref_ptr callback (new NotifyDrawCompletedCallback); rttCamera->setFinalDrawCallback(callback); @@ -907,6 +914,9 @@ namespace MWRender // now that we've "used up" the current frame, get a fresh framenumber for the next frame() following after the screenshot is completed mViewer->advance(mViewer->getFrameStamp()->getSimulationTime()); + mViewer->getCamera()->setClearMask(maskBackup); + mViewer->getCamera()->setClearDepth(clearDepthBackup); + rttCamera->removeChildren(0, rttCamera->getNumChildren()); mRootNode->removeChild(rttCamera); }