1 | // Copyright (C) 2016 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 QT3DEXTRAS_QTEXTUREATLAS_P_H |
5 | #define QT3DEXTRAS_QTEXTUREATLAS_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists for the convenience |
12 | // of other Qt classes. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <Qt3DExtras/qt3dextras_global.h> |
19 | #include <Qt3DRender/qabstracttexture.h> |
20 | #include <private/qglobal_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | namespace Qt3DExtras { |
25 | |
26 | class QTextureAtlasPrivate; |
27 | |
28 | class QTextureAtlas : public Qt3DRender::QAbstractTexture |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | typedef int TextureId; |
34 | static constexpr TextureId InvalidTexture = -1; |
35 | |
36 | QTextureAtlas(Qt3DCore::QNode *parent = nullptr); |
37 | ~QTextureAtlas(); |
38 | |
39 | QOpenGLTexture::PixelFormat pixelFormat() const; |
40 | void setPixelFormat(QOpenGLTexture::PixelFormat fmt); |
41 | |
42 | TextureId addImage(const QImage &image, int padding); |
43 | void removeImage(TextureId id); |
44 | |
45 | qsizetype imageCount() const; |
46 | |
47 | bool hasImage(TextureId id) const; |
48 | QRect imagePosition(TextureId id) const; |
49 | QRectF imageTexCoords(TextureId id) const; |
50 | int imagePadding(TextureId id) const; |
51 | |
52 | private: |
53 | Q_DECLARE_PRIVATE(QTextureAtlas) |
54 | }; |
55 | |
56 | } // namespace Qt3DExtras |
57 | |
58 | QT_END_NAMESPACE |
59 | |
60 | #endif // QT3DEXTRAS_QTEXTUREATLAS_P_H |
61 |