diff options
author | Janne Kangas <janne.kangas@qt.io> | 2020-02-07 11:32:25 +0200 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2020-02-11 14:40:05 +0200 |
commit | 7ee97f3489bb1cba4095e58d4aa5241de772dc7b (patch) | |
tree | 6bacb9a0ae6aa385fd69d7915f1174e82188a13b /tests | |
parent | 2dff84fddcffde95e882faceb45d5797dc5c63b9 (diff) |
Add size and format to textureid query
Returns texture size and format for layer and material textures. Add
corresponding test.
Task-id: QT3DS-4005
Change-Id: I773715712dc78cf511f6c4d0095f5491834df311
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp | 60 | ||||
-rw-r--r-- | tests/auto/studio3d/shared/maps/OpenfootageNET_garage-512.hdr | bin | 0 -> 422659 bytes | |||
-rw-r--r-- | tests/auto/studio3d/shared/shared_presentations.qrc | 1 |
3 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp index a4b5aa2..7dcf254 100644 --- a/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp +++ b/tests/auto/studio3d/q3dssurfaceviewer/tst_q3dssurfaceviewer.cpp @@ -85,6 +85,8 @@ private slots: void testMouseInput(); void testDataInput_data(); void testDataInput(); + void testTextureQuery(); + void testTextureQuery_data(); private: QWindow *createWindow(const QSize &size); @@ -1507,6 +1509,64 @@ void tst_Q3DSSurfaceViewer::testDataInput() delete slideInput; } +void tst_Q3DSSurfaceViewer::testTextureQuery_data() +{ + testBasics_data(); +} + +void tst_Q3DSSurfaceViewer::testTextureQuery() +{ + QFETCH(bool, isWindow); + + if (isWindow) + createWindowAndViewer(m_viewer, DATAINPUT); + else + createOffscreenAndViewer(m_viewer, DATAINPUT); + + m_viewer->settings()->setScaleMode(Q3DSViewerSettings::ScaleModeFill); + + QGuiApplication::processEvents(); + // Test texture info getters, first for layer then for individual material. + // Texture id's are likely to change if test ordering changes. + QSize texsize; + GLenum format; + + uint textureid = m_viewer->presentation()->textureId("Scene.Layer", texsize, format); + if (isWindow) + QCOMPARE(textureid, 6); + else + QCOMPARE(textureid, 7); + + QCOMPARE(texsize, QSize(300,200)); + QCOMPARE(format, GL_RGBA8); + + textureid = m_viewer->presentation()->textureId("Scene.Layer.Rectangle.Default.diffusemap", + texsize, format); + if (isWindow) + QCOMPARE(textureid, 1); + else + QCOMPARE(textureid, 2); + QCOMPARE(texsize, QSize(400,200)); + QCOMPARE(format, GL_RGBA8); + + m_viewer->presentation()->setAttribute("Scene.Layer.Rectangle.Default.diffusemap", + "subpresentation", ""); + m_viewer->presentation()->setAttribute("Scene.Layer.Rectangle.Default.diffusemap", "sourcepath", + "maps/OpenfootageNET_garage-512.hdr"); + + QGuiApplication::processEvents(); + + // Changed to HDR texture, studio-internally RGB8E but texture query should map to GL RGBA8 + textureid = m_viewer->presentation()->textureId("Scene.Layer.Rectangle.Default.diffusemap", + texsize, format); + if (isWindow) + QCOMPARE(textureid, 8); + else + QCOMPARE(textureid, 9); + + QCOMPARE(texsize, QSize(512,256)); + QCOMPARE(format, GL_RGBA8); +} QTEST_MAIN(tst_Q3DSSurfaceViewer) diff --git a/tests/auto/studio3d/shared/maps/OpenfootageNET_garage-512.hdr b/tests/auto/studio3d/shared/maps/OpenfootageNET_garage-512.hdr Binary files differnew file mode 100644 index 0000000..015b478 --- /dev/null +++ b/tests/auto/studio3d/shared/maps/OpenfootageNET_garage-512.hdr diff --git a/tests/auto/studio3d/shared/shared_presentations.qrc b/tests/auto/studio3d/shared/shared_presentations.qrc index d4bb668..25dd40e 100644 --- a/tests/auto/studio3d/shared/shared_presentations.qrc +++ b/tests/auto/studio3d/shared/shared_presentations.qrc @@ -11,5 +11,6 @@ <file alias="datainput.uip">presentation/datainput.uip</file> <file alias="datainput.uia">presentation/datainput.uia</file> <file alias="datainput_sub.uip">presentation/datainput_sub.uip</file> + <file>maps/OpenfootageNET_garage-512.hdr</file> </qresource> </RCC> |