From 6dfbe038b62c84ca7e3586066f8c71310e448690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 27 Nov 2022 23:29:51 +0100 Subject: [PATCH] Shaders: reduce error output redirection scope in tests to a minimum. Otherwise it may catch also unrelated assertions, which is undesired and which may lead to nasty crashes. --- .../Test/DistanceFieldVectorGLTest.cpp | 28 +++---- src/Magnum/Shaders/Test/FlatGLTest.cpp | 59 +++++++------- .../Shaders/Test/MeshVisualizerGLTest.cpp | 72 ++++++++--------- src/Magnum/Shaders/Test/PhongGLTest.cpp | 77 +++++++++---------- src/Magnum/Shaders/Test/VectorGLTest.cpp | 34 ++++---- src/Magnum/Shaders/Test/VertexColorGLTest.cpp | 21 ++--- 6 files changed, 141 insertions(+), 150 deletions(-) diff --git a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp index c03b8460a..19c334463 100644 --- a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp @@ -584,11 +584,11 @@ template void DistanceFieldVectorGLTest::setUniformUnifo CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - DistanceFieldVectorGL shader{typename DistanceFieldVectorGL::Configuration{} .setFlags(DistanceFieldVectorGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setTransformationProjectionMatrix({}) .setTextureMatrix({}) .setColor({}) @@ -609,11 +609,11 @@ template void DistanceFieldVectorGLTest::bindBufferUnifo CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; DistanceFieldVectorGL shader; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTransformationProjectionBuffer(buffer) .bindTransformationProjectionBuffer(buffer, 0, 16) .bindDrawBuffer(buffer) @@ -641,12 +641,11 @@ template void DistanceFieldVectorGLTest::setTextureMatri CORRADE_SKIP_IF_NO_ASSERT(); + DistanceFieldVectorGL shader; + std::ostringstream out; Error redirectError{&out}; - - DistanceFieldVectorGL shader; shader.setTextureMatrix({}); - CORRADE_COMPARE(out.str(), "Shaders::DistanceFieldVectorGL::setTextureMatrix(): the shader was not created with texture transformation enabled\n"); } @@ -662,12 +661,12 @@ template void DistanceFieldVectorGLTest::bindTextureTran CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer{GL::Buffer::TargetHint::Uniform}; DistanceFieldVectorGL shader{typename DistanceFieldVectorGL::Configuration{} .setFlags(DistanceFieldVectorGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTextureTransformationBuffer(buffer) .bindTextureTransformationBuffer(buffer, 0, 16); CORRADE_COMPARE(out.str(), @@ -687,12 +686,13 @@ template void DistanceFieldVectorGLTest::setWrongDrawOff CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; DistanceFieldVectorGL shader{typename DistanceFieldVectorGL::Configuration{} .setFlags(DistanceFieldVectorGL::Flag::UniformBuffers) .setMaterialCount(2) .setDrawCount(5)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::DistanceFieldVectorGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index c1e588438..a7de96ddd 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -1097,11 +1097,11 @@ template void FlatGLTest::setUniformUniformBuffersEnable CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - FlatGL shader{typename FlatGL::Configuration{} .setFlags(FlatGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setTransformationProjectionMatrix({}) .setTextureMatrix({}) .setTextureLayer({}) @@ -1122,11 +1122,11 @@ template void FlatGLTest::bindBufferUniformBuffersNotEna CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; FlatGL shader; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTransformationProjectionBuffer(buffer) .bindTransformationProjectionBuffer(buffer, 0, 16) .bindDrawBuffer(buffer) @@ -1161,12 +1161,12 @@ template void FlatGLTest::bindTexturesInvalid() { CORRADE_SKIP(GL::Extensions::EXT::texture_array::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - + GL::Texture2D texture; FlatGL shader{typename FlatGL::Configuration{} .setFlags(data.flags)}; - GL::Texture2D texture; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTexture(texture); #ifndef MAGNUM_TARGET_GLES2 shader.bindObjectIdTexture(texture); @@ -1187,12 +1187,12 @@ template void FlatGLTest::bindTextureArraysInvalid() { CORRADE_SKIP(GL::Extensions::EXT::texture_array::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - + GL::Texture2DArray textureArray; FlatGL shader{typename FlatGL::Configuration{} .setFlags(data.flags)}; - GL::Texture2DArray textureArray; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTexture(textureArray); shader.bindObjectIdTexture(textureArray); CORRADE_COMPARE(out.str(), data.message); @@ -1204,12 +1204,11 @@ template void FlatGLTest::setAlphaMaskNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + FlatGL shader; + std::ostringstream out; Error redirectError{&out}; - - FlatGL shader; shader.setAlphaMask(0.75f); - CORRADE_COMPARE(out.str(), "Shaders::FlatGL::setAlphaMask(): the shader was not created with alpha mask enabled\n"); } @@ -1219,12 +1218,11 @@ template void FlatGLTest::setTextureMatrixNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + FlatGL shader; + std::ostringstream out; Error redirectError{&out}; - - FlatGL shader; shader.setTextureMatrix({}); - CORRADE_COMPARE(out.str(), "Shaders::FlatGL::setTextureMatrix(): the shader was not created with texture transformation enabled\n"); } @@ -1235,12 +1233,11 @@ template void FlatGLTest::setTextureLayerNotArray() { CORRADE_SKIP_IF_NO_ASSERT(); + FlatGL shader; + std::ostringstream out; Error redirectError{&out}; - - FlatGL shader; shader.setTextureLayer(37); - CORRADE_COMPARE(out.str(), "Shaders::FlatGL::setTextureLayer(): the shader was not created with texture arrays enabled\n"); } @@ -1257,12 +1254,12 @@ template void FlatGLTest::bindTextureTransformBufferNotE CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer{GL::Buffer::TargetHint::Uniform}; FlatGL shader{typename FlatGL::Configuration{} .setFlags(FlatGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTextureTransformationBuffer(buffer) .bindTextureTransformationBuffer(buffer, 0, 16); CORRADE_COMPARE(out.str(), @@ -1277,12 +1274,11 @@ template void FlatGLTest::setObjectIdNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + FlatGL shader; + std::ostringstream out; Error redirectError{&out}; - - FlatGL shader; shader.setObjectId(33376); - CORRADE_COMPARE(out.str(), "Shaders::FlatGL::setObjectId(): the shader was not created with object ID enabled\n"); } @@ -1299,12 +1295,13 @@ template void FlatGLTest::setWrongDrawOffset() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; FlatGL shader{typename FlatGL::Configuration{} .setFlags(FlatGL::Flag::UniformBuffers) .setMaterialCount(2) .setDrawCount(5)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::FlatGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index 12b552030..706a1e29b 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -1957,11 +1957,11 @@ void MeshVisualizerGLTest::setUniformUniformBuffersEnabled2D() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - MeshVisualizerGL2D shader{MeshVisualizerGL2D::Configuration{} .setFlags(MeshVisualizerGL2D::Flag::UniformBuffers|MeshVisualizerGL2D::Flag::Wireframe|MeshVisualizerGL2D::Flag::NoGeometryShader)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setTransformationProjectionMatrix({}) .setTextureMatrix({}) .setTextureLayer({}) @@ -1992,11 +1992,11 @@ void MeshVisualizerGLTest::setUniformUniformBuffersEnabled3D() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - MeshVisualizerGL3D shader{MeshVisualizerGL3D::Configuration{} .setFlags(MeshVisualizerGL3D::Flag::UniformBuffers|MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setProjectionMatrix({}) .setTransformationMatrix({}) .setTextureMatrix({}) @@ -2037,12 +2037,12 @@ void MeshVisualizerGLTest::setUniformUniformBuffersEnabled3D() { void MeshVisualizerGLTest::bindBufferUniformBuffersNotEnabled2D() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; MeshVisualizerGL2D shader{MeshVisualizerGL2D::Configuration{} .setFlags(MeshVisualizerGL2D::Flag::Wireframe|MeshVisualizerGL2D::Flag::NoGeometryShader)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTransformationProjectionBuffer(buffer) .bindTransformationProjectionBuffer(buffer, 0, 16) .bindDrawBuffer(buffer) @@ -2067,12 +2067,12 @@ void MeshVisualizerGLTest::bindBufferUniformBuffersNotEnabled2D() { void MeshVisualizerGLTest::bindBufferUniformBuffersNotEnabled3D() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; MeshVisualizerGL3D shader{MeshVisualizerGL3D::Configuration{} .setFlags(MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindProjectionBuffer(buffer) .bindProjectionBuffer(buffer, 0, 16) .bindTransformationBuffer(buffer) @@ -2153,14 +2153,13 @@ void MeshVisualizerGLTest::bindObjectIdTextureArrayInvalid2D() { CORRADE_SKIP(GL::Extensions::EXT::texture_array::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2DArray textureArray; MeshVisualizerGL2D shader{MeshVisualizerGL2D::Configuration{} .setFlags(data.flags2D)}; - shader.bindObjectIdTexture(textureArray); + std::ostringstream out; + Error redirectError{&out}; + shader.bindObjectIdTexture(textureArray); CORRADE_COMPARE(out.str(), data.message); } @@ -2175,14 +2174,13 @@ void MeshVisualizerGLTest::bindObjectIdTextureArrayInvalid3D() { CORRADE_SKIP(GL::Extensions::EXT::texture_array::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2DArray textureArray; MeshVisualizerGL3D shader{MeshVisualizerGL3D::Configuration{} .setFlags(data.flags3D)}; - shader.bindObjectIdTexture(textureArray); + std::ostringstream out; + Error redirectError{&out}; + shader.bindObjectIdTexture(textureArray); CORRADE_COMPARE(out.str(), data.message); } #endif @@ -2374,14 +2372,13 @@ void MeshVisualizerGLTest::setObjectIdNotEnabled3D() { void MeshVisualizerGLTest::setColorMapNotEnabled2D() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2D texture; MeshVisualizerGL2D shader{NoCreate}; + + std::ostringstream out; + Error redirectError{&out}; shader.setColorMapTransformation({}, {}) .bindColorMapTexture(texture); - CORRADE_COMPARE(out.str(), "Shaders::MeshVisualizerGL::setColorMapTransformation(): the shader was not created with object/vertex/primitive ID enabled\n" "Shaders::MeshVisualizerGL::bindColorMapTexture(): the shader was not created with object/vertex/primitive ID enabled\n"); @@ -2390,14 +2387,13 @@ void MeshVisualizerGLTest::setColorMapNotEnabled2D() { void MeshVisualizerGLTest::setColorMapNotEnabled3D() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2D texture; MeshVisualizerGL3D shader{NoCreate}; + + std::ostringstream out; + Error redirectError{&out}; shader.setColorMapTransformation({}, {}) .bindColorMapTexture(texture); - CORRADE_COMPARE(out.str(), "Shaders::MeshVisualizerGL::setColorMapTransformation(): the shader was not created with object/vertex/primitive ID enabled\n" "Shaders::MeshVisualizerGL::bindColorMapTexture(): the shader was not created with object/vertex/primitive ID enabled\n"); @@ -2416,15 +2412,14 @@ void MeshVisualizerGLTest::setTangentBitangentNormalNotEnabled3D() { CORRADE_SKIP(GL::Extensions::EXT::geometry_shader::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - MeshVisualizerGL3D shader{MeshVisualizerGL3D::Configuration{} .setFlags(MeshVisualizerGL3D::Flag::Wireframe)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setNormalMatrix({}) .setLineWidth({}) .setLineLength({}); - CORRADE_COMPARE(out.str(), "Shaders::MeshVisualizerGL3D::setNormalMatrix(): the shader was not created with TBN direction enabled\n" "Shaders::MeshVisualizerGL3D::setLineWidth(): the shader was not created with TBN direction enabled\n" @@ -2441,12 +2436,13 @@ void MeshVisualizerGLTest::setWrongDrawOffset2D() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; MeshVisualizerGL2D shader{MeshVisualizerGL2D::Configuration{} .setFlags(MeshVisualizerGL2D::Flag::UniformBuffers|MeshVisualizerGL2D::Flag::Wireframe|MeshVisualizerGL2D::Flag::NoGeometryShader) .setMaterialCount(2) .setDrawCount(5)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::MeshVisualizerGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); @@ -2460,14 +2456,14 @@ void MeshVisualizerGLTest::setWrongDrawOffset3D() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; MeshVisualizerGL3D shader{MeshVisualizerGL3D::Configuration{} .setFlags(MeshVisualizerGL3D::Flag::UniformBuffers|MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader) .setMaterialCount(2) .setDrawCount(5)}; - shader - .setDrawOffset(5); + + std::ostringstream out; + Error redirectError{&out}; + shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::MeshVisualizerGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); } diff --git a/src/Magnum/Shaders/Test/PhongGLTest.cpp b/src/Magnum/Shaders/Test/PhongGLTest.cpp index f8d267a19..cfa9cf9c2 100644 --- a/src/Magnum/Shaders/Test/PhongGLTest.cpp +++ b/src/Magnum/Shaders/Test/PhongGLTest.cpp @@ -1437,11 +1437,11 @@ void PhongGLTest::setUniformUniformBuffersEnabled() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - PhongGL shader{PhongGL::Configuration{} .setFlags(PhongGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setAmbientColor({}) .setDiffuseColor({}) .setNormalTextureScale({}) @@ -1488,11 +1488,11 @@ void PhongGLTest::setUniformUniformBuffersEnabled() { void PhongGLTest::bindBufferUniformBuffersNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; PhongGL shader; + + std::ostringstream out; + Error redirectError{&out}; shader.bindProjectionBuffer(buffer) .bindProjectionBuffer(buffer, 0, 16) .bindTransformationBuffer(buffer) @@ -1534,12 +1534,12 @@ void PhongGLTest::bindTexturesInvalid() { CORRADE_SKIP(GL::Extensions::EXT::texture_array::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2D texture; PhongGL shader{PhongGL::Configuration{} .setFlags(data.flags)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindAmbientTexture(texture) .bindDiffuseTexture(texture) .bindSpecularTexture(texture) @@ -1564,18 +1564,17 @@ void PhongGLTest::bindTextureArraysInvalid() { CORRADE_SKIP(GL::Extensions::EXT::texture_array::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2DArray textureArray; PhongGL shader{PhongGL::Configuration{} .setFlags(data.flags)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindAmbientTexture(textureArray) .bindDiffuseTexture(textureArray) .bindSpecularTexture(textureArray) .bindNormalTexture(textureArray) .bindObjectIdTexture(textureArray); - CORRADE_COMPARE(out.str(), data.message); } #endif @@ -1583,12 +1582,11 @@ void PhongGLTest::bindTextureArraysInvalid() { void PhongGLTest::setAlphaMaskNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + PhongGL shader; + std::ostringstream out; Error redirectError{&out}; - - PhongGL shader; shader.setAlphaMask(0.75f); - CORRADE_COMPARE(out.str(), "Shaders::PhongGL::setAlphaMask(): the shader was not created with alpha mask enabled\n"); } @@ -1596,12 +1594,12 @@ void PhongGLTest::setAlphaMaskNotEnabled() { void PhongGLTest::setSpecularDisabled() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Texture2D texture; PhongGL shader{PhongGL::Configuration{} .setFlags(PhongGL::Flag::NoSpecular)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setSpecularColor({}) .setShininess({}) /* {{}} makes GCC 4.8 warn about zero as null pointer constant */ @@ -1617,12 +1615,11 @@ void PhongGLTest::setSpecularDisabled() { void PhongGLTest::setTextureMatrixNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + PhongGL shader; + std::ostringstream out; Error redirectError{&out}; - - PhongGL shader; shader.setTextureMatrix({}); - CORRADE_COMPARE(out.str(), "Shaders::PhongGL::setTextureMatrix(): the shader was not created with texture transformation enabled\n"); } @@ -1630,12 +1627,11 @@ void PhongGLTest::setTextureMatrixNotEnabled() { void PhongGLTest::setNormalTextureScaleNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + PhongGL shader; + std::ostringstream out; Error redirectError{&out}; - - PhongGL shader; shader.setNormalTextureScale({}); - CORRADE_COMPARE(out.str(), "Shaders::PhongGL::setNormalTextureScale(): the shader was not created with normal texture enabled\n"); } @@ -1644,12 +1640,11 @@ void PhongGLTest::setNormalTextureScaleNotEnabled() { void PhongGLTest::setTextureLayerNotArray() { CORRADE_SKIP_IF_NO_ASSERT(); + PhongGL shader; + std::ostringstream out; Error redirectError{&out}; - - PhongGL shader; shader.setTextureLayer(37); - CORRADE_COMPARE(out.str(), "Shaders::PhongGL::setTextureLayer(): the shader was not created with texture arrays enabled\n"); } @@ -1664,12 +1659,12 @@ void PhongGLTest::bindTextureTransformBufferNotEnabled() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer{GL::Buffer::TargetHint::Uniform}; PhongGL shader{PhongGL::Configuration{} .setFlags(PhongGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTextureTransformationBuffer(buffer) .bindTextureTransformationBuffer(buffer, 0, 16); CORRADE_COMPARE(out.str(), @@ -1682,12 +1677,11 @@ void PhongGLTest::bindTextureTransformBufferNotEnabled() { void PhongGLTest::setObjectIdNotEnabled() { CORRADE_SKIP_IF_NO_ASSERT(); + PhongGL shader; + std::ostringstream out; Error redirectError{&out}; - - PhongGL shader; shader.setObjectId(33376); - CORRADE_COMPARE(out.str(), "Shaders::PhongGL::setObjectId(): the shader was not created with object ID enabled\n"); } @@ -1696,10 +1690,11 @@ void PhongGLTest::setObjectIdNotEnabled() { void PhongGLTest::setWrongLightCount() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; PhongGL shader{PhongGL::Configuration{} .setLightCount(5)}; + + std::ostringstream out; + Error redirectError{&out}; shader .setLightColors({Color3{}}) .setLightPositions({Vector4{}}) @@ -1713,10 +1708,11 @@ void PhongGLTest::setWrongLightCount() { void PhongGLTest::setWrongLightId() { CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; PhongGL shader{PhongGL::Configuration{} .setLightCount(3)}; + + std::ostringstream out; + Error redirectError{&out}; shader .setLightColor(3, Color3{}) .setLightPosition(3, Vector4{}) @@ -1736,13 +1732,14 @@ void PhongGLTest::setWrongDrawOffset() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; PhongGL shader{PhongGL::Configuration{} .setFlags(PhongGL::Flag::UniformBuffers) .setLightCount(1) .setMaterialCount(2) .setDrawCount(5)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::PhongGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); diff --git a/src/Magnum/Shaders/Test/VectorGLTest.cpp b/src/Magnum/Shaders/Test/VectorGLTest.cpp index 950f6ff97..9dc2747e0 100644 --- a/src/Magnum/Shaders/Test/VectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VectorGLTest.cpp @@ -579,11 +579,11 @@ template void VectorGLTest::setUniformUniformBuffersEnab CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - VectorGL shader{typename VectorGL::Configuration{} .setFlags(VectorGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setTransformationProjectionMatrix({}) .setTextureMatrix({}) .setBackgroundColor({}) @@ -600,11 +600,11 @@ template void VectorGLTest::bindBufferUniformBuffersNotE CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; VectorGL shader; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTransformationProjectionBuffer(buffer) .bindTransformationProjectionBuffer(buffer, 0, 16) .bindDrawBuffer(buffer) @@ -632,12 +632,11 @@ template void VectorGLTest::setTextureMatrixNotEnabled() CORRADE_SKIP_IF_NO_ASSERT(); + VectorGL shader; + std::ostringstream out; Error redirectError{&out}; - - VectorGL shader; shader.setTextureMatrix({}); - CORRADE_COMPARE(out.str(), "Shaders::VectorGL::setTextureMatrix(): the shader was not created with texture transformation enabled\n"); } @@ -653,12 +652,12 @@ template void VectorGLTest::bindTextureTransformBufferNo CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer{GL::Buffer::TargetHint::Uniform}; VectorGL shader{typename VectorGL::Configuration{} .setFlags(VectorGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTextureTransformationBuffer(buffer) .bindTextureTransformationBuffer(buffer, 0, 16); CORRADE_COMPARE(out.str(), @@ -678,13 +677,14 @@ template void VectorGLTest::setWrongDrawOffset() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - VectorGL{typename VectorGL::Configuration{} + VectorGL shader{typename VectorGL::Configuration{} .setFlags(VectorGL::Flag::UniformBuffers) .setMaterialCount(2) - .setDrawCount(5)} - .setDrawOffset(5); + .setDrawCount(5)}; + + std::ostringstream out; + Error redirectError{&out}; + shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::VectorGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); } diff --git a/src/Magnum/Shaders/Test/VertexColorGLTest.cpp b/src/Magnum/Shaders/Test/VertexColorGLTest.cpp index f9816930b..51f1bcf7e 100644 --- a/src/Magnum/Shaders/Test/VertexColorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VertexColorGLTest.cpp @@ -499,11 +499,11 @@ template void VertexColorGLTest::setUniformUniformBuffer CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif - std::ostringstream out; - Error redirectError{&out}; - VertexColorGL shader{typename VertexColorGL::Configuration{} .setFlags(VertexColorGL::Flag::UniformBuffers)}; + + std::ostringstream out; + Error redirectError{&out}; shader.setTransformationProjectionMatrix({}); CORRADE_COMPARE(out.str(), "Shaders::VertexColorGL::setTransformationProjectionMatrix(): the shader was created with uniform buffers enabled\n"); @@ -514,11 +514,11 @@ template void VertexColorGLTest::bindBufferUniformBuffer CORRADE_SKIP_IF_NO_ASSERT(); - std::ostringstream out; - Error redirectError{&out}; - GL::Buffer buffer; VertexColorGL shader; + + std::ostringstream out; + Error redirectError{&out}; shader.bindTransformationProjectionBuffer(buffer) .bindTransformationProjectionBuffer(buffer, 0, 16) .setDrawOffset(0); @@ -538,12 +538,13 @@ template void VertexColorGLTest::setWrongDrawOffset() { CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported."); #endif + VertexColorGL shader{typename VertexColorGL::Configuration{} + .setFlags(VertexColorGL::Flag::UniformBuffers) + .setDrawCount(5)}; + std::ostringstream out; Error redirectError{&out}; - VertexColorGL{typename VertexColorGL::Configuration{} - .setFlags(VertexColorGL::Flag::UniformBuffers) - .setDrawCount(5)} - .setDrawOffset(5); + shader.setDrawOffset(5); CORRADE_COMPARE(out.str(), "Shaders::VertexColorGL::setDrawOffset(): draw offset 5 is out of bounds for 5 draws\n"); }