1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
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 QT3DCORE_QBUFFER_H
5#define QT3DCORE_QBUFFER_H
6
7#include <Qt3DCore/qnode.h>
8#include <Qt3DCore/qt3dcore_global.h>
9#include <QtCore/QSharedPointer>
10
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DCore {
15
16class QBufferPrivate;
17
18class Q_3DCORESHARED_EXPORT QBuffer : public Qt3DCore::QNode
19{
20 Q_OBJECT
21 Q_PROPERTY(UsageType usage READ usage WRITE setUsage NOTIFY usageChanged)
22 Q_PROPERTY(AccessType accessType READ accessType WRITE setAccessType NOTIFY accessTypeChanged QT3D_PROPERTY_REVISION(2, 9))
23
24public:
25 enum UsageType
26 {
27 StreamDraw = 0x88E0, // GL_STREAM_DRAW
28 StreamRead = 0x88E1, // GL_STREAM_READ
29 StreamCopy = 0x88E2, // GL_STREAM_COPY
30 StaticDraw = 0x88E4, // GL_STATIC_DRAW
31 StaticRead = 0x88E5, // GL_STATIC_READ
32 StaticCopy = 0x88E6, // GL_STATIC_COPY
33 DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW
34 DynamicRead = 0x88E9, // GL_DYNAMIC_READ
35 DynamicCopy = 0x88EA // GL_DYNAMIC_COPY
36 };
37 Q_ENUM(UsageType) // LCOV_EXCL_LINE
38
39 enum AccessType {
40 Write = 0x1,
41 Read = 0x2,
42 ReadWrite = Write|Read
43 };
44 Q_ENUM(AccessType) // LCOV_EXCL_LINE
45
46 explicit QBuffer(Qt3DCore::QNode *parent = nullptr);
47 ~QBuffer();
48
49 UsageType usage() const;
50 AccessType accessType() const;
51
52 void setData(const QByteArray &bytes);
53 QByteArray data() const;
54
55 Q_INVOKABLE void updateData(int offset, const QByteArray &bytes);
56
57public Q_SLOTS:
58 void setUsage(UsageType usage);
59 void setAccessType(AccessType access);
60
61Q_SIGNALS:
62 void dataChanged(const QByteArray &bytes);
63 void usageChanged(UsageType usage);
64 void accessTypeChanged(AccessType access);
65 void dataAvailable();
66
67private:
68 Q_DECLARE_PRIVATE(QBuffer)
69};
70
71} // namespace Qt3DCore
72
73QT_END_NAMESPACE
74
75#endif // QT3DCORE_QBUFFER_H
76

source code of qt3d/src/core/geometry/qbuffer.h