| 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_RENDER_GEOMETRYRENDERER_H |
| 5 | #define QT3DRENDER_RENDER_GEOMETRYRENDERER_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/private/qgeometryfactory_p.h> |
| 19 | #include <Qt3DRender/private/backendnode_p.h> |
| 20 | #include <Qt3DRender/qgeometryrenderer.h> |
| 21 | #include <Qt3DRender/qmesh.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | namespace Qt3DRender { |
| 26 | |
| 27 | namespace Render { |
| 28 | |
| 29 | class GeometryRendererManager; |
| 30 | |
| 31 | struct GeometryFunctorResult |
| 32 | { |
| 33 | Qt3DCore::QGeometry *geometry; |
| 34 | QMesh::Status status; |
| 35 | }; |
| 36 | |
| 37 | class Q_3DRENDERSHARED_PRIVATE_EXPORT GeometryRenderer : public BackendNode |
| 38 | { |
| 39 | public: |
| 40 | GeometryRenderer(); |
| 41 | ~GeometryRenderer(); |
| 42 | |
| 43 | void cleanup(); |
| 44 | void setManager(GeometryRendererManager *manager); |
| 45 | void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; |
| 46 | GeometryFunctorResult executeFunctor(); |
| 47 | |
| 48 | inline Qt3DCore::QNodeId geometryId() const { return m_geometryId; } |
| 49 | inline int instanceCount() const { return m_instanceCount; } |
| 50 | inline int vertexCount() const { return m_vertexCount; } |
| 51 | inline int indexOffset() const { return m_indexOffset; } |
| 52 | inline int firstInstance() const { return m_firstInstance; } |
| 53 | inline int firstVertex() const { return m_firstVertex; } |
| 54 | inline int indexBufferByteOffset() const { return m_indexBufferByteOffset; } |
| 55 | inline int restartIndexValue() const { return m_restartIndexValue; } |
| 56 | inline int verticesPerPatch() const { return m_verticesPerPatch; } |
| 57 | inline bool primitiveRestartEnabled() const { return m_primitiveRestartEnabled; } |
| 58 | inline QGeometryRenderer::PrimitiveType primitiveType() const { return m_primitiveType; } |
| 59 | inline bool isDirty() const { return m_dirty; } |
| 60 | inline Qt3DCore::QGeometryFactoryPtr geometryFactory() const { return m_geometryFactory; } |
| 61 | void unsetDirty(); |
| 62 | bool hasView() const { return m_hasView; } |
| 63 | float sortIndex() const { return m_sortIndex; } |
| 64 | |
| 65 | private: |
| 66 | Qt3DCore::QNodeId m_geometryId; |
| 67 | int m_instanceCount; |
| 68 | int m_vertexCount; |
| 69 | int m_indexOffset; |
| 70 | int m_firstInstance; |
| 71 | int m_firstVertex; |
| 72 | int m_indexBufferByteOffset; |
| 73 | int m_restartIndexValue; |
| 74 | int m_verticesPerPatch; |
| 75 | bool m_primitiveRestartEnabled; |
| 76 | QGeometryRenderer::PrimitiveType m_primitiveType; |
| 77 | bool m_dirty; |
| 78 | bool m_hasView; |
| 79 | Qt3DCore::QGeometryFactoryPtr m_geometryFactory; |
| 80 | GeometryRendererManager *m_manager; |
| 81 | float m_sortIndex; |
| 82 | }; |
| 83 | |
| 84 | class GeometryRendererFunctor : public Qt3DCore::QBackendNodeMapper |
| 85 | { |
| 86 | public: |
| 87 | explicit GeometryRendererFunctor(AbstractRenderer *renderer, GeometryRendererManager *manager); |
| 88 | Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const override; |
| 89 | Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const override; |
| 90 | void destroy(Qt3DCore::QNodeId id) const override; |
| 91 | private: |
| 92 | GeometryRendererManager *m_manager; |
| 93 | AbstractRenderer *m_renderer; |
| 94 | }; |
| 95 | |
| 96 | } // namespace Render |
| 97 | |
| 98 | } // namespace Qt3DRender |
| 99 | |
| 100 | QT_END_NAMESPACE |
| 101 | |
| 102 | #endif // QT3DRENDER_RENDER_RENDERGEOMETRYRENDERER_H |
| 103 | |