1// Copyright (C) 2015 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 QT3DRENDER_QGEOMETRYRENDERER_H
5#define QT3DRENDER_QGEOMETRYRENDERER_H
6
7#include <Qt3DCore/qboundingvolume.h>
8#include <Qt3DCore/qgeometry.h>
9#include <Qt3DCore/qgeometryview.h>
10#include <Qt3DRender/qt3drender_global.h>
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DRender {
15
16class QGeometryRendererPrivate;
17
18class Q_3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QBoundingVolume
19{
20 Q_OBJECT
21 Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged)
22 Q_PROPERTY(int vertexCount READ vertexCount WRITE setVertexCount NOTIFY vertexCountChanged)
23 Q_PROPERTY(int indexOffset READ indexOffset WRITE setIndexOffset NOTIFY indexOffsetChanged)
24 Q_PROPERTY(int firstInstance READ firstInstance WRITE setFirstInstance NOTIFY firstInstanceChanged)
25 Q_PROPERTY(int firstVertex READ firstVertex WRITE setFirstVertex NOTIFY firstVertexChanged)
26 Q_PROPERTY(int indexBufferByteOffset READ indexBufferByteOffset WRITE setIndexBufferByteOffset NOTIFY indexBufferByteOffsetChanged)
27 Q_PROPERTY(int restartIndexValue READ restartIndexValue WRITE setRestartIndexValue NOTIFY restartIndexValueChanged)
28 Q_PROPERTY(int verticesPerPatch READ verticesPerPatch WRITE setVerticesPerPatch NOTIFY verticesPerPatchChanged)
29 Q_PROPERTY(bool primitiveRestartEnabled READ primitiveRestartEnabled WRITE setPrimitiveRestartEnabled NOTIFY primitiveRestartEnabledChanged)
30 Q_PROPERTY(Qt3DCore::QGeometry* geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
31 Q_PROPERTY(PrimitiveType primitiveType READ primitiveType WRITE setPrimitiveType NOTIFY primitiveTypeChanged)
32 Q_PROPERTY(float sortIndex READ sortIndex WRITE setSortIndex NOTIFY sortIndexChanged)
33public:
34 explicit QGeometryRenderer(Qt3DCore::QNode *parent = nullptr);
35 ~QGeometryRenderer();
36
37 enum PrimitiveType {
38 Points = 0x0000,
39 Lines = 0x0001,
40 LineLoop = 0x0002,
41 LineStrip = 0x0003,
42 Triangles = 0x0004,
43 TriangleStrip = 0x0005,
44 TriangleFan = 0x0006,
45 LinesAdjacency = 0x000A,
46 TrianglesAdjacency = 0x000C,
47 LineStripAdjacency = 0x000B,
48 TriangleStripAdjacency = 0x000D,
49 Patches = 0x000E
50 };
51 Q_ENUM(PrimitiveType) // LCOV_EXCL_LINE
52
53 // how to figure out index count and all the fancy stuff that QMeshData provides for us?
54 // also how to figure out which attribute(s?) hold the indices?
55
56 int instanceCount() const;
57 int vertexCount() const;
58 int indexOffset() const;
59 int firstInstance() const;
60 int firstVertex() const;
61 int indexBufferByteOffset() const;
62 int restartIndexValue() const;
63 int verticesPerPatch() const;
64 bool primitiveRestartEnabled() const;
65 Qt3DCore::QGeometry *geometry() const;
66 PrimitiveType primitiveType() const;
67 float sortIndex() const;
68
69public Q_SLOTS:
70 void setInstanceCount(int instanceCount);
71 void setVertexCount(int vertexCount);
72 void setIndexOffset(int indexOffset);
73 void setFirstInstance(int firstInstance);
74 void setFirstVertex(int firstVertex);
75 void setIndexBufferByteOffset(int offset);
76 void setRestartIndexValue(int index);
77 void setVerticesPerPatch(int verticesPerPatch);
78 void setPrimitiveRestartEnabled(bool enabled);
79 void setGeometry(Qt3DCore::QGeometry *geometry);
80 void setPrimitiveType(PrimitiveType primitiveType);
81 void setSortIndex(float sortIndex);
82
83Q_SIGNALS:
84 void instanceCountChanged(int instanceCount);
85 void vertexCountChanged(int vertexCount);
86 void indexOffsetChanged(int indexOffset);
87 void firstInstanceChanged(int firstInstance);
88 void firstVertexChanged(int firstVertex);
89 void indexBufferByteOffsetChanged(int offset);
90 void restartIndexValueChanged(int restartIndexValue);
91 void verticesPerPatchChanged(int verticesPerPatch);
92 void primitiveRestartEnabledChanged(bool primitiveRestartEnabled);
93 void geometryChanged(Qt3DCore::QGeometry *geometry);
94 void primitiveTypeChanged(PrimitiveType primitiveType);
95
96 void sortIndexChanged(float sortIndex);
97
98protected:
99 explicit QGeometryRenderer(QGeometryRendererPrivate &dd, Qt3DCore::QNode *parent = nullptr);
100
101private:
102 Q_DECLARE_PRIVATE(QGeometryRenderer)
103 float m_sortIndex; // TODO Remove in Qt 7
104};
105
106} // namespace Qt3DRender
107
108QT_END_NAMESPACE
109
110#endif // QT3DRENDER_QGEOMETRYRENDERER_H
111

source code of qt3d/src/render/geometry/qgeometryrenderer.h