Browse Source

Test: port file/image comparison tests to the new Utility::Path.

pull/556/head
Vladimír Vondruš 4 years ago
parent
commit
0001308d61
  1. 9
      src/Magnum/DebugTools/Test/ForceRendererGLTest.cpp
  2. 7
      src/Magnum/DebugTools/Test/ObjectRendererGLTest.cpp
  3. 24
      src/Magnum/DebugTools/Test/ScreenshotGLTest.cpp
  4. 1
      src/Magnum/GL/Test/RendererGLTest.cpp
  5. 33
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  6. 41
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  7. 71
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  8. 64
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  9. 72
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  10. 17
      src/Magnum/Shaders/Test/ShadersGLBenchmark.cpp
  11. 39
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  12. 26
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp
  13. 21
      src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp

9
src/Magnum/DebugTools/Test/ForceRendererGLTest.cpp

@ -24,8 +24,9 @@
*/ */
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Path.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -125,7 +126,7 @@ void ForceRendererGLTest::render2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}), framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "ForceRenderer2D.tga"), Utility::Path::join(DEBUGTOOLS_TEST_DIR, "ForceRenderer2D.tga"),
*comparator); *comparator);
} }
@ -173,12 +174,12 @@ void ForceRendererGLTest::render3D() {
CORRADE_EXPECT_FAIL("I'm unable to convince it to orient the arrowhead correctly in 3D."); CORRADE_EXPECT_FAIL("I'm unable to convince it to orient the arrowhead correctly in 3D.");
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}), framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "ForceRenderer2D.tga"), Utility::Path::join(DEBUGTOOLS_TEST_DIR, "ForceRenderer2D.tga"),
CompareImageToFile{_manager}); CompareImageToFile{_manager});
} }
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}), framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "ForceRenderer3D.tga"), Utility::Path::join(DEBUGTOOLS_TEST_DIR, "ForceRenderer3D.tga"),
CompareImageToFile{_manager}); CompareImageToFile{_manager});
} }

7
src/Magnum/DebugTools/Test/ObjectRendererGLTest.cpp

@ -24,8 +24,9 @@
*/ */
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Path.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -116,7 +117,7 @@ void ObjectRendererGLTest::render2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}), framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "ObjectRenderer2D.tga"), Utility::Path::join(DEBUGTOOLS_TEST_DIR, "ObjectRenderer2D.tga"),
/* SwiftShader misplaces two pixels here. Nothing serious. */ /* SwiftShader misplaces two pixels here. Nothing serious. */
(CompareImageToFile{_manager, 71.6f, 0.07f})); (CompareImageToFile{_manager, 71.6f, 0.07f}));
} }
@ -172,7 +173,7 @@ void ObjectRendererGLTest::render3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}), framebuffer.read({{}, {64, 64}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(DEBUGTOOLS_TEST_DIR, "ObjectRenderer3D.tga"), Utility::Path::join(DEBUGTOOLS_TEST_DIR, "ObjectRenderer3D.tga"),
*comparator); *comparator);
} }

24
src/Magnum/DebugTools/Test/ScreenshotGLTest.cpp

@ -25,10 +25,12 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove when screenshot() is <string>-free */
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
#include "Magnum/PixelFormat.h" #include "Magnum/PixelFormat.h"
@ -122,11 +124,11 @@ void ScreenshotGLTest::rgba8() {
CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete);
std::string file = Utility::Directory::join(SCREENSHOTTEST_SAVE_DIR, "image.tga"); Containers::String file = Utility::Path::join(SCREENSHOTTEST_SAVE_DIR, "image.tga");
if(Utility::Directory::exists(file)) if(Utility::Path::exists(file))
CORRADE_VERIFY(Utility::Directory::rm(file)); CORRADE_VERIFY(Utility::Path::remove(file));
else else
CORRADE_VERIFY(Utility::Directory::mkpath(SCREENSHOTTEST_SAVE_DIR)); CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR));
std::ostringstream out; std::ostringstream out;
bool succeeded; bool succeeded;
@ -179,11 +181,11 @@ void ScreenshotGLTest::r8() {
CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete); CORRADE_COMPARE(framebuffer.checkStatus(GL::FramebufferTarget::Read), GL::Framebuffer::Status::Complete);
std::string file = Utility::Directory::join(SCREENSHOTTEST_SAVE_DIR, "image.tga"); Containers::String file = Utility::Path::join(SCREENSHOTTEST_SAVE_DIR, "image.tga");
if(Utility::Directory::exists(file)) if(Utility::Path::exists(file))
CORRADE_VERIFY(Utility::Directory::rm(file)); CORRADE_VERIFY(Utility::Path::remove(file));
else else
CORRADE_VERIFY(Utility::Directory::mkpath(SCREENSHOTTEST_SAVE_DIR)); CORRADE_VERIFY(Utility::Path::make(SCREENSHOTTEST_SAVE_DIR));
std::ostringstream out; std::ostringstream out;
bool succeeded; bool succeeded;
@ -236,7 +238,7 @@ void ScreenshotGLTest::unknownFormat() {
bool succeeded; bool succeeded;
{ {
Error redirectOutput{&out}; Error redirectOutput{&out};
succeeded = DebugTools::screenshot(_converterManager, framebuffer, Utility::Directory::join(SCREENSHOTTEST_SAVE_DIR, "image.tga")); succeeded = DebugTools::screenshot(_converterManager, framebuffer, Utility::Path::join(SCREENSHOTTEST_SAVE_DIR, "image.tga"));
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -273,7 +275,7 @@ void ScreenshotGLTest::pluginLoadFailed() {
bool succeeded; bool succeeded;
{ {
Error redirectOutput{&out}; Error redirectOutput{&out};
succeeded = DebugTools::screenshot(manager, framebuffer, Utility::Directory::join(SCREENSHOTTEST_SAVE_DIR, "image.poo")); succeeded = DebugTools::screenshot(manager, framebuffer, Utility::Path::join(SCREENSHOTTEST_SAVE_DIR, "image.poo"));
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

1
src/Magnum/GL/Test/RendererGLTest.cpp

@ -30,6 +30,7 @@
#include <Corrade/Utility/Path.h> #include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */ #include <Corrade/Utility/System.h> /* isSandboxed() */
#endif #endif

33
src/Magnum/MeshTools/Test/CompileGLTest.cpp

@ -26,9 +26,10 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/EnumSet.h> #include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -515,7 +516,7 @@ template<class T> void CompileGLTest::twoDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/flat2D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/flat2D.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
} }
@ -527,7 +528,7 @@ template<class T> void CompileGLTest::twoDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/color2D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/color2D.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
} }
@ -541,7 +542,7 @@ template<class T> void CompileGLTest::twoDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured2D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured2D.tga"),
/* SwiftShader has some minor off-by-one precision differences, /* SwiftShader has some minor off-by-one precision differences,
llvmpipe as well */ llvmpipe as well */
(DebugTools::CompareImageToFile{_manager, 1.75f, 0.22f})); (DebugTools::CompareImageToFile{_manager, 1.75f, 0.22f}));
@ -758,7 +759,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/flat3D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/flat3D.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
} }
@ -775,7 +776,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.013f})); (DebugTools::CompareImageToFile{_manager, 0.5f, 0.013f}));
} }
@ -795,7 +796,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong-flat.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong-flat.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.012f})); (DebugTools::CompareImageToFile{_manager, 0.5f, 0.012f}));
} else if(data.flags & Flag::GeneratedSmoothNormals) { } else if(data.flags & Flag::GeneratedSmoothNormals) {
@ -810,7 +811,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong-smooth.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong-smooth.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.0088f})); (DebugTools::CompareImageToFile{_manager, 0.5f, 0.0088f}));
} }
@ -825,7 +826,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/color3D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/color3D.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.0162f})); (DebugTools::CompareImageToFile{_manager, 0.5f, 0.0162f}));
} }
@ -841,7 +842,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured3D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured3D.tga"),
/* SwiftShader has some minor off-by-one precision differences, /* SwiftShader has some minor off-by-one precision differences,
llvmpipe as well */ llvmpipe as well */
(DebugTools::CompareImageToFile{_manager, 2.0f, 0.256f})); (DebugTools::CompareImageToFile{_manager, 2.0f, 0.256f}));
@ -908,7 +909,7 @@ template<class T> void CompileGLTest::threeDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/tbn.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/tbn.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.0948f})); (DebugTools::CompareImageToFile{_manager, 1.0f, 0.0948f}));
#else #else
@ -973,7 +974,7 @@ void CompileGLTest::multipleAttributes() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured2D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured2D.tga"),
/* SwiftShader has some minor off-by-one precision differences, /* SwiftShader has some minor off-by-one precision differences,
llvmpipe as well */ llvmpipe as well */
(DebugTools::CompareImageToFile{_manager, 1.75f, 0.22f})); (DebugTools::CompareImageToFile{_manager, 1.75f, 0.22f}));
@ -1115,7 +1116,7 @@ void CompileGLTest::packedAttributes() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.013f})); (DebugTools::CompareImageToFile{_manager, 0.5f, 0.013f}));
@ -1127,7 +1128,7 @@ void CompileGLTest::packedAttributes() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/color3D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/color3D.tga"),
/* SwiftShader has some minor off-by-one precision differences */ /* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.0162f})); (DebugTools::CompareImageToFile{_manager, 0.5f, 0.0162f}));
@ -1140,7 +1141,7 @@ void CompileGLTest::packedAttributes() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured3D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/textured3D.tga"),
/* SwiftShader has some minor off-by-one precision differences, /* SwiftShader has some minor off-by-one precision differences,
llvmpipe more */ llvmpipe more */
(DebugTools::CompareImageToFile{_manager, 2.0f, 0.259f})); (DebugTools::CompareImageToFile{_manager, 2.0f, 0.259f}));
@ -1400,7 +1401,7 @@ void CompileGLTest::externalBuffers() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/flat2D.tga"), Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/flat2D.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
} }

41
src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp

@ -26,9 +26,16 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -333,13 +340,13 @@ DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation()); _testDir = Utility::Path::split(*Utility::Path::executableLocation()).first();
} else } else
#endif #endif
{ {
@ -673,7 +680,7 @@ template<DistanceFieldVectorGL2D::Flag flag> void DistanceFieldVectorGLTest::ren
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -720,7 +727,7 @@ template<DistanceFieldVectorGL2D::Flag flag> void DistanceFieldVectorGLTest::ren
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"), Utility::Path::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, 201.0f, 6.1f})); (DebugTools::CompareImageToFile{_manager, 201.0f, 6.1f}));
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
@ -734,7 +741,7 @@ template<DistanceFieldVectorGL2D::Flag flag> void DistanceFieldVectorGLTest::ren
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults-distancefield.tga"), Utility::Path::join(_testDir, "VectorTestFiles/defaults-distancefield.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -761,7 +768,7 @@ template<DistanceFieldVectorGL3D::Flag flag> void DistanceFieldVectorGLTest::ren
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -808,7 +815,7 @@ template<DistanceFieldVectorGL3D::Flag flag> void DistanceFieldVectorGLTest::ren
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"), Utility::Path::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, 201.0f, 6.1f})); (DebugTools::CompareImageToFile{_manager, 201.0f, 6.1f}));
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
@ -822,7 +829,7 @@ template<DistanceFieldVectorGL3D::Flag flag> void DistanceFieldVectorGLTest::ren
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults-distancefield.tga"), Utility::Path::join(_testDir, "VectorTestFiles/defaults-distancefield.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -852,7 +859,7 @@ template<DistanceFieldVectorGL2D::Flag flag> void DistanceFieldVectorGLTest::ren
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -930,7 +937,7 @@ template<DistanceFieldVectorGL2D::Flag flag> void DistanceFieldVectorGLTest::ren
const Float maxThreshold = 32.0f, meanThreshold = 2.386f; const Float maxThreshold = 32.0f, meanThreshold = 2.386f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "VectorTestFiles", data.file2D}), Utility::Path::join({_testDir, "VectorTestFiles", data.file2D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -960,7 +967,7 @@ template<DistanceFieldVectorGL3D::Flag flag> void DistanceFieldVectorGLTest::ren
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -1044,7 +1051,7 @@ template<DistanceFieldVectorGL3D::Flag flag> void DistanceFieldVectorGLTest::ren
const Float maxThreshold = 32.0f, meanThreshold = 1.613f; const Float maxThreshold = 32.0f, meanThreshold = 1.613f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "VectorTestFiles", data.file3D}), Utility::Path::join({_testDir, "VectorTestFiles", data.file3D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1084,7 +1091,7 @@ void DistanceFieldVectorGLTest::renderMulti2D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
GL::Texture2D vector; GL::Texture2D vector;
vector.setMinificationFilter(GL::SamplerFilter::Linear) vector.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
@ -1246,7 +1253,7 @@ void DistanceFieldVectorGLTest::renderMulti2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "VectorTestFiles", data.expected2D}), Utility::Path::join({_testDir, "VectorTestFiles", data.expected2D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
@ -1285,7 +1292,7 @@ void DistanceFieldVectorGLTest::renderMulti3D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
GL::Texture2D vector; GL::Texture2D vector;
vector.setMinificationFilter(GL::SamplerFilter::Linear) vector.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
@ -1452,7 +1459,7 @@ void DistanceFieldVectorGLTest::renderMulti3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "VectorTestFiles", data.expected3D}), Utility::Path::join({_testDir, "VectorTestFiles", data.expected3D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
#endif #endif

71
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -26,10 +26,17 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -150,7 +157,7 @@ struct FlatGLTest: GL::OpenGLTester {
private: private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"}; PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir; Containers::String _testDir;
GL::Renderbuffer _color{NoCreate}; GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -806,13 +813,13 @@ FlatGLTest::FlatGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation()); _testDir = Utility::Path::split(*Utility::Path::executableLocation()).first();
} else } else
#endif #endif
{ {
@ -1296,7 +1303,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"), Utility::Path::join(_testDir, "FlatTestFiles/defaults.tga"),
/* SwiftShader has 8 different pixels on the edges */ /* SwiftShader has 8 different pixels on the edges */
(DebugTools::CompareImageToFile{_manager, 238.0f, 0.2975f})); (DebugTools::CompareImageToFile{_manager, 238.0f, 0.2975f}));
} }
@ -1349,7 +1356,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"), Utility::Path::join(_testDir, "FlatTestFiles/defaults.tga"),
/* SwiftShader has 8 different pixels on the edges */ /* SwiftShader has 8 different pixels on the edges */
(DebugTools::CompareImageToFile{_manager, 238.0f, 0.2975f})); (DebugTools::CompareImageToFile{_manager, 238.0f, 0.2975f}));
} }
@ -1413,7 +1420,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderColored2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/colored2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1486,7 +1493,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderColored3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1613,7 +1620,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderSinglePixelTextured2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/colored2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1735,7 +1742,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderSinglePixelTextured3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1770,7 +1777,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderTextured2D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
FlatGL2D::Flags flags = data.flags|flag; FlatGL2D::Flags flags = data.flags|flag;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -1861,7 +1868,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderTextured2D() {
const Float maxThreshold = 15.667f, meanThreshold = 3.254f; const Float maxThreshold = 15.667f, meanThreshold = 3.254f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join(_testDir, "FlatTestFiles/textured2D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/textured2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1896,7 +1903,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderTextured3D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
FlatGL3D::Flags flags = data.flags|flag; FlatGL3D::Flags flags = data.flags|flag;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -1997,7 +2004,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderTextured3D() {
const Float maxThreshold = 139.0f, meanThreshold = 2.896f; const Float maxThreshold = 139.0f, meanThreshold = 2.896f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join(_testDir, "FlatTestFiles/textured3D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/textured3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2038,7 +2045,7 @@ template<class T, FlatGL2D::Flag flag> void FlatGLTest::renderVertexColor2D() {
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -2086,7 +2093,7 @@ template<class T, FlatGL2D::Flag flag> void FlatGLTest::renderVertexColor2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/vertexColor2D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/vertexColor2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2127,7 +2134,7 @@ template<class T, FlatGL2D::Flag flag> void FlatGLTest::renderVertexColor3D() {
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -2184,7 +2191,7 @@ template<class T, FlatGL2D::Flag flag> void FlatGLTest::renderVertexColor3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/vertexColor3D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/vertexColor3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2226,7 +2233,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderAlpha2D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
GL::Texture2D texture; GL::Texture2D texture;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join({_testDir, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -2284,7 +2291,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderAlpha2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, data.expected2D), Utility::Path::join(_testDir, data.expected2D),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2312,7 +2319,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderAlpha3D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
GL::Texture2D texture; GL::Texture2D texture;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join({_testDir, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -2391,7 +2398,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderAlpha3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, data.expected3D}), Utility::Path::join({_testDir, data.expected3D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2545,7 +2552,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderObjectId2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/colored2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels /* Object ID -- no need to verify the whole image, just check that pixels
@ -2694,7 +2701,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderObjectId3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"), Utility::Path::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels /* Object ID -- no need to verify the whole image, just check that pixels
@ -2815,7 +2822,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderInstanced2D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/* For arrays we upload three slices of the original image to half-high /* For arrays we upload three slices of the original image to half-high
@ -3003,7 +3010,7 @@ template<FlatGL2D::Flag flag> void FlatGLTest::renderInstanced2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "FlatTestFiles", data.expected2D}), Utility::Path::join({_testDir, "FlatTestFiles", data.expected2D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -3128,7 +3135,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderInstanced3D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/* For arrays we upload three slices of the original image to half-high /* For arrays we upload three slices of the original image to half-high
@ -3319,7 +3326,7 @@ template<FlatGL3D::Flag flag> void FlatGLTest::renderInstanced3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "FlatTestFiles", data.expected3D}), Utility::Path::join({_testDir, "FlatTestFiles", data.expected3D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -3388,7 +3395,7 @@ void FlatGLTest::renderMulti2D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
/* For arrays we upload three slices of the original image to half-high /* For arrays we upload three slices of the original image to half-high
slices */ slices */
@ -3658,7 +3665,7 @@ void FlatGLTest::renderMulti2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "FlatTestFiles", data.expected2D}), Utility::Path::join({_testDir, "FlatTestFiles", data.expected2D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels /* Object ID -- no need to verify the whole image, just check that pixels
@ -3724,7 +3731,7 @@ void FlatGLTest::renderMulti3D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
/* For arrays we upload three slices of the original image to half-high /* For arrays we upload three slices of the original image to half-high
slices */ slices */
@ -4001,7 +4008,7 @@ void FlatGLTest::renderMulti3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "FlatTestFiles", data.expected3D}), Utility::Path::join({_testDir, "FlatTestFiles", data.expected3D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels /* Object ID -- no need to verify the whole image, just check that pixels

64
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -26,11 +26,17 @@
#include <numeric> #include <numeric>
#include <sstream> #include <sstream>
#include <Corrade/Containers/ArrayViewStl.h> #include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/DebugTools/ColorMap.h" #include "Magnum/DebugTools/ColorMap.h"
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"
@ -186,7 +192,7 @@ struct MeshVisualizerGLTest: GL::OpenGLTester {
private: private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"}; PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir; Containers::String _testDir;
GL::Renderbuffer _color{NoCreate}, GL::Renderbuffer _color{NoCreate},
_depth{NoCreate}; _depth{NoCreate};
@ -1310,13 +1316,13 @@ MeshVisualizerGLTest::MeshVisualizerGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation()); _testDir = Utility::Path::split(*Utility::Path::executableLocation()).first();
} else } else
#endif #endif
{ {
@ -2425,7 +2431,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe2D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe2D.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
} }
@ -2456,7 +2462,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe2D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe2D.tga"),
/* AMD has off-by-one errors on edges compared to Intel */ /* AMD has off-by-one errors on edges compared to Intel */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.082f})); (DebugTools::CompareImageToFile{_manager, 1.0f, 0.082f}));
} }
@ -2522,7 +2528,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe3D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe3D.tga"),
(DebugTools::CompareImageToFile{_manager})); (DebugTools::CompareImageToFile{_manager}));
} }
@ -2557,7 +2563,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe3D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe3D.tga"),
/* AMD has off-by-one errors on edges compared to Intel */ /* AMD has off-by-one errors on edges compared to Intel */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.06f})); (DebugTools::CompareImageToFile{_manager, 1.0f, 0.06f}));
} }
@ -2612,7 +2618,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-objectid2D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-objectid2D.tga"),
/* SwiftShader has a few rounding errors on edges */ /* SwiftShader has a few rounding errors on edges */
(DebugTools::CompareImageToFile{_manager, 24.67f, 0.11f})); (DebugTools::CompareImageToFile{_manager, 24.67f, 0.11f}));
} }
@ -2669,7 +2675,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-objectid3D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-objectid3D.tga"),
/* SwiftShader has a few rounding errors on edges and off-by-two /* SwiftShader has a few rounding errors on edges and off-by-two
pixels */ pixels */
(DebugTools::CompareImageToFile{_manager, 24.67f, 2.55f})); (DebugTools::CompareImageToFile{_manager, 24.67f, 2.55f}));
@ -2746,7 +2752,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-instancedobjectid2D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-instancedobjectid2D.tga"),
/* SwiftShader has a few rounding errors on edges */ /* SwiftShader has a few rounding errors on edges */
(DebugTools::CompareImageToFile{_manager, 150.67f, 0.45f})); (DebugTools::CompareImageToFile{_manager, 150.67f, 0.45f}));
} }
@ -2826,7 +2832,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-instancedobjectid3D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-instancedobjectid3D.tga"),
/* SwiftShader has a few rounding errors on edges */ /* SwiftShader has a few rounding errors on edges */
(DebugTools::CompareImageToFile{_manager, 150.67f, 0.165f})); (DebugTools::CompareImageToFile{_manager, 150.67f, 0.165f}));
} }
@ -2878,7 +2884,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-vertexid2D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-vertexid2D.tga"),
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.017f})); (DebugTools::CompareImageToFile{_manager, 1.0f, 0.017f}));
} }
@ -2933,7 +2939,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-vertexid3D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-vertexid3D.tga"),
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.012f})); (DebugTools::CompareImageToFile{_manager, 1.0f, 0.012f}));
} }
@ -3013,7 +3019,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-primitiveid2D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-primitiveid2D.tga"),
/* SwiftShader has a few rounding errors on edges */ /* SwiftShader has a few rounding errors on edges */
(DebugTools::CompareImageToFile{_manager, 76.67f, 0.23f})); (DebugTools::CompareImageToFile{_manager, 76.67f, 0.23f}));
} }
@ -3098,7 +3104,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-primitiveid3D.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-primitiveid3D.tga"),
/* SwiftShader has a few rounding errors on edges */ /* SwiftShader has a few rounding errors on edges */
(DebugTools::CompareImageToFile{_manager, 88.34f, 0.071f})); (DebugTools::CompareImageToFile{_manager, 88.34f, 0.071f}));
} }
@ -3166,7 +3172,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-tbn.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-tbn.tga"),
/* AMD has off-by-one errors on edges compared to Intel */ /* AMD has off-by-one errors on edges compared to Intel */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.06f})); (DebugTools::CompareImageToFile{_manager, 1.0f, 0.06f}));
} }
@ -3282,7 +3288,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderWirefra
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.file}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.file}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -3299,7 +3305,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderWirefra
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.fileXfail}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.fileXfail}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
} }
@ -3430,7 +3436,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderWirefra
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.file}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.file}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -3447,7 +3453,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderWirefra
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.fileXfail}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.fileXfail}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
} }
@ -3639,7 +3645,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderObjectV
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.file2D}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.file2D}),
/* AMD has slight off-by-one errors compared to Intel, SwiftShader a /* AMD has slight off-by-one errors compared to Intel, SwiftShader a
bit more */ bit more */
(DebugTools::CompareImageToFile{_manager, 4.67f, 0.141f})); (DebugTools::CompareImageToFile{_manager, 4.67f, 0.141f}));
@ -3850,7 +3856,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderObjectV
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.file3D}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.file3D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
#endif #endif
@ -3893,7 +3899,7 @@ void MeshVisualizerGLTest::renderWireframe3DPerspective() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/wireframe-perspective.tga"), Utility::Path::join(_testDir, "MeshVisualizerTestFiles/wireframe-perspective.tga"),
(DebugTools::CompareImageToFile{_manager, 0.667f, 0.002f})); (DebugTools::CompareImageToFile{_manager, 0.667f, 0.002f}));
} }
@ -4086,7 +4092,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderTangent
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.file}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.file}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
#endif #endif
@ -4345,7 +4351,7 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderInstanc
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.expected}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
@ -4635,7 +4641,7 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderInstanc
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.expected}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
@ -4956,7 +4962,7 @@ void MeshVisualizerGLTest::renderMulti2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.expected}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
@ -5287,7 +5293,7 @@ void MeshVisualizerGLTest::renderMulti3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.expected}), Utility::Path::join({_testDir, "MeshVisualizerTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
#endif #endif

72
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -26,12 +26,18 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/TestSuite/Compare/Numeric.h> #include <Corrade/TestSuite/Compare/Numeric.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -162,7 +168,7 @@ struct PhongGLTest: GL::OpenGLTester {
private: private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"}; PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir; Containers::String _testDir;
GL::Renderbuffer _color{NoCreate}; GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -1147,13 +1153,13 @@ PhongGLTest::PhongGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation()); _testDir = Utility::Path::split(*Utility::Path::executableLocation()).first();
} else } else
#endif #endif
{ {
@ -1753,7 +1759,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderDefaults() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/defaults.tga"), Utility::Path::join(_testDir, "PhongTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1853,7 +1859,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderColored() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"), Utility::Path::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2050,7 +2056,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderSinglePixelTextured() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"), Utility::Path::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2108,7 +2114,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderTextured() {
#endif #endif
if(data.flags & PhongGL::Flag::AmbientTexture) { if(data.flags & PhongGL::Flag::AmbientTexture) {
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/ambient-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/ambient-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(data.flags & PhongGL::Flag::TextureArrays) { if(data.flags & PhongGL::Flag::TextureArrays) {
@ -2136,7 +2142,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderTextured() {
so ambient/specular is visible */ so ambient/specular is visible */
if(data.flags & PhongGL::Flag::DiffuseTexture) { if(data.flags & PhongGL::Flag::DiffuseTexture) {
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(data.flags & PhongGL::Flag::TextureArrays) { if(data.flags & PhongGL::Flag::TextureArrays) {
@ -2162,7 +2168,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderTextured() {
if(data.flags & PhongGL::Flag::SpecularTexture) { if(data.flags & PhongGL::Flag::SpecularTexture) {
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/specular-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/specular-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(data.flags & PhongGL::Flag::TextureArrays) { if(data.flags & PhongGL::Flag::TextureArrays) {
@ -2288,7 +2294,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderTextured() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}), Utility::Path::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2326,7 +2332,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderTexturedNormal() {
/* Normal texture. Flip normal Y, if requested */ /* Normal texture. Flip normal Y, if requested */
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/normal-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/normal-texture.tga")) && (image = importer->image2D(0)));
if(data.flipNormalY) for(auto row: image->mutablePixels<Color3ub>()) if(data.flipNormalY) for(auto row: image->mutablePixels<Color3ub>())
for(Color3ub& pixel: row) for(Color3ub& pixel: row)
pixel.y() = 255 - pixel.y(); pixel.y() = 255 - pixel.y();
@ -2484,7 +2490,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderTexturedNormal() {
const Float maxThreshold = 191.0f, meanThreshold = 3.017f; const Float maxThreshold = 191.0f, meanThreshold = 3.017f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}), Utility::Path::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2532,7 +2538,7 @@ template<class T, PhongGL::Flag flag> void PhongGLTest::renderVertexColor() {
GL::Texture2D diffuse; GL::Texture2D diffuse;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
diffuse.setMinificationFilter(GL::SamplerFilter::Linear) diffuse.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -2609,7 +2615,7 @@ template<class T, PhongGL::Flag flag> void PhongGLTest::renderVertexColor() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/vertexColor.tga"), Utility::Path::join(_testDir, "PhongTestFiles/vertexColor.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2723,7 +2729,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderShininess() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}), Utility::Path::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -2745,7 +2751,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderShininess() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles", "shininess0-overflow.tga"}), Utility::Path::join({_testDir, "PhongTestFiles", "shininess0-overflow.tga"}),
/* The threshold = 0.001 case has a slight reddish tone on /* The threshold = 0.001 case has a slight reddish tone on
SwiftShader; ARM Mali has one pixel off */ SwiftShader; ARM Mali has one pixel off */
(DebugTools::CompareImageToFile{_manager, 255.0f, 23.1f})); (DebugTools::CompareImageToFile{_manager, 255.0f, 23.1f}));
@ -2795,7 +2801,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderAlpha() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
GL::Texture2D ambient; GL::Texture2D ambient;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", data.ambientTexture})) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join({_testDir, "TestFiles", data.ambientTexture})) && (image = importer->image2D(0)));
ambient.setMinificationFilter(GL::SamplerFilter::Linear) ambient.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -2803,7 +2809,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderAlpha() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
GL::Texture2D diffuse; GL::Texture2D diffuse;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", data.diffuseTexture})) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join({_testDir, "TestFiles", data.diffuseTexture})) && (image = importer->image2D(0)));
diffuse.setMinificationFilter(GL::SamplerFilter::Linear) diffuse.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -2912,7 +2918,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderAlpha() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, data.expected), Utility::Path::join(_testDir, data.expected),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -3093,7 +3099,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderObjectId() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"), Utility::Path::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels /* Object ID -- no need to verify the whole image, just check that pixels
@ -3221,7 +3227,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderLights() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<const Color3ub>(image.pixels<Color4ub>()), Containers::arrayCast<const Color3ub>(image.pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles", data.file}), Utility::Path::join({_testDir, "PhongTestFiles", data.file}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -3279,7 +3285,7 @@ void PhongGLTest::renderLightsSetOneByOne() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<const Color3ub>(image.pixels<Color4ub>()), Containers::arrayCast<const Color3ub>(image.pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles/light-point-range1.5.tga"}), Utility::Path::join({_testDir, "PhongTestFiles/light-point-range1.5.tga"}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -3320,7 +3326,7 @@ void PhongGLTest::renderLowLightAngle() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/low-light-angle.tga"), Utility::Path::join(_testDir, "PhongTestFiles/low-light-angle.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -3393,7 +3399,7 @@ void PhongGLTest::renderLightCulling() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"), Utility::Path::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
#endif #endif
@ -3434,7 +3440,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderZeroLights() {
GL::Texture2D ambient; GL::Texture2D ambient;
Containers::Optional<Trade::ImageData2D> ambientImage; Containers::Optional<Trade::ImageData2D> ambientImage;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-alpha-texture.tga")) && (ambientImage = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-alpha-texture.tga")) && (ambientImage = importer->image2D(0)));
ambient.setMinificationFilter(GL::SamplerFilter::Linear) ambient.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge) .setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -3541,7 +3547,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderZeroLights() {
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
/* Should be equivalent to masked Flat3D */ /* Should be equivalent to masked Flat3D */
Utility::Directory::join(_testDir, "FlatTestFiles/textured3D-alpha-mask0.5.tga"), Utility::Path::join(_testDir, "FlatTestFiles/textured3D-alpha-mask0.5.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -3682,7 +3688,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderInstanced() {
if(data.flags & PhongGL::Flag::DiffuseTexture) { if(data.flags & PhongGL::Flag::DiffuseTexture) {
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(data.flags & PhongGL::Flag::TextureArrays) { if(data.flags & PhongGL::Flag::TextureArrays) {
@ -3732,7 +3738,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderInstanced() {
if(data.flags & PhongGL::Flag::NormalTexture) { if(data.flags & PhongGL::Flag::NormalTexture) {
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/normal-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/normal-texture.tga")) && (image = importer->image2D(0)));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(data.flags & PhongGL::Flag::TextureArrays) { if(data.flags & PhongGL::Flag::TextureArrays) {
@ -3953,7 +3959,7 @@ template<PhongGL::Flag flag> void PhongGLTest::renderInstanced() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}), Utility::Path::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -4022,7 +4028,7 @@ void PhongGLTest::renderMulti() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
/* For arrays we upload three slices of the original image to half-high /* For arrays we upload three slices of the original image to half-high
slices */ slices */
@ -4342,7 +4348,7 @@ void PhongGLTest::renderMulti() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}), Utility::Path::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels /* Object ID -- no need to verify the whole image, just check that pixels

17
src/Magnum/Shaders/Test/ShadersGLBenchmark.cpp

@ -23,9 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -670,7 +671,7 @@ template<UnsignedInt dimensions> void ShadersGLBenchmark::flat() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }
@ -837,7 +838,7 @@ void ShadersGLBenchmark::phong() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }
@ -896,7 +897,7 @@ template<UnsignedInt dimensions> void ShadersGLBenchmark::vertexColor() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }
@ -968,7 +969,7 @@ template<UnsignedInt dimensions> void ShadersGLBenchmark::vector() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }
@ -1038,7 +1039,7 @@ template<UnsignedInt dimensions> void ShadersGLBenchmark::distanceFieldVector()
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }
@ -1172,7 +1173,7 @@ void ShadersGLBenchmark::meshVisualizer2D() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }
@ -1323,7 +1324,7 @@ void ShadersGLBenchmark::meshVisualizer3D() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}), CORRADE_COMPARE_WITH(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"), Utility::Path::join(SHADERS_TEST_DIR, "BenchmarkFiles/trivial.tga"),
DebugTools::CompareImageToFile{_manager}); DebugTools::CompareImageToFile{_manager});
} }

39
src/Magnum/Shaders/Test/VectorGLTest.cpp

@ -26,10 +26,17 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove once AbstractImporter is <string>-free */
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -116,7 +123,7 @@ struct VectorGLTest: GL::OpenGLTester {
private: private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"}; PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir; Containers::String _testDir;
GL::Renderbuffer _color{NoCreate}; GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -330,13 +337,13 @@ VectorGLTest::VectorGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation()); _testDir = Utility::Path::split(*Utility::Path::executableLocation()).first();
} else } else
#endif #endif
{ {
@ -664,7 +671,7 @@ template<VectorGL2D::Flag flag> void VectorGLTest::renderDefaults2D() {
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -716,7 +723,7 @@ template<VectorGL2D::Flag flag> void VectorGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"), Utility::Path::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -743,7 +750,7 @@ template<VectorGL3D::Flag flag> void VectorGLTest::renderDefaults3D() {
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -795,7 +802,7 @@ template<VectorGL3D::Flag flag> void VectorGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"), Utility::Path::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -825,7 +832,7 @@ template<VectorGL2D::Flag flag> void VectorGLTest::render2D() {
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -900,7 +907,7 @@ template<VectorGL2D::Flag flag> void VectorGLTest::render2D() {
const Float maxThreshold = 170.0f, meanThreshold = 0.962f; const Float maxThreshold = 170.0f, meanThreshold = 0.962f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "VectorTestFiles", data.file2D}), Utility::Path::join({_testDir, "VectorTestFiles", data.file2D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -930,7 +937,7 @@ template<VectorGL3D::Flag flag> void VectorGLTest::render3D() {
GL::Texture2D texture; GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear) texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge); .setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -1009,7 +1016,7 @@ template<VectorGL3D::Flag flag> void VectorGLTest::render3D() {
const Float maxThreshold = 170.0f, meanThreshold = 0.660f; const Float maxThreshold = 170.0f, meanThreshold = 0.660f;
#endif #endif
CORRADE_COMPARE_WITH(pixels, CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "VectorTestFiles", data.file3D}), Utility::Path::join({_testDir, "VectorTestFiles", data.file3D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -1049,7 +1056,7 @@ void VectorGLTest::renderMulti2D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
GL::Texture2D vector; GL::Texture2D vector;
vector.setMinificationFilter(GL::SamplerFilter::Linear) vector.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
@ -1211,7 +1218,7 @@ void VectorGLTest::renderMulti2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "VectorTestFiles", data.expected2D}), Utility::Path::join({_testDir, "VectorTestFiles", data.expected2D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
@ -1250,7 +1257,7 @@ void VectorGLTest::renderMulti3D() {
CORRADE_VERIFY(importer); CORRADE_VERIFY(importer);
Containers::Optional<Trade::ImageData2D> image; Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
GL::Texture2D vector; GL::Texture2D vector;
vector.setMinificationFilter(GL::SamplerFilter::Linear) vector.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear) .setMagnificationFilter(GL::SamplerFilter::Linear)
@ -1417,7 +1424,7 @@ void VectorGLTest::renderMulti3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "VectorTestFiles", data.expected3D}), Utility::Path::join({_testDir, "VectorTestFiles", data.expected3D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
#endif #endif

26
src/Magnum/Shaders/Test/VertexColorGLTest.cpp

@ -25,9 +25,15 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/PluginManager/Manager.h> #include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/DebugTools/CompareImage.h" #include "Magnum/DebugTools/CompareImage.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
@ -102,7 +108,7 @@ struct VertexColorGLTest: GL::OpenGLTester {
private: private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"}; PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir; Containers::String _testDir;
GL::Renderbuffer _color{NoCreate}; GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -273,13 +279,13 @@ VertexColorGLTest::VertexColorGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation()); _testDir = Utility::Path::split(*Utility::Path::executableLocation()).first();
} else } else
#endif #endif
{ {
@ -561,7 +567,7 @@ template<class T, VertexColorGL2D::Flag flag> void VertexColorGLTest::renderDefa
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"), Utility::Path::join(_testDir, "FlatTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -623,7 +629,7 @@ template<class T, VertexColorGL2D::Flag flag> void VertexColorGLTest::renderDefa
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"), Utility::Path::join(_testDir, "FlatTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -690,7 +696,7 @@ template<class T, VertexColorGL2D::Flag flag> void VertexColorGLTest::render2D()
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VertexColorTestFiles/vertexColor2D.tga"), Utility::Path::join(_testDir, "VertexColorTestFiles/vertexColor2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -766,7 +772,7 @@ template<class T, VertexColorGL3D::Flag flag> void VertexColorGLTest::render3D()
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VertexColorTestFiles/vertexColor3D.tga"), Utility::Path::join(_testDir, "VertexColorTestFiles/vertexColor3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold})); (DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
} }
@ -895,7 +901,7 @@ void VertexColorGLTest::renderMulti2D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "VertexColorTestFiles", data.expected2D}), Utility::Path::join({_testDir, "VertexColorTestFiles", data.expected2D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
@ -1026,7 +1032,7 @@ void VertexColorGLTest::renderMulti3D() {
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */ /* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()), Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({_testDir, "VertexColorTestFiles", data.expected3D}), Utility::Path::join({_testDir, "VertexColorTestFiles", data.expected3D}),
(DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold})); (DebugTools::CompareImageToFile{_manager, data.maxThreshold, data.meanThreshold}));
} }
#endif #endif

21
src/Magnum/TextureTools/Test/DistanceFieldGLTest.cpp

@ -23,8 +23,15 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove when AbstractImporter is <string>-free */
#include <Corrade/PluginManager/AbstractManager.h> #include <Corrade/PluginManager/AbstractManager.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Path.h>
#ifdef CORRADE_TARGET_APPLE
#include <Corrade/Containers/Pair.h>
#include <Corrade/Utility/System.h> /* isSandboxed() */
#endif
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/ImageView.h" #include "Magnum/ImageView.h"
@ -65,7 +72,7 @@ struct DistanceFieldGLTest: GL::OpenGLTester {
private: private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"}; PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir; Containers::String _testDir;
}; };
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
@ -89,13 +96,13 @@ DistanceFieldGLTest::DistanceFieldGLTest() {
#endif #endif
#ifdef CORRADE_TARGET_APPLE #ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed() if(Utility::System::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST) #if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */ /** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID") && std::getenv("SIMULATOR_UDID")
#endif #endif
) { ) {
_testDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "DistanceFieldGLTestFiles"); _testDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "DistanceFieldGLTestFiles");
} else } else
#endif #endif
{ {
@ -108,7 +115,7 @@ void DistanceFieldGLTest::test() {
if(!(importer = _manager.loadAndInstantiate("TgaImporter"))) if(!(importer = _manager.loadAndInstantiate("TgaImporter")))
CORRADE_SKIP("TgaImporter plugin not found."); CORRADE_SKIP("TgaImporter plugin not found.");
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "input.tga"))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "input.tga")));
CORRADE_COMPARE(importer->image2DCount(), 1); CORRADE_COMPARE(importer->image2DCount(), 1);
Containers::Optional<Trade::ImageData2D> inputImage = importer->image2D(0); Containers::Optional<Trade::ImageData2D> inputImage = importer->image2D(0);
CORRADE_VERIFY(inputImage); CORRADE_VERIFY(inputImage);
@ -225,7 +232,7 @@ void DistanceFieldGLTest::test() {
#endif #endif
CORRADE_COMPARE_WITH(*actualOutputImage, CORRADE_COMPARE_WITH(*actualOutputImage,
Utility::Directory::join(_testDir, "output.tga"), Utility::Path::join(_testDir, "output.tga"),
/* Some mobile GPUs have slight (off-by-one) rounding errors compared /* Some mobile GPUs have slight (off-by-one) rounding errors compared
to the ground truth, but it's just a very small amount of pixels to the ground truth, but it's just a very small amount of pixels
(20-50 out of the total 4k pixels, iOS/WebGL has slightly more). (20-50 out of the total 4k pixels, iOS/WebGL has slightly more).
@ -245,7 +252,7 @@ void DistanceFieldGLTest::benchmark() {
if(!(importer = _manager.loadAndInstantiate("TgaImporter"))) if(!(importer = _manager.loadAndInstantiate("TgaImporter")))
CORRADE_SKIP("TgaImporter plugin not found."); CORRADE_SKIP("TgaImporter plugin not found.");
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "input.tga"))); CORRADE_VERIFY(importer->openFile(Utility::Path::join(_testDir, "input.tga")));
CORRADE_COMPARE(importer->image2DCount(), 1); CORRADE_COMPARE(importer->image2DCount(), 1);
Containers::Optional<Trade::ImageData2D> inputImage = importer->image2D(0); Containers::Optional<Trade::ImageData2D> inputImage = importer->image2D(0);
CORRADE_VERIFY(inputImage); CORRADE_VERIFY(inputImage);

Loading…
Cancel
Save