Browse Source

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.
pull/499/head
Vladimír Vondruš 4 years ago
parent
commit
6dfbe038b6
  1. 28
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  2. 59
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  3. 72
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  4. 77
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  5. 34
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  6. 21
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp

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

@ -584,11 +584,11 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::setUniformUnifo
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
DistanceFieldVectorGL<dimensions> shader{typename DistanceFieldVectorGL<dimensions>::Configuration{}
.setFlags(DistanceFieldVectorGL<dimensions>::Flag::UniformBuffers)};
std::ostringstream out;
Error redirectError{&out};
shader.setTransformationProjectionMatrix({})
.setTextureMatrix({})
.setColor({})
@ -609,11 +609,11 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::bindBufferUnifo
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Error redirectError{&out};
GL::Buffer buffer;
DistanceFieldVectorGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
shader.bindTransformationProjectionBuffer(buffer)
.bindTransformationProjectionBuffer(buffer, 0, 16)
.bindDrawBuffer(buffer)
@ -641,12 +641,11 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::setTextureMatri
CORRADE_SKIP_IF_NO_ASSERT();
DistanceFieldVectorGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
DistanceFieldVectorGL<dimensions> 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<UnsignedInt dimensions> 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<dimensions> shader{typename DistanceFieldVectorGL<dimensions>::Configuration{}
.setFlags(DistanceFieldVectorGL<dimensions>::Flag::UniformBuffers)};
std::ostringstream out;
Error redirectError{&out};
shader.bindTextureTransformationBuffer(buffer)
.bindTextureTransformationBuffer(buffer, 0, 16);
CORRADE_COMPARE(out.str(),
@ -687,12 +686,13 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::setWrongDrawOff
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
DistanceFieldVectorGL<dimensions> shader{typename DistanceFieldVectorGL<dimensions>::Configuration{}
.setFlags(DistanceFieldVectorGL<dimensions>::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");

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

@ -1097,11 +1097,11 @@ template<UnsignedInt dimensions> void FlatGLTest::setUniformUniformBuffersEnable
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
FlatGL<dimensions> shader{typename FlatGL<dimensions>::Configuration{}
.setFlags(FlatGL<dimensions>::Flag::UniformBuffers)};
std::ostringstream out;
Error redirectError{&out};
shader.setTransformationProjectionMatrix({})
.setTextureMatrix({})
.setTextureLayer({})
@ -1122,11 +1122,11 @@ template<UnsignedInt dimensions> void FlatGLTest::bindBufferUniformBuffersNotEna
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Error redirectError{&out};
GL::Buffer buffer;
FlatGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
shader.bindTransformationProjectionBuffer(buffer)
.bindTransformationProjectionBuffer(buffer, 0, 16)
.bindDrawBuffer(buffer)
@ -1161,12 +1161,12 @@ template<UnsignedInt dimensions> 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<dimensions> shader{typename FlatGL<dimensions>::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<UnsignedInt dimensions> 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<dimensions> shader{typename FlatGL<dimensions>::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<UnsignedInt dimensions> void FlatGLTest::setAlphaMaskNotEnabled() {
CORRADE_SKIP_IF_NO_ASSERT();
FlatGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
FlatGL<dimensions> 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<UnsignedInt dimensions> void FlatGLTest::setTextureMatrixNotEnabled() {
CORRADE_SKIP_IF_NO_ASSERT();
FlatGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
FlatGL<dimensions> 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<UnsignedInt dimensions> void FlatGLTest::setTextureLayerNotArray() {
CORRADE_SKIP_IF_NO_ASSERT();
FlatGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
FlatGL<dimensions> 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<UnsignedInt dimensions> 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<dimensions> shader{typename FlatGL<dimensions>::Configuration{}
.setFlags(FlatGL<dimensions>::Flag::UniformBuffers)};
std::ostringstream out;
Error redirectError{&out};
shader.bindTextureTransformationBuffer(buffer)
.bindTextureTransformationBuffer(buffer, 0, 16);
CORRADE_COMPARE(out.str(),
@ -1277,12 +1274,11 @@ template<UnsignedInt dimensions> void FlatGLTest::setObjectIdNotEnabled() {
CORRADE_SKIP_IF_NO_ASSERT();
FlatGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
FlatGL<dimensions> 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<UnsignedInt dimensions> void FlatGLTest::setWrongDrawOffset() {
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
FlatGL<dimensions> shader{typename FlatGL<dimensions>::Configuration{}
.setFlags(FlatGL<dimensions>::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");

72
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");
}

77
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");

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

@ -579,11 +579,11 @@ template<UnsignedInt dimensions> void VectorGLTest::setUniformUniformBuffersEnab
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
VectorGL<dimensions> shader{typename VectorGL<dimensions>::Configuration{}
.setFlags(VectorGL<dimensions>::Flag::UniformBuffers)};
std::ostringstream out;
Error redirectError{&out};
shader.setTransformationProjectionMatrix({})
.setTextureMatrix({})
.setBackgroundColor({})
@ -600,11 +600,11 @@ template<UnsignedInt dimensions> void VectorGLTest::bindBufferUniformBuffersNotE
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Error redirectError{&out};
GL::Buffer buffer;
VectorGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
shader.bindTransformationProjectionBuffer(buffer)
.bindTransformationProjectionBuffer(buffer, 0, 16)
.bindDrawBuffer(buffer)
@ -632,12 +632,11 @@ template<UnsignedInt dimensions> void VectorGLTest::setTextureMatrixNotEnabled()
CORRADE_SKIP_IF_NO_ASSERT();
VectorGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
VectorGL<dimensions> 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<UnsignedInt dimensions> 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<dimensions> shader{typename VectorGL<dimensions>::Configuration{}
.setFlags(VectorGL<dimensions>::Flag::UniformBuffers)};
std::ostringstream out;
Error redirectError{&out};
shader.bindTextureTransformationBuffer(buffer)
.bindTextureTransformationBuffer(buffer, 0, 16);
CORRADE_COMPARE(out.str(),
@ -678,13 +677,14 @@ template<UnsignedInt dimensions> void VectorGLTest::setWrongDrawOffset() {
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
VectorGL<dimensions>{typename VectorGL<dimensions>::Configuration{}
VectorGL<dimensions> shader{typename VectorGL<dimensions>::Configuration{}
.setFlags(VectorGL<dimensions>::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");
}

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

@ -499,11 +499,11 @@ template<UnsignedInt dimensions> void VertexColorGLTest::setUniformUniformBuffer
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
std::ostringstream out;
Error redirectError{&out};
VertexColorGL<dimensions> shader{typename VertexColorGL<dimensions>::Configuration{}
.setFlags(VertexColorGL<dimensions>::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<UnsignedInt dimensions> void VertexColorGLTest::bindBufferUniformBuffer
CORRADE_SKIP_IF_NO_ASSERT();
std::ostringstream out;
Error redirectError{&out};
GL::Buffer buffer;
VertexColorGL<dimensions> shader;
std::ostringstream out;
Error redirectError{&out};
shader.bindTransformationProjectionBuffer(buffer)
.bindTransformationProjectionBuffer(buffer, 0, 16)
.setDrawOffset(0);
@ -538,12 +538,13 @@ template<UnsignedInt dimensions> void VertexColorGLTest::setWrongDrawOffset() {
CORRADE_SKIP(GL::Extensions::ARB::uniform_buffer_object::string() << "is not supported.");
#endif
VertexColorGL<dimensions> shader{typename VertexColorGL<dimensions>::Configuration{}
.setFlags(VertexColorGL<dimensions>::Flag::UniformBuffers)
.setDrawCount(5)};
std::ostringstream out;
Error redirectError{&out};
VertexColorGL<dimensions>{typename VertexColorGL<dimensions>::Configuration{}
.setFlags(VertexColorGL<dimensions>::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");
}

Loading…
Cancel
Save