From 1a4f351e3d9fafbb60c0baa1d0485376b55c65aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Thu, 16 Nov 2017 12:17:52 +0100 Subject: [PATCH] move camera freeze code --- apps/openmw/mwrender/renderingmanager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 3b82b549d..c571d516f 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -806,6 +806,11 @@ namespace MWRender osg::ref_ptr callback (new NotifyDrawCompletedCallback); camera->setFinalDrawCallback(callback); + GLbitfield maskBackup = mViewer->getCamera()->getClearMask(); + double clearDepthBackup = mViewer->getCamera()->getClearDepth(); + mViewer->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT); // don't render the main camera + mViewer->getCamera()->setClearDepth(0); + // at the time this function is called we are in the middle of a frame, // so out of order calls are necessary to get a correct frameNumber for the next frame. // refer to the advance() and frame() order in Engine::go() @@ -816,6 +821,9 @@ namespace MWRender callback->waitTillDone(); + mViewer->getCamera()->setClearMask(maskBackup); + mViewer->getCamera()->setClearDepth(clearDepthBackup); + // 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()); } @@ -856,16 +864,8 @@ namespace MWRender 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); - renderCameraToImage(rttCamera.get(),image,w,h); - mViewer->getCamera()->setClearMask(maskBackup); - mViewer->getCamera()->setClearDepth(clearDepthBackup); - rttCamera->removeChildren(0, rttCamera->getNumChildren()); mRootNode->removeChild(rttCamera); }