1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 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_DdsTextures : public QObject |
38 | { |
39 | Q_OBJECT |
40 | |
41 | private slots: |
42 | void ddsImageData(); |
43 | }; |
44 | |
45 | void tst_DdsTextures::ddsImageData() |
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/16x16x1-1-lumi-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::R8_UNorm }, |
57 | { .source: "data/16x16x1-1-lumi.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 5, .format: QOpenGLTexture::R8_UNorm }, |
58 | { .source: "data/16x16x1-1-rgb-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA8_UNorm }, |
59 | { .source: "data/16x16x1-1-rgb.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA8_UNorm }, |
60 | { .source: "data/16x16x1-1-bc1-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT1 }, |
61 | { .source: "data/16x16x1-1-bc1.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT1 }, |
62 | { .source: "data/16x16x1-1-bc3-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT5 }, |
63 | { .source: "data/16x16x1-1-bc3.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT5 }, |
64 | { .source: "data/16x16x1-1-bc1-nomips-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT1 }, |
65 | { .source: "data/16x16x1-1-bc1-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT1 }, |
66 | { .source: "data/16x16x1-1-bc3-nomips-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT5 }, |
67 | { .source: "data/16x16x1-1-bc3-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT5 }, |
68 | { .source: "data/16x16x1-6-lumi-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 1, .format: QOpenGLTexture::R8_UNorm }, |
69 | { .source: "data/16x16x1-6-lumi.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 5, .format: QOpenGLTexture::R8_UNorm }, |
70 | { .source: "data/16x16x1-6-rgb-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA8_UNorm }, |
71 | { .source: "data/16x16x1-6-rgb.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA8_UNorm }, |
72 | { .source: "data/16x16x1-6-bc1-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT1 }, |
73 | { .source: "data/16x16x1-6-bc1.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT1 }, |
74 | { .source: "data/16x16x1-6-bc3-nomips.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT5 }, |
75 | { .source: "data/16x16x1-6-bc3.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT5 }, |
76 | { .source: "data/16x16x1-6-bc1-nomips-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT1 }, |
77 | { .source: "data/16x16x1-6-bc1-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT1 }, |
78 | { .source: "data/16x16x1-6-bc3-nomips-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 1, .format: QOpenGLTexture::RGBA_DXT5 }, |
79 | { .source: "data/16x16x1-6-bc3-dx10.dds" , .width: 16, .height: 16, .depth: 1, .faces: 6, .mipmapLevels: 5, .format: QOpenGLTexture::RGBA_DXT5 }, |
80 | { .source: "data/16x16-etc1.pkm" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGB8_ETC1 }, |
81 | { .source: "data/16x16-etc2.pkm" , .width: 16, .height: 16, .depth: 1, .faces: 1, .mipmapLevels: 1, .format: QOpenGLTexture::RGB8_ETC2 }, |
82 | }; |
83 | |
84 | for (unsigned i = 0; i < sizeof(textures)/sizeof(*textures); i++) { |
85 | const TextureInfo *texture = &textures[i]; |
86 | |
87 | Qt3DRender::QTextureImageDataPtr data = Qt3DRender::TextureLoadingHelper::loadTextureData(source: QUrl::fromLocalFile(QFINDTESTDATA(texture->source)), allow3D: true, mirrored: false); |
88 | |
89 | QVERIFY(data); |
90 | QCOMPARE(data->width(), texture->width); |
91 | QCOMPARE(data->height(), texture->height); |
92 | QCOMPARE(data->faces(), texture->faces); |
93 | QCOMPARE(data->mipLevels(), texture->mipmapLevels); |
94 | QCOMPARE(data->format(), texture->format); |
95 | } |
96 | } |
97 | |
98 | QTEST_APPLESS_MAIN(tst_DdsTextures) |
99 | |
100 | #include "tst_ddstextures.moc" |
101 | |