1// Copyright (C) 2014 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_TEXTUREIMAGEDATA_H
5#define QT3DRENDER_TEXTUREIMAGEDATA_H
6
7#include <Qt3DRender/qt3drender_global.h>
8#include <QtOpenGL/qopengltexture.h>
9#include <QtGui/QImage>
10#include <QtCore/QSharedPointer>
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DRender {
15
16class QTextureImageDataPrivate;
17
18class Q_3DRENDERSHARED_EXPORT QTextureImageData
19{
20public:
21 QTextureImageData();
22 ~QTextureImageData();
23
24 QTextureImageData &operator=(const QTextureImageData &other);
25
26 void cleanup() noexcept;
27
28 bool isCompressed() const noexcept;
29
30 int width() const noexcept;
31 int height() const noexcept;
32 int depth() const noexcept;
33
34 int layers() const noexcept;
35 int mipLevels() const noexcept;
36 int faces() const noexcept;
37
38 void setWidth(int width) noexcept;
39 void setHeight(int height) noexcept;
40 void setDepth(int depth) noexcept;
41
42 void setLayers(int layers) noexcept;
43 void setMipLevels(int mipLevels) noexcept;
44 void setFaces(int faces) noexcept;
45
46 int alignment() const noexcept;
47 void setAlignment(int alignment) noexcept;
48
49 QOpenGLTexture::Target target() const noexcept;
50 QOpenGLTexture::TextureFormat format() const noexcept;
51
52 QOpenGLTexture::PixelFormat pixelFormat() const noexcept;
53 QOpenGLTexture::PixelType pixelType() const noexcept;
54
55 void setTarget(QOpenGLTexture::Target target) noexcept;
56 void setFormat(QOpenGLTexture::TextureFormat format) noexcept;
57
58 void setPixelFormat(QOpenGLTexture::PixelFormat pixelFormat) noexcept;
59 void setPixelType(QOpenGLTexture::PixelType pixelType) noexcept;
60
61 void setImage(const QImage &);
62 void setData(const QByteArray &data,
63 int blockSize,
64 bool isCompressed = false);
65
66 void setData(const QByteArray &data,
67 std::function<QByteArray(QByteArray rawData, int layer, int face, int mipmapLevel)>,
68 bool isCompressed = false);
69
70 QByteArray data(int layer = 0, int face = 0, int mipmapLevel = 0) const;
71protected:
72 QTextureImageData(QTextureImageDataPrivate &dd);
73
74private:
75 Q_DECLARE_PRIVATE(QTextureImageData)
76 QTextureImageDataPrivate *d_ptr;
77};
78
79typedef QSharedPointer<QTextureImageData> QTextureImageDataPtr;
80
81} // namespace Qt3DRender
82
83
84QT_END_NAMESPACE
85
86#endif // QT3DRENDER_TEXTUREIMAGEDATA_H
87

source code of qt3d/src/render/texture/qtextureimagedata.h