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:GPL-EXCEPT$ |
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 General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | // TODO Remove in Qt6 |
30 | #include <QtCore/qcompilerdetection.h> |
31 | QT_WARNING_DISABLE_DEPRECATED |
32 | |
33 | #include <QtTest/QTest> |
34 | #include <Qt3DRender/qtextureimagedata.h> |
35 | #include <Qt3DRender/private/qtexture_p.h> |
36 | |
37 | class tst_KtxTextures : public QObject |
38 | { |
39 | Q_OBJECT |
40 | |
41 | private slots: |
42 | void ktxImageData(); |
43 | }; |
44 | |
45 | void tst_KtxTextures::ktxImageData() |
46 | { |
47 | const struct TextureInfo { |
48 | const char *source; |
49 | int width; |
50 | int height; |
51 | int depth; |
52 | int faces; |
53 | int mipmapLevels; |
54 | QOpenGLTexture::TextureFormat format; |
55 | } textures[] = { |
56 | { .source: "data/16_16_PNG_ASTC_7.KTX" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_ASTC_4x4 }, |
57 | { .source: "data/16_16_PNG_ASTC_8.KTX" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_ASTC_4x4 }, |
58 | { .source: "data/16_16_PNG_ETC2_RGB_13.KTX" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGB8_ETC2 }, |
59 | { .source: "data/16_16_PNG_ETC2_RGBA_11.KTX" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA8_ETC2_EAC }, |
60 | { .source: "data/16_16_PNG_ETC_RGB_12.KTX" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGB8_ETC1 }, |
61 | }; |
62 | |
63 | for (unsigned i = 0; i < sizeof(textures)/sizeof(*textures); i++) { |
64 | const TextureInfo *texture = &textures[i]; |
65 | |
66 | Qt3DRender::QTextureImageDataPtr data = Qt3DRender::TextureLoadingHelper::loadTextureData(source: QUrl::fromLocalFile(QFINDTESTDATA(texture->source)), allow3D: true, mirrored: false); |
67 | |
68 | QVERIFY(data); |
69 | QCOMPARE(data->width(), texture->width); |
70 | QCOMPARE(data->height(), texture->height); |
71 | QCOMPARE(data->faces(), texture->faces); |
72 | QCOMPARE(data->mipLevels(), texture->mipmapLevels); |
73 | QCOMPARE(data->format(), texture->format); |
74 | } |
75 | } |
76 | |
77 | QTEST_APPLESS_MAIN(tst_KtxTextures) |
78 | |
79 | #include "tst_ktxtextures.moc" |
80 | |