Skip to content
Permalink
Browse files

change render policy to Always when it needs to be

(cherry picked from commit a225666)
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 13, 2021
1 parent 1864237 commit f7013d2fd25d2954c9917c0b247d201aa22594b3
Showing with 11 additions and 0 deletions.
  1. +7 −0 src/3d/qgs3dutils.cpp
  2. +4 −0 src/3d/qgsabstract3dengine.cpp
@@ -38,12 +38,16 @@
#include "qgspolygon3dsymbol.h"

#include <Qt3DExtras/QPhongMaterial>
#include <Qt3DRender/QRenderSettings>

QImage Qgs3DUtils::captureSceneImage( QgsAbstract3DEngine &engine, Qgs3DMapScene *scene )
{
QImage resImage;
QEventLoop evLoop;

// We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );

auto requestImageFcn = [&engine, scene]
{
if ( scene->sceneState() == Qgs3DMapScene::Ready )
@@ -77,6 +81,7 @@ QImage Qgs3DUtils::captureSceneImage( QgsAbstract3DEngine &engine, Qgs3DMapScene
if ( conn2 )
QObject::disconnect( conn2 );

engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::OnDemand );
return resImage;
}

@@ -94,6 +99,8 @@ bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSetting
engine.setSize( outputSize );
Qgs3DMapScene *scene = new Qgs3DMapScene( mapSettings, &engine );
engine.setRootEntity( scene );
// We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );

if ( animationSettings.keyFrames().size() < 2 )
{
@@ -18,6 +18,7 @@
#include "qgsshadowrenderingframegraph.h"

#include <Qt3DRender/QRenderCapture>
#include <Qt3DRender/QRenderSettings>

QgsAbstract3DEngine::QgsAbstract3DEngine( QObject *parent )
: QObject( parent )
@@ -29,9 +30,12 @@ void QgsAbstract3DEngine::requestCaptureImage()
{
Qt3DRender::QRenderCaptureReply *captureReply;
captureReply = mFrameGraph->renderCapture()->requestCapture();
// We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
this->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );
connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [ = ]
{
emit imageCaptured( captureReply->image() );
this->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::OnDemand );
captureReply->deleteLater();
} );
}

0 comments on commit f7013d2

Please sign in to comment.