1// Copyright (C) 2019 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_QSHADERIMAGE_H
5#define QT3DRENDER_QSHADERIMAGE_H
6
7#include <Qt3DCore/qnode.h>
8#include <Qt3DRender/qt3drender_global.h>
9#include <Qt3DRender/qabstracttexture.h>
10
11QT_BEGIN_NAMESPACE
12
13namespace Qt3DRender {
14
15class QShaderImagePrivate;
16
17class Q_3DRENDERSHARED_EXPORT QShaderImage : public Qt3DCore::QNode
18{
19 Q_OBJECT
20 Q_PROPERTY(Qt3DRender::QAbstractTexture *texture READ texture WRITE setTexture NOTIFY textureChanged)
21 Q_PROPERTY(bool layered READ layered WRITE setLayered NOTIFY layeredChanged)
22 Q_PROPERTY(int mipLevel READ mipLevel WRITE setMipLevel NOTIFY mipLevelChanged)
23 Q_PROPERTY(int layer READ layer WRITE setLayer NOTIFY layerChanged)
24 Q_PROPERTY(Access access READ access WRITE setAccess NOTIFY accessChanged)
25 Q_PROPERTY(ImageFormat format READ format WRITE setFormat NOTIFY formatChanged)
26
27public:
28 enum Access {
29 ReadOnly = 0,
30 WriteOnly,
31 ReadWrite
32 };
33 Q_ENUM(Access)
34
35 enum ImageFormat {
36 NoFormat = 0, // GL_NONE
37 Automatic = 1, // The Qt3D engine automatically determines the best format
38
39 // Unsigned normalized formats
40 R8_UNorm = 0x8229, // GL_R8
41 RG8_UNorm = 0x822B, // GL_RG8
42 RGBA8_UNorm = 0x8058, // GL_RGBA8
43
44 R16_UNorm = 0x822A, // GL_R16
45 RG16_UNorm = 0x822C, // GL_RG16
46 RGBA16_UNorm = 0x805B, // GL_RGBA16
47
48 // Signed normalized formats
49 R8_SNorm = 0x8F94, // GL_R8_SNORM
50 RG8_SNorm = 0x8F95, // GL_RG8_SNORM
51 RGBA8_SNorm = 0x8F97, // GL_RGBA8_SNORM
52
53 R16_SNorm = 0x8F98, // GL_R16_SNORM
54 RG16_SNorm = 0x8F99, // GL_RG16_SNORM
55 RGBA16_SNorm = 0x8F9B, // GL_RGBA16_SNORM
56
57 // Unsigned integer formats
58 R8U = 0x8232, // GL_R8UI
59 RG8U = 0x8238, // GL_RG8UI
60 RGBA8U = 0x8D7C, // GL_RGBA8UI
61
62 R16U = 0x8234, // GL_R16UI
63 RG16U = 0x823A, // GL_RG16UI
64 RGBA16U = 0x8D76, // GL_RGBA16UI
65
66 R32U = 0x8236, // GL_R32UI
67 RG32U = 0x823C, // GL_RG32UI
68 RGBA32U = 0x8D70, // GL_RGBA32UI
69
70 // Signed integer formats
71 R8I = 0x8231, // GL_R8I
72 RG8I = 0x8237, // GL_RG8I
73 RGBA8I = 0x8D8E, // GL_RGBA8I
74
75 R16I = 0x8233, // GL_R16I
76 RG16I = 0x8239, // GL_RG16I
77 RGBA16I = 0x8D88, // GL_RGBA16I
78
79 R32I = 0x8235, // GL_R32I
80 RG32I = 0x823B, // GL_RG32I
81 RGBA32I = 0x8D82, // GL_RGBA32I
82
83 // Floating point formats
84 R16F = 0x822D, // GL_R16F
85 RG16F = 0x822F, // GL_RG16F
86 RGBA16F = 0x881A, // GL_RGBA16F
87
88 R32F = 0x822E, // GL_R32F
89 RG32F = 0x8230, // GL_RG32F
90 RGBA32F = 0x8814, // GL_RGBA32F
91
92 // Packed formats
93 RG11B10F = 0x8C3A, // GL_R11F_G11F_B10F
94 RGB10A2 = 0x8059, // GL_RGB10_A2
95 RGB10A2U = 0x906F, // GL_RGB10_A2_UI
96 };
97 Q_ENUM(ImageFormat)
98
99 explicit QShaderImage(Qt3DCore::QNode *parent = nullptr);
100 ~QShaderImage();
101
102 Qt3DRender::QAbstractTexture *texture() const;
103 bool layered() const;
104 int mipLevel() const;
105 int layer() const;
106 Access access() const;
107 ImageFormat format() const;
108
109public Q_SLOTS:
110 void setTexture(Qt3DRender::QAbstractTexture *texture);
111 void setLayered(bool layered);
112 void setMipLevel(int mipLevel);
113 void setLayer(int layer);
114 void setAccess(Access access);
115 void setFormat(ImageFormat format);
116
117Q_SIGNALS:
118 void textureChanged(Qt3DRender::QAbstractTexture *texture);
119 void layeredChanged(bool layered);
120 void mipLevelChanged(int mipLevel);
121 void layerChanged(int layer);
122 void accessChanged(Access access);
123 void formatChanged(ImageFormat format);
124
125private:
126 Q_DECLARE_PRIVATE(QShaderImage)
127};
128
129} // namespace Qt3DRender
130
131QT_END_NAMESPACE
132
133#endif // QT3DRENDER_QSHADERIMAGE_H
134

source code of qt3d/src/render/materialsystem/qshaderimage.h