| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H |
| 5 | #define QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of other Qt classes. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <Qt3DCore/qnodeid.h> |
| 19 | #include <Qt3DRender/qpickevent.h> |
| 20 | #include <Qt3DQuickScene2D/qscene2d.h> |
| 21 | |
| 22 | #include <private/qscene2d_p.h> |
| 23 | #include <private/qrendertargetoutput_p.h> |
| 24 | #include <private/backendnode_p.h> |
| 25 | #include <private/attachmentpack_p.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | namespace Qt3DRender { |
| 30 | |
| 31 | namespace Render { |
| 32 | |
| 33 | class GraphicsContext; |
| 34 | |
| 35 | namespace Quick { |
| 36 | |
| 37 | class Scene2D; |
| 38 | |
| 39 | class RenderQmlEventHandler : public QObject |
| 40 | { |
| 41 | Q_OBJECT |
| 42 | public: |
| 43 | RenderQmlEventHandler(Scene2D *node); |
| 44 | bool event(QEvent *e) override; |
| 45 | |
| 46 | private: |
| 47 | Scene2D *m_node; |
| 48 | }; |
| 49 | |
| 50 | class Q_3DQUICKSCENE2DSHARED_EXPORT Scene2D : public Qt3DRender::Render::BackendNode |
| 51 | { |
| 52 | public: |
| 53 | Scene2D(); |
| 54 | ~Scene2D(); |
| 55 | |
| 56 | void render(); |
| 57 | void initializeRender(); |
| 58 | void setSharedObject(Qt3DRender::Quick::Scene2DSharedObjectPtr sharedObject); |
| 59 | void cleanup(); |
| 60 | void setOutput(Qt3DCore::QNodeId outputId); |
| 61 | void initializeSharedObject(); |
| 62 | |
| 63 | void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; |
| 64 | |
| 65 | bool updateFbo(QOpenGLTexture *texture); |
| 66 | void syncRenderControl(); |
| 67 | bool registerObjectPickerEvents(Qt3DCore::QEntity *qentity); |
| 68 | void unregisterObjectPickerEvents(Qt3DCore::QNodeId entityId); |
| 69 | void handlePickEvent(int type, const QPickEvent *ev); |
| 70 | |
| 71 | QOpenGLContext *m_context; |
| 72 | QOpenGLContext *m_shareContext; |
| 73 | QThread *m_renderThread; |
| 74 | Qt3DCore::QNodeId m_outputId; |
| 75 | QSharedPointer<Qt3DRender::Quick::Scene2DSharedObject> m_sharedObject; |
| 76 | Qt3DCore::QNodeId m_peerId; |
| 77 | Qt3DRender::Render::Attachment m_attachmentData; |
| 78 | |
| 79 | GLuint m_fbo; |
| 80 | GLuint m_rbo; |
| 81 | QSize m_textureSize; |
| 82 | |
| 83 | bool m_initialized; |
| 84 | bool m_renderInitialized; |
| 85 | bool m_mouseEnabled; |
| 86 | Qt3DRender::Quick::QScene2D::RenderPolicy m_renderPolicy; |
| 87 | QList<Qt3DCore::QNodeId> m_entities; |
| 88 | Qt3DRender::QPickEventPtr m_cachedPickEvent; |
| 89 | QList<QMetaObject::Connection> m_connections; |
| 90 | }; |
| 91 | |
| 92 | } // Quick |
| 93 | } // Render |
| 94 | } // Qt3DRender |
| 95 | |
| 96 | QT_END_NAMESPACE |
| 97 | |
| 98 | #endif // QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H |
| 99 | |