1/****************************************************************************
2**
3** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QT3DRENDER_QSHADERIMAGE_H
41#define QT3DRENDER_QSHADERIMAGE_H
42
43#include <Qt3DCore/qnode.h>
44#include <Qt3DRender/qt3drender_global.h>
45
46QT_BEGIN_NAMESPACE
47
48namespace Qt3DRender {
49
50class QAbstractTexture;
51class QShaderImagePrivate;
52
53class Q_3DRENDERSHARED_EXPORT QShaderImage : public Qt3DCore::QNode
54{
55 Q_OBJECT
56 Q_PROPERTY(Qt3DRender::QAbstractTexture *texture READ texture WRITE setTexture NOTIFY textureChanged)
57 Q_PROPERTY(bool layered READ layered WRITE setLayered NOTIFY layeredChanged)
58 Q_PROPERTY(int mipLevel READ mipLevel WRITE setMipLevel NOTIFY mipLevelChanged)
59 Q_PROPERTY(int layer READ layer WRITE setLayer NOTIFY layerChanged)
60 Q_PROPERTY(Access access READ access WRITE setAccess NOTIFY accessChanged)
61 Q_PROPERTY(ImageFormat format READ format WRITE setFormat NOTIFY formatChanged)
62
63public:
64 enum Access {
65 ReadOnly = 0,
66 WriteOnly,
67 ReadWrite
68 };
69 Q_ENUM(Access)
70
71 enum ImageFormat {
72 NoFormat = 0, // GL_NONE
73 Automatic = 1, // The Qt3D engine automatically determines the best format
74
75 // Unsigned normalized formats
76 R8_UNorm = 0x8229, // GL_R8
77 RG8_UNorm = 0x822B, // GL_RG8
78 RGBA8_UNorm = 0x8058, // GL_RGBA8
79
80 R16_UNorm = 0x822A, // GL_R16
81 RG16_UNorm = 0x822C, // GL_RG16
82 RGBA16_UNorm = 0x805B, // GL_RGBA16
83
84 // Signed normalized formats
85 R8_SNorm = 0x8F94, // GL_R8_SNORM
86 RG8_SNorm = 0x8F95, // GL_RG8_SNORM
87 RGBA8_SNorm = 0x8F97, // GL_RGBA8_SNORM
88
89 R16_SNorm = 0x8F98, // GL_R16_SNORM
90 RG16_SNorm = 0x8F99, // GL_RG16_SNORM
91 RGBA16_SNorm = 0x8F9B, // GL_RGBA16_SNORM
92
93 // Unsigned integer formats
94 R8U = 0x8232, // GL_R8UI
95 RG8U = 0x8238, // GL_RG8UI
96 RGBA8U = 0x8D7C, // GL_RGBA8UI
97
98 R16U = 0x8234, // GL_R16UI
99 RG16U = 0x823A, // GL_RG16UI
100 RGBA16U = 0x8D76, // GL_RGBA16UI
101
102 R32U = 0x8236, // GL_R32UI
103 RG32U = 0x823C, // GL_RG32UI
104 RGBA32U = 0x8D70, // GL_RGBA32UI
105
106 // Signed integer formats
107 R8I = 0x8231, // GL_R8I
108 RG8I = 0x8237, // GL_RG8I
109 RGBA8I = 0x8D8E, // GL_RGBA8I
110
111 R16I = 0x8233, // GL_R16I
112 RG16I = 0x8239, // GL_RG16I
113 RGBA16I = 0x8D88, // GL_RGBA16I
114
115 R32I = 0x8235, // GL_R32I
116 RG32I = 0x823B, // GL_RG32I
117 RGBA32I = 0x8D82, // GL_RGBA32I
118
119 // Floating point formats
120 R16F = 0x822D, // GL_R16F
121 RG16F = 0x822F, // GL_RG16F
122 RGBA16F = 0x881A, // GL_RGBA16F
123
124 R32F = 0x822E, // GL_R32F
125 RG32F = 0x8230, // GL_RG32F
126 RGBA32F = 0x8814, // GL_RGBA32F
127
128 // Packed formats
129 RG11B10F = 0x8C3A, // GL_R11F_G11F_B10F
130 RGB10A2 = 0x8059, // GL_RGB10_A2
131 RGB10A2U = 0x906F, // GL_RGB10_A2_UI
132 };
133 Q_ENUM(ImageFormat)
134
135 explicit QShaderImage(Qt3DCore::QNode *parent = nullptr);
136 ~QShaderImage();
137
138 Qt3DRender::QAbstractTexture *texture() const;
139 bool layered() const;
140 int mipLevel() const;
141 int layer() const;
142 Access access() const;
143 ImageFormat format() const;
144
145public Q_SLOTS:
146 void setTexture(Qt3DRender::QAbstractTexture *texture);
147 void setLayered(bool layered);
148 void setMipLevel(int mipLevel);
149 void setLayer(int layer);
150 void setAccess(Access access);
151 void setFormat(ImageFormat format);
152
153Q_SIGNALS:
154 void textureChanged(Qt3DRender::QAbstractTexture *texture);
155 void layeredChanged(bool layered);
156 void mipLevelChanged(int mipLevel);
157 void layerChanged(int layer);
158 void accessChanged(Access access);
159 void formatChanged(ImageFormat format);
160
161private:
162 Q_DECLARE_PRIVATE(QShaderImage)
163 Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
164};
165
166} // namespace Qt3DRender
167
168QT_END_NAMESPACE
169
170#endif // QT3DRENDER_QSHADERIMAGE_H
171