QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsabstract3dengine.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsabstract3dengine.cpp
3  --------------------------------------
4  Date : July 2018
5  Copyright : (C) 2018 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsabstract3dengine.h"
17 
19 
20 #include <Qt3DRender/QRenderCapture>
21 #include <Qt3DRender/QRenderSettings>
22 
24  : QObject( parent )
25 {
26 
27 }
28 
30 {
31  Qt3DRender::QRenderCaptureReply *captureReply;
32  captureReply = mFrameGraph->renderCapture()->requestCapture();
33  // We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
34  this->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );
35  connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [ = ]
36  {
37  emit imageCaptured( captureReply->image() );
38  this->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::OnDemand );
39  captureReply->deleteLater();
40  } );
41 }
42 
44 {
45  Qt3DRender::QRenderCaptureReply *captureReply;
46  captureReply = mFrameGraph->depthRenderCapture()->requestCapture();
47  // We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
48  this->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );
49  connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [ = ]
50  {
51  emit depthBufferCaptured( captureReply->image() );
52  this->renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::OnDemand );
53  captureReply->deleteLater();
54  } );
55 }
56 
58 {
60 }
61 
63 {
65 }
QgsAbstract3DEngine::mFrameGraph
QgsShadowRenderingFrameGraph * mFrameGraph
Definition: qgsabstract3dengine.h:139
QgsAbstract3DEngine::depthBufferCaptured
void depthBufferCaptured(const QImage &image)
Emitted after a call to requestDepthBufferCapture() to return the captured depth buffer.
QgsAbstract3DEngine::imageCaptured
void imageCaptured(const QImage &image)
Emitted after a call to requestCaptureImage() to return the captured image.
QgsAbstract3DEngine::QgsAbstract3DEngine
QgsAbstract3DEngine(QObject *parent=nullptr)
Constructor for QgsAbstract3DEngine with the specified parent object.
Definition: qgsabstract3dengine.cpp:23
qgsshadowrenderingframegraph.h
QgsAbstract3DEngine::requestDepthBufferCapture
void requestDepthBufferCapture()
Starts a request for an image containing the depth buffer data of the engine.
Definition: qgsabstract3dengine.cpp:43
qgsabstract3dengine.h
QgsShadowRenderingFrameGraph::renderCapture
Qt3DRender::QRenderCapture * renderCapture()
Returns the render capture object used to take an image of the scene.
Definition: qgsshadowrenderingframegraph.h:102
QgsAbstract3DEngine::requestCaptureImage
void requestCaptureImage()
Starts a request for an image rendered by the engine.
Definition: qgsabstract3dengine.cpp:29
QgsShadowRenderingFrameGraph::depthRenderCapture
Qt3DRender::QRenderCapture * depthRenderCapture()
Returns the render capture object used to take an image of the depth buffer of the scene.
Definition: qgsshadowrenderingframegraph.h:105
QgsShadowRenderingFrameGraph::setRenderCaptureEnabled
void setRenderCaptureEnabled(bool enabled)
Sets whether it will be possible to render to an image.
Definition: qgsshadowrenderingframegraph.cpp:673
QgsAbstract3DEngine::renderSettings
virtual Qt3DRender::QRenderSettings * renderSettings()=0
Returns access to the engine's render settings (the frame graph can be accessed from here)
QgsAbstract3DEngine::renderCaptureEnabled
bool renderCaptureEnabled() const
Returns whether it will be possible to render to an image.
Definition: qgsabstract3dengine.cpp:62
QgsAbstract3DEngine::setRenderCaptureEnabled
void setRenderCaptureEnabled(bool enabled)
Sets whether it will be possible to render to an image.
Definition: qgsabstract3dengine.cpp:57
QgsShadowRenderingFrameGraph::renderCaptureEnabled
bool renderCaptureEnabled() const
Returns whether it will be possible to render to an image.
Definition: qgsshadowrenderingframegraph.h:153