QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsoffscreen3dengine.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsoffscreen3dengine.h
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 #ifndef QGSOFFSCREEN3DENGINE_H
17 #define QGSOFFSCREEN3DENGINE_H
18 
19 #include "qgsabstract3dengine.h"
20 
21 #include <QSize>
22 
23 class QOffscreenSurface;
24 
25 namespace Qt3DCore
26 {
27  class QAspectEngine;
28  class QNode;
29 }
30 
31 namespace Qt3DRender
32 {
33  class QCameraSelector;
34  class QClearBuffers;
35  class QRenderAspect;
36  class QRenderCapture;
37  class QRenderCaptureReply;
38  class QRenderTarget;
39  class QRenderTargetSelector;
40  class QRenderTargetOutput;
41  class QRenderSurfaceSelector;
42  class QTexture2D;
43  class QViewport;
44 }
45 
46 namespace Qt3DLogic
47 {
48  class QLogicAspect;
49 }
50 
51 
61 class _3D_EXPORT QgsOffscreen3DEngine : public QgsAbstract3DEngine
62 {
63  Q_OBJECT
64  public:
66  ~QgsOffscreen3DEngine() override;
67 
69  void setSize( QSize s );
70 
71  void setClearColor( const QColor &color ) override;
72  void setFrustumCullingEnabled( bool enabled ) override;
73  void setRootEntity( Qt3DCore::QEntity *root ) override;
74 
75  Qt3DRender::QRenderSettings *renderSettings() override;
76  Qt3DRender::QCamera *camera() override;
77  QSize size() const override;
78 
79  void requestCaptureImage() override;
80 
81  private:
82  void createRenderTarget();
83  void createFrameGraph();
84 
85  private:
86 
87  QSize mSize = QSize( 640, 480 );
88  Qt3DRender::QCamera *mCamera = nullptr;
89  QOffscreenSurface *mOffscreenSurface = nullptr;
90  Qt3DRender::QRenderCaptureReply *mReply = nullptr;
91 
92  // basic Qt3D stuff
93  Qt3DCore::QAspectEngine *mAspectEngine = nullptr; // The aspect engine, which holds the scene and related aspects.
94  Qt3DRender::QRenderAspect *mRenderAspect = nullptr; // The render aspect, which deals with rendering the scene.
95  Qt3DLogic::QLogicAspect *mLogicAspect = nullptr; // The logic aspect, which runs jobs to do with synchronising frames.
96  Qt3DRender::QRenderSettings *mRenderSettings = nullptr; // The render settings, which control the general rendering behavior.
97  Qt3DCore::QNode *mSceneRoot = nullptr; // The scene root, which becomes a child of the engine's root entity.
98  Qt3DCore::QEntity *mRoot = nullptr;
99 
100  // render target stuff
101  Qt3DRender::QRenderTarget *mTextureTarget = nullptr;
102  Qt3DRender::QRenderTargetOutput *mTextureOutput = nullptr;
103  Qt3DRender::QTexture2D *mTexture = nullptr;
104  Qt3DRender::QRenderTargetOutput *mDepthTextureOutput = nullptr;
105  Qt3DRender::QTexture2D *mDepthTexture = nullptr;
106 
107  // frame graph stuff
108  Qt3DRender::QRenderSurfaceSelector *mSurfaceSelector = nullptr;
109  Qt3DRender::QRenderTargetSelector *mRenderTargetSelector = nullptr;
110  Qt3DRender::QViewport *mViewport = nullptr;
111  Qt3DRender::QClearBuffers *mClearBuffers = nullptr;
112  Qt3DRender::QCameraSelector *mCameraSelector = nullptr;
113  Qt3DRender::QRenderCapture *mRenderCapture = nullptr; // The render capture node, which is appended to the frame graph.
114 
115 };
116 
117 #endif // QGSOFFSCREEN3DENGINE_H
3 Off-screen 3D engine implementation.
3 Base class for 3D engine implementation.