Changeset View
Changeset View
Standalone View
Standalone View
src/scenegraph/shadowedrectanglematerial.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> | ||||
3 | * | ||||
4 | * SPDX-License-Identifier: LGPL-2.0-or-later | ||||
5 | */ | ||||
6 | | ||||
7 | #pragma once | ||||
8 | | ||||
9 | #include <QSGMaterial> | ||||
10 | #include <QSGMaterialShader> | ||||
11 | | ||||
12 | class ShadowedRectangleMaterial : public QSGMaterial | ||||
13 | { | ||||
14 | public: | ||||
15 | ShadowedRectangleMaterial(); | ||||
16 | | ||||
17 | QSGMaterialShader* createShader() const override; | ||||
18 | QSGMaterialType* type() const override; | ||||
19 | int compare(const QSGMaterial* other) const override; | ||||
20 | | ||||
21 | QVector2D aspect = QVector2D{1.0, 1.0}; | ||||
22 | float size = 0.0; | ||||
23 | float radius = 0.0; | ||||
24 | QColor color = Qt::white; | ||||
25 | QColor shadowColor = Qt::black; | ||||
26 | QVector2D offset; | ||||
27 | }; | ||||
28 | | ||||
29 | class ElevatedRectangleShader : public QSGMaterialShader | ||||
30 | { | ||||
31 | public: | ||||
32 | ElevatedRectangleShader(); | ||||
33 | | ||||
34 | char const *const *attributeNames() const override; | ||||
35 | | ||||
36 | void initialize() override; | ||||
37 | void updateState(const QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; | ||||
38 | | ||||
39 | private: | ||||
40 | int m_matrixLocation = -1; | ||||
41 | int m_opacityLocation = -1; | ||||
42 | int m_aspectLocation = -1; | ||||
43 | int m_sizeLocation = -1; | ||||
44 | int m_radiusLocation = -1; | ||||
45 | int m_colorLocation = -1; | ||||
46 | int m_shadowColorLocation = -1; | ||||
47 | int m_offsetLocation = -1; | ||||
48 | }; |