Browse Source

Fixed shaders tests for iOS

pull/382/head
Marco Melorio 7 years ago
parent
commit
2379b8cd09
  1. 48
      src/Magnum/Shaders/Test/CMakeLists.txt
  2. 35
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  3. 55
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  4. 27
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  5. 53
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  6. 31
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  7. 23
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp

48
src/Magnum/Shaders/Test/CMakeLists.txt

@ -69,7 +69,11 @@ if(BUILD_GL_TESTS)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/configure.h
INPUT ${CMAKE_CURRENT_BINARY_DIR}/configure.h.in)
corrade_add_test(ShadersDistanceFieldVectorGLTest DistanceFieldVectorGLTest.cpp
set(ShadersDistanceFieldVectorGLTest_SRCS DistanceFieldVectorGLTest.cpp)
if(CORRADE_TARGET_IOS)
list(APPEND ShadersDistanceFieldVectorGLTest_SRCS TestFiles VectorTestFiles)
endif()
corrade_add_test(ShadersDistanceFieldVectorGLTest ${ShadersDistanceFieldVectorGLTest_SRCS}
LIBRARIES
MagnumDebugTools
MagnumMeshTools
@ -97,7 +101,11 @@ if(BUILD_GL_TESTS)
endif()
endif()
corrade_add_test(ShadersFlatGLTest FlatGLTest.cpp
set(ShadersFlatGLTest_SRCS FlatGLTest.cpp)
if(CORRADE_TARGET_IOS)
list(APPEND ShadersFlatGLTest_SRCS TestFiles FlatTestFiles)
endif()
corrade_add_test(ShadersFlatGLTest ${ShadersFlatGLTest_SRCS}
LIBRARIES
MagnumDebugTools
MagnumMeshTools
@ -130,7 +138,11 @@ if(BUILD_GL_TESTS)
endif()
endif()
corrade_add_test(ShadersMeshVisualizerGLTest MeshVisualizerGLTest.cpp
set(ShadersMeshVisualizerGLTest_SRCS MeshVisualizerGLTest.cpp)
if(CORRADE_TARGET_IOS)
list(APPEND ShadersMeshVisualizerGLTest_SRCS FlatTestFiles MeshVisualizerTestFiles)
endif()
corrade_add_test(ShadersMeshVisualizerGLTest ${ShadersMeshVisualizerGLTest_SRCS}
LIBRARIES
MagnumDebugTools
MagnumMeshTools
@ -154,7 +166,11 @@ if(BUILD_GL_TESTS)
endif()
endif()
corrade_add_test(ShadersPhongGLTest PhongGLTest.cpp
set(ShadersPhongGLTest_SRCS PhongGLTest.cpp)
if(CORRADE_TARGET_IOS)
list(APPEND ShadersPhongGLTest_SRCS TestFiles PhongTestFiles FlatTestFiles)
endif()
corrade_add_test(ShadersPhongGLTest ${ShadersPhongGLTest_SRCS}
LIBRARIES
MagnumDebugTools
MagnumMeshTools
@ -199,7 +215,11 @@ if(BUILD_GL_TESTS)
endif()
endif()
corrade_add_test(ShadersVectorGLTest VectorGLTest.cpp
set(ShadersVectorGLTest_SRCS VectorGLTest.cpp)
if(CORRADE_TARGET_IOS)
list(APPEND ShadersVectorGLTest_SRCS TestFiles VectorTestFiles)
endif()
corrade_add_test(ShadersVectorGLTest ${ShadersVectorGLTest_SRCS}
LIBRARIES
MagnumDebugTools
MagnumMeshTools
@ -222,7 +242,11 @@ if(BUILD_GL_TESTS)
endif()
endif()
corrade_add_test(ShadersVertexColorGLTest VertexColorGLTest.cpp
set(ShadersVertexColorGLTest_SRCS VertexColorGLTest.cpp)
if(CORRADE_TARGET_IOS)
list(APPEND ShadersVertexColorGLTest_SRCS FlatTestFiles VertexColorTestFiles)
endif()
corrade_add_test(ShadersVertexColorGLTest ${ShadersVertexColorGLTest_SRCS}
LIBRARIES
MagnumDebugTools
MagnumMeshTools
@ -244,6 +268,18 @@ if(BUILD_GL_TESTS)
endif()
endif()
if(CORRADE_TARGET_IOS)
set_source_files_properties(
TestFiles
VectorTestFiles
FlatTestFiles
MeshVisualizerTestFiles
PhongTestFiles
VectorTestFiles
VertexColorTestFiles
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
endif()
set_target_properties(
ShadersDistanceFieldVectorGLTest
ShadersFlatGLTest

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

@ -71,6 +71,7 @@ struct DistanceFieldVectorGLTest: GL::OpenGLTester {
private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir;
GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2
@ -128,6 +129,20 @@ DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() {
#ifdef TGAIMPORTER_PLUGIN_FILENAME
CORRADE_INTERNAL_ASSERT(_manager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);
#endif
#ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
#endif
) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation());
} else
#endif
{
_testDir = SHADERS_TEST_DIR;
}
}
template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::construct() {
@ -211,7 +226,7 @@ void DistanceFieldVectorGLTest::renderDefaults2D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -237,7 +252,7 @@ void DistanceFieldVectorGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, 189.0f, 6.1f}));
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
@ -251,7 +266,7 @@ void DistanceFieldVectorGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/defaults-distancefield.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults-distancefield.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -267,7 +282,7 @@ void DistanceFieldVectorGLTest::renderDefaults3D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -293,7 +308,7 @@ void DistanceFieldVectorGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, 189.0f, 6.1f}));
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
@ -307,7 +322,7 @@ void DistanceFieldVectorGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/defaults-distancefield.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults-distancefield.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -326,7 +341,7 @@ void DistanceFieldVectorGLTest::render2D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -363,7 +378,7 @@ void DistanceFieldVectorGLTest::render2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "VectorTestFiles", data.file2D}),
Utility::Directory::join({_testDir, "VectorTestFiles", data.file2D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -382,7 +397,7 @@ void DistanceFieldVectorGLTest::render3D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector-distancefield.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -424,7 +439,7 @@ void DistanceFieldVectorGLTest::render3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "VectorTestFiles", data.file3D}),
Utility::Directory::join({_testDir, "VectorTestFiles", data.file3D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}

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

@ -102,6 +102,7 @@ struct FlatGLTest: GL::OpenGLTester {
private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir;
GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2
@ -219,6 +220,20 @@ FlatGLTest::FlatGLTest() {
#ifdef TGAIMPORTER_PLUGIN_FILENAME
CORRADE_INTERNAL_ASSERT(_manager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);
#endif
#ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
#endif
) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation());
} else
#endif
{
_testDir = SHADERS_TEST_DIR;
}
}
template<UnsignedInt dimensions> void FlatGLTest::construct() {
@ -344,7 +359,7 @@ void FlatGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"),
/* SwiftShader has 8 different pixels on the edges */
(DebugTools::CompareImageToFile{_manager, 238.0f, 0.2975f}));
}
@ -364,7 +379,7 @@ void FlatGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"),
/* SwiftShader has 8 different pixels on the edges */
(DebugTools::CompareImageToFile{_manager, 238.0f, 0.2975f}));
}
@ -393,7 +408,7 @@ void FlatGLTest::renderColored2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored2D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -426,7 +441,7 @@ void FlatGLTest::renderColored3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored3D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -479,7 +494,7 @@ void FlatGLTest::renderSinglePixelTextured2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored2D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -521,7 +536,7 @@ void FlatGLTest::renderSinglePixelTextured3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored3D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -538,7 +553,7 @@ void FlatGLTest::renderTextured2D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -565,7 +580,7 @@ void FlatGLTest::renderTextured2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/textured2D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/textured2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -582,7 +597,7 @@ void FlatGLTest::renderTextured3D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -613,7 +628,7 @@ void FlatGLTest::renderTextured3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/textured3D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/textured3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -642,7 +657,7 @@ template<class T> void FlatGLTest::renderVertexColor2D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -667,7 +682,7 @@ template<class T> void FlatGLTest::renderVertexColor2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/vertexColor2D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/vertexColor2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -696,7 +711,7 @@ template<class T> void FlatGLTest::renderVertexColor3D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -725,7 +740,7 @@ template<class T> void FlatGLTest::renderVertexColor3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/vertexColor3D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/vertexColor3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -756,7 +771,7 @@ void FlatGLTest::renderAlpha2D() {
CORRADE_VERIFY(importer);
GL::Texture2D texture;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({SHADERS_TEST_DIR, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -790,7 +805,7 @@ void FlatGLTest::renderAlpha2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, data.expected2D),
Utility::Directory::join(_testDir, data.expected2D),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -807,7 +822,7 @@ void FlatGLTest::renderAlpha3D() {
CORRADE_VERIFY(importer);
GL::Texture2D texture;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({SHADERS_TEST_DIR, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", "diffuse-alpha-texture.tga"})) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -850,7 +865,7 @@ void FlatGLTest::renderAlpha3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, data.expected3D}),
Utility::Directory::join({_testDir, data.expected3D}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -912,7 +927,7 @@ void FlatGLTest::renderObjectId2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored2D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels
@ -964,7 +979,7 @@ void FlatGLTest::renderObjectId3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored3D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels

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

@ -83,6 +83,7 @@ struct MeshVisualizerGLTest: GL::OpenGLTester {
private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir;
GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2
@ -150,6 +151,20 @@ MeshVisualizerGLTest::MeshVisualizerGLTest() {
#ifdef TGAIMPORTER_PLUGIN_FILENAME
CORRADE_INTERNAL_ASSERT(_manager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);
#endif
#ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
#endif
) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation());
} else
#endif
{
_testDir = SHADERS_TEST_DIR;
}
}
void MeshVisualizerGLTest::construct() {
@ -288,7 +303,7 @@ void MeshVisualizerGLTest::renderDefaults() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -323,7 +338,7 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "MeshVisualizerTestFiles/defaults-wireframe.tga"),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe.tga"),
(DebugTools::CompareImageToFile{_manager}));
}
@ -336,7 +351,7 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "MeshVisualizerTestFiles/defaults-wireframe.tga"),
Utility::Directory::join(_testDir, "MeshVisualizerTestFiles/defaults-wireframe.tga"),
/* AMD has off-by-one errors on edges compared to Intel */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.06f}));
}
@ -370,7 +385,7 @@ void MeshVisualizerGLTest::render() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/colored3D.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/colored3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -451,7 +466,7 @@ void MeshVisualizerGLTest::renderWireframe() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "MeshVisualizerTestFiles", data.file}),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.file}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -467,7 +482,7 @@ void MeshVisualizerGLTest::renderWireframe() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "MeshVisualizerTestFiles", data.fileXfail}),
Utility::Directory::join({_testDir, "MeshVisualizerTestFiles", data.fileXfail}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
}

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

@ -103,6 +103,7 @@ struct PhongGLTest: GL::OpenGLTester {
private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir;
GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2
@ -331,6 +332,20 @@ PhongGLTest::PhongGLTest() {
#ifdef TGAIMPORTER_PLUGIN_FILENAME
CORRADE_INTERNAL_ASSERT(_manager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);
#endif
#ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
#endif
) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation());
} else
#endif
{
_testDir = SHADERS_TEST_DIR;
}
}
void PhongGLTest::construct() {
@ -518,7 +533,7 @@ void PhongGLTest::renderDefaults() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "PhongTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "PhongTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -559,7 +574,7 @@ void PhongGLTest::renderColored() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "PhongTestFiles/colored.tga"),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -645,7 +660,7 @@ void PhongGLTest::renderSinglePixelTextured() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "PhongTestFiles/colored.tga"),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -668,7 +683,7 @@ void PhongGLTest::renderTextured() {
GL::Texture2D ambient;
if(data.flags & Phong::Flag::AmbientTexture) {
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/ambient-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/ambient-texture.tga")) && (image = importer->image2D(0)));
ambient.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -686,7 +701,7 @@ void PhongGLTest::renderTextured() {
GL::Texture2D diffuse;
if(data.flags & Phong::Flag::DiffuseTexture) {
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
diffuse.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -702,7 +717,7 @@ void PhongGLTest::renderTextured() {
GL::Texture2D specular;
if(data.flags & Phong::Flag::SpecularTexture) {
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/specular-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/specular-texture.tga")) && (image = importer->image2D(0)));
specular.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -743,7 +758,7 @@ void PhongGLTest::renderTextured() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "PhongTestFiles", data.expected}),
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -760,7 +775,7 @@ void PhongGLTest::renderTexturedNormal() {
GL::Texture2D normal;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/normal-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/normal-texture.tga")) && (image = importer->image2D(0)));
normal.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -826,7 +841,7 @@ void PhongGLTest::renderTexturedNormal() {
const Float maxThreshold = 191.0f, meanThreshold = 3.017f;
#endif
CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join(SHADERS_TEST_DIR, "PhongTestFiles/textured-normal.tga"),
Utility::Directory::join(_testDir, "PhongTestFiles/textured-normal.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -855,7 +870,7 @@ template<class T> void PhongGLTest::renderVertexColor() {
GL::Texture2D diffuse;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-texture.tga")) && (image = importer->image2D(0)));
diffuse.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -889,7 +904,7 @@ template<class T> void PhongGLTest::renderVertexColor() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "PhongTestFiles/vertexColor.tga"),
Utility::Directory::join(_testDir, "PhongTestFiles/vertexColor.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -943,7 +958,7 @@ void PhongGLTest::renderShininess() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "PhongTestFiles", data.expected}),
Utility::Directory::join({_testDir, "PhongTestFiles", data.expected}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -965,7 +980,7 @@ void PhongGLTest::renderShininess() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join({SHADERS_TEST_DIR, "PhongTestFiles", "shininess0-overflow.tga"}),
Utility::Directory::join({_testDir, "PhongTestFiles", "shininess0-overflow.tga"}),
/* The threshold = 0.001 case has a slight reddish tone on
SwiftShader; ARM Mali has one pixel off */
(DebugTools::CompareImageToFile{_manager, 255.0f, 1.475f}));
@ -999,7 +1014,7 @@ void PhongGLTest::renderAlpha() {
CORRADE_VERIFY(importer);
GL::Texture2D ambient;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({SHADERS_TEST_DIR, "TestFiles", data.ambientTexture})) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", data.ambientTexture})) && (image = importer->image2D(0)));
ambient.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -1007,7 +1022,7 @@ void PhongGLTest::renderAlpha() {
.setSubImage(0, {}, *image);
GL::Texture2D diffuse;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({SHADERS_TEST_DIR, "TestFiles", data.diffuseTexture})) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join({_testDir, "TestFiles", data.diffuseTexture})) && (image = importer->image2D(0)));
diffuse.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -1066,7 +1081,7 @@ void PhongGLTest::renderAlpha() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, data.expected),
Utility::Directory::join(_testDir, data.expected),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -1136,7 +1151,7 @@ void PhongGLTest::renderObjectId() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "PhongTestFiles/colored.tga"),
Utility::Directory::join(_testDir, "PhongTestFiles/colored.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Object ID -- no need to verify the whole image, just check that pixels
@ -1176,7 +1191,7 @@ void PhongGLTest::renderZeroLights() {
GL::Texture2D ambient;
Containers::Optional<Trade::ImageData2D> ambientImage;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/diffuse-alpha-texture.tga")) && (ambientImage = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/diffuse-alpha-texture.tga")) && (ambientImage = importer->image2D(0)));
ambient.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge)
@ -1228,7 +1243,7 @@ void PhongGLTest::renderZeroLights() {
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
/* Should be equivalent to masked Flat3D */
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/textured3D-alpha-mask0.5.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/textured3D-alpha-mask0.5.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
#ifndef MAGNUM_TARGET_GLES2

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

@ -71,6 +71,7 @@ struct VectorGLTest: GL::OpenGLTester {
private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir;
GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2
@ -113,6 +114,20 @@ VectorGLTest::VectorGLTest() {
#ifdef TGAIMPORTER_PLUGIN_FILENAME
CORRADE_INTERNAL_ASSERT(_manager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);
#endif
#ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
#endif
) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation());
} else
#endif
{
_testDir = SHADERS_TEST_DIR;
}
}
template<UnsignedInt dimensions> void VectorGLTest::construct() {
@ -196,7 +211,7 @@ void VectorGLTest::renderDefaults2D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -227,7 +242,7 @@ void VectorGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -243,7 +258,7 @@ void VectorGLTest::renderDefaults3D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -274,7 +289,7 @@ void VectorGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -290,7 +305,7 @@ void VectorGLTest::render2D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -326,7 +341,7 @@ void VectorGLTest::render2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/vector2D.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/vector2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -342,7 +357,7 @@ void VectorGLTest::render3D() {
GL::Texture2D texture;
Containers::Optional<Trade::ImageData2D> image;
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(SHADERS_TEST_DIR, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(_testDir, "TestFiles/vector.tga")) && (image = importer->image2D(0)));
texture.setMinificationFilter(GL::SamplerFilter::Linear)
.setMagnificationFilter(GL::SamplerFilter::Linear)
.setWrapping(GL::SamplerWrapping::ClampToEdge);
@ -380,7 +395,7 @@ void VectorGLTest::render3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VectorTestFiles/vector3D.tga"),
Utility::Directory::join(_testDir, "VectorTestFiles/vector3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}

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

@ -68,6 +68,7 @@ struct VertexColorGLTest: GL::OpenGLTester {
private:
PluginManager::Manager<Trade::AbstractImporter> _manager{"nonexistent"};
std::string _testDir;
GL::Renderbuffer _color{NoCreate};
#ifndef MAGNUM_TARGET_GLES2
@ -115,6 +116,20 @@ VertexColorGLTest::VertexColorGLTest() {
#ifdef TGAIMPORTER_PLUGIN_FILENAME
CORRADE_INTERNAL_ASSERT(_manager.load(TGAIMPORTER_PLUGIN_FILENAME) & PluginManager::LoadState::Loaded);
#endif
#ifdef CORRADE_TARGET_APPLE
if(Utility::Directory::isSandboxed()
#if defined(CORRADE_TARGET_IOS) && defined(CORRADE_TESTSUITE_TARGET_XCTEST)
/** @todo Fix this once I persuade CMake to run XCTest tests properly */
&& std::getenv("SIMULATOR_UDID")
#endif
) {
_testDir = Utility::Directory::path(Utility::Directory::executableLocation());
} else
#endif
{
_testDir = SHADERS_TEST_DIR;
}
}
template<UnsignedInt dimensions> void VertexColorGLTest::construct() {
@ -211,7 +226,7 @@ template<class T> void VertexColorGLTest::renderDefaults2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -248,7 +263,7 @@ template<class T> void VertexColorGLTest::renderDefaults3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "FlatTestFiles/defaults.tga"),
Utility::Directory::join(_testDir, "FlatTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -289,7 +304,7 @@ template<class T> void VertexColorGLTest::render2D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VertexColorTestFiles/vertexColor2D.tga"),
Utility::Directory::join(_testDir, "VertexColorTestFiles/vertexColor2D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}
@ -334,7 +349,7 @@ template<class T> void VertexColorGLTest::render3D() {
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(SHADERS_TEST_DIR, "VertexColorTestFiles/vertexColor3D.tga"),
Utility::Directory::join(_testDir, "VertexColorTestFiles/vertexColor3D.tga"),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
}

Loading…
Cancel
Save