| 1 | // Copyright (C) 2017 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_QSHADERPROGRAMBUILDER_H |
| 5 | #define QT3DRENDER_QSHADERPROGRAMBUILDER_H |
| 6 | |
| 7 | #include <Qt3DCore/qnode.h> |
| 8 | #include <Qt3DRender/qt3drender_global.h> |
| 9 | #include <Qt3DRender/qshaderprogram.h> |
| 10 | |
| 11 | #include <QtCore/qurl.h> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | namespace Qt3DRender { |
| 16 | |
| 17 | class QShaderProgramBuilderPrivate; |
| 18 | |
| 19 | class Q_3DRENDERSHARED_EXPORT QShaderProgramBuilder : public Qt3DCore::QNode |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | Q_PROPERTY(Qt3DRender::QShaderProgram* shaderProgram READ shaderProgram WRITE setShaderProgram NOTIFY shaderProgramChanged) |
| 23 | Q_PROPERTY(QStringList enabledLayers READ enabledLayers WRITE setEnabledLayers NOTIFY enabledLayersChanged) |
| 24 | Q_PROPERTY(QUrl vertexShaderGraph READ vertexShaderGraph WRITE setVertexShaderGraph NOTIFY vertexShaderGraphChanged) |
| 25 | Q_PROPERTY(QUrl tessellationControlShaderGraph READ tessellationControlShaderGraph WRITE setTessellationControlShaderGraph NOTIFY tessellationControlShaderGraphChanged) |
| 26 | Q_PROPERTY(QUrl tessellationEvaluationShaderGraph READ tessellationEvaluationShaderGraph WRITE setTessellationEvaluationShaderGraph NOTIFY tessellationEvaluationShaderGraphChanged) |
| 27 | Q_PROPERTY(QUrl geometryShaderGraph READ geometryShaderGraph WRITE setGeometryShaderGraph NOTIFY geometryShaderGraphChanged) |
| 28 | Q_PROPERTY(QUrl fragmentShaderGraph READ fragmentShaderGraph WRITE setFragmentShaderGraph NOTIFY fragmentShaderGraphChanged) |
| 29 | Q_PROPERTY(QUrl computeShaderGraph READ computeShaderGraph WRITE setComputeShaderGraph NOTIFY computeShaderGraphChanged) |
| 30 | Q_PROPERTY(QByteArray vertexShaderCode READ vertexShaderCode NOTIFY vertexShaderCodeChanged REVISION(2, 13)) |
| 31 | Q_PROPERTY(QByteArray tessellationControlShaderCode READ tessellationControlShaderCode NOTIFY tessellationControlShaderCodeChanged REVISION(2, 13)) |
| 32 | Q_PROPERTY(QByteArray tessellationEvaluationShaderCode READ tessellationEvaluationShaderCode NOTIFY tessellationEvaluationShaderCodeChanged REVISION(2, 13)) |
| 33 | Q_PROPERTY(QByteArray geometryShaderCode READ geometryShaderCode NOTIFY geometryShaderCodeChanged REVISION(2, 13)) |
| 34 | Q_PROPERTY(QByteArray fragmentShaderCode READ fragmentShaderCode NOTIFY fragmentShaderCodeChanged REVISION(2, 13)) |
| 35 | Q_PROPERTY(QByteArray computeShaderCode READ computeShaderCode NOTIFY computeShaderCodeChanged REVISION(2, 13)) |
| 36 | |
| 37 | public: |
| 38 | explicit QShaderProgramBuilder(Qt3DCore::QNode *parent = nullptr); |
| 39 | ~QShaderProgramBuilder(); |
| 40 | |
| 41 | QShaderProgram *shaderProgram() const; |
| 42 | QStringList enabledLayers() const; |
| 43 | QUrl vertexShaderGraph() const; |
| 44 | QUrl tessellationControlShaderGraph() const; |
| 45 | QUrl tessellationEvaluationShaderGraph() const; |
| 46 | QUrl geometryShaderGraph() const; |
| 47 | QUrl fragmentShaderGraph() const; |
| 48 | QUrl computeShaderGraph() const; |
| 49 | QByteArray vertexShaderCode() const; |
| 50 | QByteArray tessellationControlShaderCode() const; |
| 51 | QByteArray tessellationEvaluationShaderCode() const; |
| 52 | QByteArray geometryShaderCode() const; |
| 53 | QByteArray fragmentShaderCode() const; |
| 54 | QByteArray computeShaderCode() const; |
| 55 | |
| 56 | public Q_SLOTS: |
| 57 | void setShaderProgram(Qt3DRender::QShaderProgram *program); |
| 58 | void setEnabledLayers(const QStringList &layers); |
| 59 | void setVertexShaderGraph(const QUrl &vertexShaderGraph); |
| 60 | void setTessellationControlShaderGraph(const QUrl &tessellationControlShaderGraph); |
| 61 | void setTessellationEvaluationShaderGraph(const QUrl &tessellationEvaluationShaderGraph); |
| 62 | void setGeometryShaderGraph(const QUrl &geometryShaderGraph); |
| 63 | void setFragmentShaderGraph(const QUrl &fragmentShaderGraph); |
| 64 | void setComputeShaderGraph(const QUrl &computeShaderGraph); |
| 65 | |
| 66 | Q_SIGNALS: |
| 67 | void shaderProgramChanged(Qt3DRender::QShaderProgram *shaderProgram); |
| 68 | void enabledLayersChanged(const QStringList &layers); |
| 69 | void vertexShaderGraphChanged(const QUrl &vertexShaderGraph); |
| 70 | void tessellationControlShaderGraphChanged(const QUrl &tessellationControlShaderGraph); |
| 71 | void tessellationEvaluationShaderGraphChanged(const QUrl &tessellationEvaluationShaderGraph); |
| 72 | void geometryShaderGraphChanged(const QUrl &geometryShaderGraph); |
| 73 | void fragmentShaderGraphChanged(const QUrl &fragmentShaderGraph); |
| 74 | void computeShaderGraphChanged(const QUrl &computeShaderGraph); |
| 75 | Q_REVISION(13) void vertexShaderCodeChanged(const QByteArray &vertexShaderCode); |
| 76 | Q_REVISION(13) void tessellationControlShaderCodeChanged(const QByteArray &tessellationControlShaderCode); |
| 77 | Q_REVISION(13) void tessellationEvaluationShaderCodeChanged(const QByteArray &tessellationEvaluationShaderCode); |
| 78 | Q_REVISION(13) void geometryShaderCodeChanged(const QByteArray &geometryShaderCode); |
| 79 | Q_REVISION(13) void fragmentShaderCodeChanged(const QByteArray &fragmentShaderCode); |
| 80 | Q_REVISION(13) void computeShaderCodeChanged(const QByteArray &computeShaderCode); |
| 81 | |
| 82 | protected: |
| 83 | explicit QShaderProgramBuilder(QShaderProgramBuilderPrivate &dd, Qt3DCore::QNode *parent = nullptr); |
| 84 | |
| 85 | private: |
| 86 | Q_DECLARE_PRIVATE(QShaderProgramBuilder) |
| 87 | }; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | QT_END_NAMESPACE |
| 92 | |
| 93 | #endif // QT3DRENDER_QSHADERPROGRAMBUILDER_H |
| 94 | |