Debian Codegraph @

tests/auto/render/ddstextures/tst_ddstextures.cpp

raw symbols SCIP
1 // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 // TODO Remove in Qt6
5 #include <QtCore/qcompilerdetection.h>
6 QT_WARNING_DISABLE_DEPRECATED
7
8 #include <QtTest/QTest>
9 #include <Qt3DRender/qtextureimagedata.h>
10 #include <Qt3DRender/private/qtexture_p.h>
11
12 class tst_DdsTextures : public QObject
13 {
14 Q_OBJECT
15
16 private slots:
17 void ddsImageData();
18 };
19
20 void tst_DdsTextures::ddsImageData()
21 {
22 const struct TextureInfo {
23 const char *source;
24 int width;
25 int height;
26 int depth;
27 int faces;
28 int mipmapLevels;
29 QOpenGLTexture::TextureFormat format;
30 } textures[] = {
31 { "data/16x16x1-1-lumi-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::R8_UNorm },
32 { "data/16x16x1-1-lumi.dds", 16, 16, 1, 1, 5, QOpenGLTexture::R8_UNorm },
33 { "data/16x16x1-1-rgb-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA8_UNorm },
34 { "data/16x16x1-1-rgb.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA8_UNorm },
35 { "data/16x16x1-1-bc1-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT1 },
36 { "data/16x16x1-1-bc1.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT1 },
37 { "data/16x16x1-1-bc3-nomips.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT5 },
38 { "data/16x16x1-1-bc3.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT5 },
39 { "data/16x16x1-1-bc1-nomips-dx10.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT1 },
40 { "data/16x16x1-1-bc1-dx10.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT1 },
41 { "data/16x16x1-1-bc3-nomips-dx10.dds", 16, 16, 1, 1, 1, QOpenGLTexture::RGBA_DXT5 },
42 { "data/16x16x1-1-bc3-dx10.dds", 16, 16, 1, 1, 5, QOpenGLTexture::RGBA_DXT5 },
43 { "data/16x16x1-6-lumi-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::R8_UNorm },
44 { "data/16x16x1-6-lumi.dds", 16, 16, 1, 6, 5, QOpenGLTexture::R8_UNorm },
45 { "data/16x16x1-6-rgb-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA8_UNorm },
46 { "data/16x16x1-6-rgb.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA8_UNorm },
47 { "data/16x16x1-6-bc1-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT1 },
48 { "data/16x16x1-6-bc1.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT1 },
49 { "data/16x16x1-6-bc3-nomips.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT5 },
50 { "data/16x16x1-6-bc3.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT5 },
51 { "data/16x16x1-6-bc1-nomips-dx10.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT1 },
52 { "data/16x16x1-6-bc1-dx10.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT1 },
53 { "data/16x16x1-6-bc3-nomips-dx10.dds", 16, 16, 1, 6, 1, QOpenGLTexture::RGBA_DXT5 },
54 { "data/16x16x1-6-bc3-dx10.dds", 16, 16, 1, 6, 5, QOpenGLTexture::RGBA_DXT5 },
55 { "data/16x16-etc1.pkm", 16, 16, 1, 1, 1, QOpenGLTexture::RGB8_ETC1 },
56 { "data/16x16-etc2.pkm", 16, 16, 1, 1, 1, QOpenGLTexture::RGB8_ETC2 },
57 };
58
59 for (unsigned i = 0; i < sizeof(textures)/sizeof(*textures); i++) {
60 const TextureInfo *texture = &textures[i];
61
62 Qt3DRender::QTextureImageDataPtr data = Qt3DRender::TextureLoadingHelper::loadTextureData(QUrl::fromLocalFile(QFINDTESTDATA(texture->source)), true, false);
63
64 QVERIFY(data);
65 QCOMPARE(data->width(), texture->width);
66 QCOMPARE(data->height(), texture->height);
67 QCOMPARE(data->faces(), texture->faces);
68 QCOMPARE(data->mipLevels(), texture->mipmapLevels);
69 QCOMPARE(data->format(), texture->format);
70 }
71 }
72
73 QTEST_APPLESS_MAIN(tst_DdsTextures)
74
75 #include "tst_ddstextures.moc"