summaryrefslogtreecommitdiffstats
path: root/src/render/texture/qtextureimagedata.h
blob: b8c3a3e0125dc00616b457de84b18bbb667dca84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/****************************************************************************
**
** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
****************************************************************************/

#ifndef QT3DRENDER_TEXTUREIMAGEDATA_H
#define QT3DRENDER_TEXTUREIMAGEDATA_H

#include <Qt3DRender/qt3drender_global.h>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#  include <QOpenGLTexture>
#else
#  include <QtGui/qopengltexture.h>
#endif
#include <QtGui/QImage>
#include <QtCore/QSharedPointer>

QT_BEGIN_NAMESPACE

namespace Qt3DRender {

class QTextureImageDataPrivate;

class Q_3DRENDERSHARED_EXPORT QTextureImageData
{
public:
    QTextureImageData();
    ~QTextureImageData();

    QTextureImageData &operator=(const QTextureImageData &other);

    void cleanup() Q_DECL_NOTHROW;

    bool isCompressed() const Q_DECL_NOTHROW;

    int width() const Q_DECL_NOTHROW;
    int height() const Q_DECL_NOTHROW;
    int depth() const Q_DECL_NOTHROW;

    int layers() const Q_DECL_NOTHROW;
    int mipLevels() const Q_DECL_NOTHROW;
    int faces() const Q_DECL_NOTHROW;

    void setWidth(int width) Q_DECL_NOTHROW;
    void setHeight(int height) Q_DECL_NOTHROW;
    void setDepth(int depth) Q_DECL_NOTHROW;

    void setLayers(int layers) Q_DECL_NOTHROW;
    void setMipLevels(int mipLevels) Q_DECL_NOTHROW;
    void setFaces(int faces) Q_DECL_NOTHROW;

    QOpenGLTexture::Target target() const Q_DECL_NOTHROW;
    QOpenGLTexture::TextureFormat format() const Q_DECL_NOTHROW;

    QOpenGLTexture::PixelFormat pixelFormat() const Q_DECL_NOTHROW;
    QOpenGLTexture::PixelType pixelType() const Q_DECL_NOTHROW;

    void setTarget(QOpenGLTexture::Target target) Q_DECL_NOTHROW;
    void setFormat(QOpenGLTexture::TextureFormat format) Q_DECL_NOTHROW;

    void setPixelFormat(QOpenGLTexture::PixelFormat pixelFormat) Q_DECL_NOTHROW;
    void setPixelType(QOpenGLTexture::PixelType pixelType) Q_DECL_NOTHROW;

    void setImage(const QImage &);
    void setData(const QByteArray &data,
                 int blockSize,
                 bool isCompressed = false);

    QByteArray data(int layer = 0, int face = 0, int mipmapLevel = 0) const;
protected:
    QTextureImageData(QTextureImageDataPrivate &dd);

private:
    Q_DECLARE_PRIVATE(QTextureImageData)
    QTextureImageDataPrivate *d_ptr;
};

typedef QSharedPointer<QTextureImageData> QTextureImageDataPtr;

} // namespace Qt3DRender


QT_END_NAMESPACE

#endif // QT3DRENDER_TEXTUREIMAGEDATA_H