1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H
38#define QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists for the convenience
45// of other Qt classes. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <Qt3DCore/qnodeid.h>
52#include <Qt3DCore/qpropertyupdatedchange.h>
53#include <Qt3DRender/qpickevent.h>
54#include <Qt3DQuickScene2D/qscene2d.h>
55
56#include <private/qscene2d_p.h>
57#include <private/qrendertargetoutput_p.h>
58#include <private/backendnode_p.h>
59#include <private/attachmentpack_p.h>
60
61QT_BEGIN_NAMESPACE
62
63namespace Qt3DRender {
64
65namespace Render {
66
67class GraphicsContext;
68
69namespace Quick {
70
71class Scene2D;
72
73class RenderQmlEventHandler : public QObject
74{
75 Q_OBJECT
76public:
77 RenderQmlEventHandler(Scene2D *node);
78 bool event(QEvent *e) override;
79
80private:
81 Scene2D *m_node;
82};
83
84class Q_3DQUICKSCENE2DSHARED_EXPORT Scene2D : public Qt3DRender::Render::BackendNode
85{
86public:
87 Scene2D();
88 ~Scene2D();
89
90 void render();
91 void initializeRender();
92 void setSharedObject(Qt3DRender::Quick::Scene2DSharedObjectPtr sharedObject);
93 void cleanup();
94 void setOutput(Qt3DCore::QNodeId outputId);
95 void initializeSharedObject();
96
97 void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
98
99 bool updateFbo(QOpenGLTexture *texture);
100 void syncRenderControl();
101 bool registerObjectPickerEvents(Qt3DCore::QEntity *qentity);
102 void unregisterObjectPickerEvents(Qt3DCore::QNodeId entityId);
103 void handlePickEvent(int type, const QPickEvent *ev);
104
105 QOpenGLContext *m_context;
106 QOpenGLContext *m_shareContext;
107 QThread *m_renderThread;
108 Qt3DCore::QNodeId m_outputId;
109 QSharedPointer<Qt3DRender::Quick::Scene2DSharedObject> m_sharedObject;
110 Qt3DCore::QNodeId m_peerId;
111 Qt3DRender::Render::Attachment m_attachmentData;
112
113 GLuint m_fbo;
114 GLuint m_rbo;
115 QSize m_textureSize;
116
117 bool m_initialized;
118 bool m_renderInitialized;
119 bool m_mouseEnabled;
120 Qt3DRender::Quick::QScene2D::RenderPolicy m_renderPolicy;
121 QVector<Qt3DCore::QNodeId> m_entities;
122 Qt3DRender::QPickEventPtr m_cachedPickEvent;
123#ifdef QT_OPENGL_ES_2_ANGLE
124 bool m_usingAngle;
125#endif
126 QVector<QMetaObject::Connection> m_connections;
127};
128
129} // Quick
130} // Render
131} // Qt3DRender
132
133QT_END_NAMESPACE
134
135#endif // QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H
136

source code of qt3d/src/quick3d/quick3dscene2d/items/scene2d_p.h