| 1 | // Copyright (C) 2016 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 SCENE3DSGMATERIAL_H |
| 5 | #define SCENE3DSGMATERIAL_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 purely as an |
| 12 | // implementation detail. 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 <QtQuick/QSGMaterial> |
| 19 | #include <QtQuick/qsgtexture.h> |
| 20 | |
| 21 | #include <private/scene3dsgmaterialshader_p.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | namespace Qt3DRender { |
| 26 | |
| 27 | class Scene3DSGMaterial : public QSGMaterial |
| 28 | { |
| 29 | public: |
| 30 | Scene3DSGMaterial(); |
| 31 | |
| 32 | void setTexture(QSGTexture *texture) |
| 33 | { |
| 34 | m_texture = texture; |
| 35 | setFlag(flags: Blending, on: m_texture ? m_texture->hasAlphaChannel() : false); |
| 36 | } |
| 37 | |
| 38 | QSGTexture *texture() const noexcept { return m_texture; } |
| 39 | QSGMaterialType *type() const final { return &Scene3DSGMaterialShader::type; } |
| 40 | QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const final; |
| 41 | |
| 42 | void show() { m_visible = true; } |
| 43 | bool visible() const { return m_visible; } |
| 44 | |
| 45 | private: |
| 46 | QSGTexture *m_texture; |
| 47 | bool m_visible; |
| 48 | }; |
| 49 | |
| 50 | } // namespace Qt3DRender |
| 51 | |
| 52 | QT_END_NAMESPACE |
| 53 | |
| 54 | #endif // SCENE3DSGMATERIAL_H |
| 55 | |