1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
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 https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QT3DRENDER_QBUFFER_H |
41 | #define QT3DRENDER_QBUFFER_H |
42 | |
43 | #include <Qt3DCore/qnode.h> |
44 | #include <Qt3DRender/qt3drender_global.h> |
45 | #include <QtCore/QSharedPointer> |
46 | |
47 | |
48 | QT_BEGIN_NAMESPACE |
49 | |
50 | namespace Qt3DRender { |
51 | |
52 | class QBufferPrivate; |
53 | class QBufferDataGenerator; |
54 | typedef QSharedPointer<QBufferDataGenerator> QBufferDataGeneratorPtr; |
55 | |
56 | class Q_3DRENDERSHARED_EXPORT QBuffer : public Qt3DCore::QNode |
57 | { |
58 | Q_OBJECT |
59 | Q_PROPERTY(BufferType type READ type WRITE setType NOTIFY typeChanged) |
60 | Q_PROPERTY(UsageType usage READ usage WRITE setUsage NOTIFY usageChanged) |
61 | Q_PROPERTY(bool syncData READ isSyncData WRITE setSyncData NOTIFY syncDataChanged) |
62 | Q_PROPERTY(AccessType accessType READ accessType WRITE setAccessType NOTIFY accessTypeChanged REVISION 9) |
63 | |
64 | public: |
65 | enum BufferType |
66 | { |
67 | VertexBuffer = 0x8892, // GL_ARRAY_BUFFER |
68 | IndexBuffer = 0x8893, // GL_ELEMENT_ARRAY_BUFFER |
69 | PixelPackBuffer = 0x88EB, // GL_PIXEL_PACK_BUFFER |
70 | PixelUnpackBuffer = 0x88EC, // GL_PIXEL_UNPACK_BUFFER |
71 | UniformBuffer = 0x8A11, // GL_UNIFORM_BUFFER |
72 | ShaderStorageBuffer = 0x90D2, // GL_SHADER_STORAGE_BUFFER |
73 | DrawIndirectBuffer = 0x8F3F // GL_DRAW_INDIRECT_BUFFER |
74 | }; |
75 | Q_ENUM(BufferType) // LCOV_EXCL_LINE |
76 | |
77 | enum UsageType |
78 | { |
79 | StreamDraw = 0x88E0, // GL_STREAM_DRAW |
80 | StreamRead = 0x88E1, // GL_STREAM_READ |
81 | StreamCopy = 0x88E2, // GL_STREAM_COPY |
82 | StaticDraw = 0x88E4, // GL_STATIC_DRAW |
83 | StaticRead = 0x88E5, // GL_STATIC_READ |
84 | StaticCopy = 0x88E6, // GL_STATIC_COPY |
85 | DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW |
86 | DynamicRead = 0x88E9, // GL_DYNAMIC_READ |
87 | DynamicCopy = 0x88EA // GL_DYNAMIC_COPY |
88 | }; |
89 | Q_ENUM(UsageType) // LCOV_EXCL_LINE |
90 | |
91 | enum AccessType { |
92 | Write = 0x1, |
93 | Read = 0x2, |
94 | ReadWrite = Write|Read |
95 | }; |
96 | Q_ENUM(AccessType) // LCOV_EXCL_LINE |
97 | |
98 | explicit QBuffer(Qt3DCore::QNode *parent = nullptr); |
99 | QT_DEPRECATED explicit QBuffer(BufferType ty, Qt3DCore::QNode *parent = nullptr); |
100 | ~QBuffer(); |
101 | |
102 | UsageType usage() const; |
103 | QT_DEPRECATED BufferType type() const; |
104 | bool isSyncData() const; |
105 | AccessType accessType() const; |
106 | |
107 | void setData(const QByteArray &bytes); |
108 | QByteArray data() const; |
109 | |
110 | Q3D_DECL_DEPRECATED void setDataGenerator(const QBufferDataGeneratorPtr &functor); |
111 | Q3D_DECL_DEPRECATED QBufferDataGeneratorPtr dataGenerator() const; |
112 | |
113 | Q_INVOKABLE void updateData(int offset, const QByteArray &bytes); |
114 | |
115 | public Q_SLOTS: |
116 | QT_DEPRECATED void setType(BufferType type); |
117 | void setUsage(UsageType usage); |
118 | void setSyncData(bool syncData); |
119 | void setAccessType(AccessType access); |
120 | |
121 | Q_SIGNALS: |
122 | void dataChanged(const QByteArray &bytes); |
123 | void typeChanged(BufferType type); |
124 | void usageChanged(UsageType usage); |
125 | void syncDataChanged(bool syncData); |
126 | void accessTypeChanged(AccessType access); |
127 | void dataAvailable(); |
128 | |
129 | protected: |
130 | // TODO Unused remove in Qt6 |
131 | void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override; |
132 | |
133 | private: |
134 | Q_DECLARE_PRIVATE(QBuffer) |
135 | Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override; |
136 | }; |
137 | |
138 | } // namespace Qt3DRender |
139 | |
140 | QT_END_NAMESPACE |
141 | |
142 | #endif // QT3DRENDER_QBUFFER_H |
143 | |