Browse Source

Adapted all code and doc snippets to GL library changes.

pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
de9c289328
  1. 32
      doc/generated/primitives.cpp
  2. 53
      doc/generated/shaders.cpp
  3. 7
      doc/snippets/Magnum.cpp
  4. 13
      doc/snippets/MagnumGL.cpp
  5. 4
      doc/snippets/MagnumSceneGraph-gl.cpp
  6. 59
      doc/snippets/MagnumShaders.cpp
  7. 8
      doc/snippets/MagnumText.cpp
  8. 4
      src/Magnum/DebugTools/ForceRenderer.cpp
  9. 4
      src/Magnum/DebugTools/ObjectRenderer.cpp
  10. 2
      src/Magnum/DebugTools/TextureImage.cpp
  11. 18
      src/Magnum/GL/Test/MeshGLTest.cpp
  12. 6
      src/Magnum/GL/Test/MeshTest.cpp
  13. 12
      src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp
  14. 4
      src/Magnum/GL/Test/RendererGLTest.cpp
  15. 8
      src/Magnum/GL/Test/SampleQueryGLTest.cpp
  16. 14
      src/Magnum/GL/Test/TransformFeedbackGLTest.cpp
  17. 53
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  18. 3
      src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp
  19. 26
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  20. 98
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  21. 27
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  22. 58
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  23. 26
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  24. 22
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp
  25. 2
      src/Magnum/TextureTools/DistanceField.cpp

32
doc/generated/primitives.cpp

@ -193,7 +193,7 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data).draw(shader); shader.draw(MeshTools::compile(*data));
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -212,7 +212,7 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data).draw(shader); shader.draw(MeshTools::compile(*data));
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -237,7 +237,7 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data).draw(shader); shader.draw(MeshTools::compile(*data));
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -267,7 +267,7 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data).draw(shader); shader.draw(MeshTools::compile(*data));
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -302,9 +302,9 @@ int PrimitiveVisualizer::exec() {
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
/* TODO: use MeshVisualizer2D once it exists */ /* TODO: use MeshVisualizer2D once it exists */
MeshTools::compile(*data) GL::Mesh mesh = MeshTools::compile(*data);
.draw(flat) flat.draw(mesh);
.draw(wireframe2D); wireframe2D.draw(mesh);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -345,9 +345,9 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data) GL::Mesh mesh = MeshTools::compile(*data);
.draw(phong) phong.draw(mesh);
.draw(wireframe3D); wireframe3D.draw(mesh);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -368,9 +368,9 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data) GL::Mesh mesh = MeshTools::compile(*data);
.draw(shader) shader.draw(mesh);
.draw(wireframe2D); wireframe2D.draw(mesh);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});
@ -391,9 +391,9 @@ int PrimitiveVisualizer::exec() {
Containers::Optional<Trade::MeshData> data; Containers::Optional<Trade::MeshData> data;
std::tie(data, filename) = (this->*fun)(); std::tie(data, filename) = (this->*fun)();
MeshTools::compile(*data) GL::Mesh mesh = MeshTools::compile(*data);
.draw(shader) shader.draw(mesh);
.draw(wireframe3D); wireframe3D.draw(mesh);
GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color); GL::AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), GL::FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm}); Image2D result = framebuffer.read(framebuffer.viewport(), {PixelFormat::RGBA8Unorm});

53
doc/generated/shaders.cpp

@ -154,14 +154,15 @@ namespace {
} }
std::string ShaderVisualizer::phong() { std::string ShaderVisualizer::phong() {
MeshTools::compile(Primitives::uvSphereSolid(16, 32)).draw(Shaders::Phong{} Shaders::Phong{}
.setAmbientColor(0x22272e_srgbf) .setAmbientColor(0x22272e_srgbf)
.setDiffuseColor(BaseColor) .setDiffuseColor(BaseColor)
.setShininess(200.0f) .setShininess(200.0f)
.setLightPosition({5.0f, 5.0f, 7.0f}) .setLightPosition({5.0f, 5.0f, 7.0f})
.setProjectionMatrix(Projection) .setProjectionMatrix(Projection)
.setTransformationMatrix(Transformation) .setTransformationMatrix(Transformation)
.setNormalMatrix(Transformation.normalMatrix())); .setNormalMatrix(Transformation.normalMatrix())
.draw(MeshTools::compile(Primitives::uvSphereSolid(16, 32)));
return "phong.png"; return "phong.png";
} }
@ -171,21 +172,22 @@ std::string ShaderVisualizer::meshVisualizer() {
Matrix4::rotationZ(13.7_degf)* Matrix4::rotationZ(13.7_degf)*
Matrix4::rotationX(-12.6_degf); Matrix4::rotationX(-12.6_degf);
MeshTools::compile(Primitives::icosphereSolid(1)) Shaders::MeshVisualizer{Shaders::MeshVisualizer::Flag::Wireframe}
.draw(Shaders::MeshVisualizer{Shaders::MeshVisualizer::Flag::Wireframe} .setColor(BaseColor)
.setColor(BaseColor) .setWireframeColor(OutlineColor)
.setWireframeColor(OutlineColor) .setWireframeWidth(2.0f)
.setWireframeWidth(2.0f) .setViewportSize(Vector2{ImageSize})
.setViewportSize(Vector2{ImageSize}) .setTransformationProjectionMatrix(projection)
.setTransformationProjectionMatrix(projection)); .draw(MeshTools::compile(Primitives::icosphereSolid(1)));
return "meshvisualizer.png"; return "meshvisualizer.png";
} }
std::string ShaderVisualizer::flat() { std::string ShaderVisualizer::flat() {
MeshTools::compile(Primitives::uvSphereSolid(16, 32)).draw(Shaders::Flat3D{} Shaders::Flat3D{}
.setColor(BaseColor) .setColor(BaseColor)
.setTransformationProjectionMatrix(Projection*Transformation)); .setTransformationProjectionMatrix(Projection*Transformation)
.draw(MeshTools::compile(Primitives::uvSphereSolid(16, 32)));
return "flat.png"; return "flat.png";
} }
@ -213,9 +215,8 @@ std::string ShaderVisualizer::vertexColor() {
.setIndexBuffer(indices, 0, GL::MeshIndexType::UnsignedInt); .setIndexBuffer(indices, 0, GL::MeshIndexType::UnsignedInt);
Shaders::VertexColor3D shader; Shaders::VertexColor3D shader;
shader.setTransformationProjectionMatrix(Projection*Transformation); shader.setTransformationProjectionMatrix(Projection*Transformation)
.draw(mesh);
mesh.draw(shader);
return "vertexcolor.png"; return "vertexcolor.png";
} }
@ -238,11 +239,11 @@ std::string ShaderVisualizer::vector() {
GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha); GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add); GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add);
MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate)) Shaders::Vector2D{}
.draw(Shaders::Vector2D{} .setColor(BaseColor)
.setColor(BaseColor) .bindVectorTexture(texture)
.bindVectorTexture(texture) .setTransformationProjectionMatrix({})
.setTransformationProjectionMatrix({})); .draw(MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate)));
GL::Renderer::disable(GL::Renderer::Feature::Blending); GL::Renderer::disable(GL::Renderer::Feature::Blending);
@ -267,13 +268,13 @@ std::string ShaderVisualizer::distanceFieldVector() {
GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha); GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add); GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add);
MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate)) Shaders::DistanceFieldVector2D{}
.draw(Shaders::DistanceFieldVector2D{} .setColor(BaseColor)
.setColor(BaseColor) .setOutlineColor(OutlineColor)
.setOutlineColor(OutlineColor) .setOutlineRange(0.6f, 0.4f)
.setOutlineRange(0.6f, 0.4f) .bindVectorTexture(texture)
.bindVectorTexture(texture) .setTransformationProjectionMatrix({})
.setTransformationProjectionMatrix({})); .draw(MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate)));
GL::Renderer::disable(GL::Renderer::Feature::Blending); GL::Renderer::disable(GL::Renderer::Feature::Blending);

7
doc/snippets/Magnum.cpp

@ -230,7 +230,7 @@ MyResourceManager manager;
typedef ResourceManager<GL::Mesh, GL::Texture2D, GL::AbstractShaderProgram> typedef ResourceManager<GL::Mesh, GL::Texture2D, GL::AbstractShaderProgram>
MyResourceManager; MyResourceManager;
struct MyShader: GL::AbstractShaderProgram { struct MyShader: GL::AbstractShaderProgram {
void bindTexture(GL::Texture2D&) {} MyShader& bindTexture(GL::Texture2D&) { return *this; }
}; };
/* [ResourceManager-fill] */ /* [ResourceManager-fill] */
MyResourceManager manager; MyResourceManager manager;
@ -248,8 +248,9 @@ if(!cube) {
/* [ResourceManager-fill] */ /* [ResourceManager-fill] */
/* [ResourceManager-use] */ /* [ResourceManager-use] */
shader->bindTexture(*texture); (*shader)
cube->draw(*shader); .bindTexture(*texture)
.draw(*cube);
/* [ResourceManager-use] */ /* [ResourceManager-use] */
} }

13
doc/snippets/MagnumGL.cpp

@ -160,7 +160,7 @@ struct: GL::AbstractShaderProgram {} someShader;
GL::Buffer buffer; GL::Buffer buffer;
GL::Mesh mesh; GL::Mesh mesh;
// ... // ...
mesh.draw(someShader); someShader.draw(mesh);
{ {
/* Entering a section with 3rd-party OpenGL code -- clean up all state that /* Entering a section with 3rd-party OpenGL code -- clean up all state that
@ -406,9 +406,8 @@ GL::Texture2D diffuseTexture, specularTexture;
shader.setTransformationMatrix(transformation) shader.setTransformationMatrix(transformation)
.setProjectionMatrix(projection) .setProjectionMatrix(projection)
.bindDiffuseTexture(diffuseTexture) .bindDiffuseTexture(diffuseTexture)
.bindSpecularTexture(specularTexture); .bindSpecularTexture(specularTexture)
.draw(mesh);
mesh.draw(shader);
/* [AbstractShaderProgram-rendering] */ /* [AbstractShaderProgram-rendering] */
} }
#endif #endif
@ -832,7 +831,7 @@ GL::DebugOutput::setEnabled(
GL::DebugOutput::Severity::Notification, "Rendering a transparent mesh"); GL::DebugOutput::Severity::Notification, "Rendering a transparent mesh");
GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::Blending);
mesh.draw(shader); shader.draw(mesh);
GL::Renderer::disable(GL::Renderer::Feature::Blending); GL::Renderer::disable(GL::Renderer::Feature::Blending);
// ... // ...
@ -865,7 +864,7 @@ struct: GL::AbstractShaderProgram {} shader;
GL::DebugGroup group{GL::DebugGroup::Source::Application, 42, "Scene rendering"}; GL::DebugGroup group{GL::DebugGroup::Source::Application, 42, "Scene rendering"};
GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::Blending);
mesh.draw(shader); shader.draw(mesh);
GL::Renderer::disable(GL::Renderer::Feature::Blending); GL::Renderer::disable(GL::Renderer::Feature::Blending);
/* The debug group is popped automatically at the end of the scope */ /* The debug group is popped automatically at the end of the scope */
@ -882,7 +881,7 @@ GL::DebugGroup group;
group.push(GL::DebugGroup::Source::Application, 42, "Scene rendering"); group.push(GL::DebugGroup::Source::Application, 42, "Scene rendering");
GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::Blending);
mesh.draw(shader); shader.draw(mesh);
GL::Renderer::disable(GL::Renderer::Feature::Blending); GL::Renderer::disable(GL::Renderer::Feature::Blending);
group.pop(); group.pop();

4
doc/snippets/MagnumSceneGraph-gl.cpp

@ -107,8 +107,8 @@ class RedCubeDrawable: public SceneGraph::Drawable3D {
{5.0f, 5.0f, 7.0f})) {5.0f, 5.0f, 7.0f}))
.setTransformationMatrix(transformationMatrix) .setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix()) .setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(camera.projectionMatrix()); .setProjectionMatrix(camera.projectionMatrix())
_mesh.draw(_shader); .draw(_mesh);
} }
GL::Mesh _mesh; GL::Mesh _mesh;

59
doc/snippets/MagnumShaders.cpp

@ -83,9 +83,8 @@ shader.bindDiffuseTexture(diffuseTexture)
.setLightPosition({5.0f, 5.0f, 7.0f}) .setLightPosition({5.0f, 5.0f, 7.0f})
.setTransformationMatrix(transformationMatrix) .setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix()) .setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(projectionMatrix); .setProjectionMatrix(projectionMatrix)
.draw(mesh);
mesh.draw(shader);
/* [shaders-rendering] */ /* [shaders-rendering] */
/* [shaders-generic] */ /* [shaders-generic] */
@ -101,9 +100,8 @@ visualizerShader
.setColor(0x2f83cc_rgbf) .setColor(0x2f83cc_rgbf)
.setWireframeColor(0xdcdcdc_rgbf) .setWireframeColor(0xdcdcdc_rgbf)
.setViewportSize(Vector2{GL::defaultFramebuffer.viewport().size()}) .setViewportSize(Vector2{GL::defaultFramebuffer.viewport().size()})
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(visualizerShader);
/* [shaders-meshvisualizer] */ /* [shaders-meshvisualizer] */
} }
@ -140,9 +138,8 @@ shader.setColor(0x2f83cc_rgbf)
.setOutlineColor(0xdcdcdc_rgbf) .setOutlineColor(0xdcdcdc_rgbf)
.setOutlineRange(0.6f, 0.4f) .setOutlineRange(0.6f, 0.4f)
.bindVectorTexture(texture) .bindVectorTexture(texture)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(shader);
/* [DistanceFieldVector-usage2] */ /* [DistanceFieldVector-usage2] */
} }
@ -171,9 +168,8 @@ Matrix4 projectionMatrix =
Shaders::Flat3D shader; Shaders::Flat3D shader;
shader.setColor(0x2f83cc_rgbf) shader.setColor(0x2f83cc_rgbf)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(shader);
/* [Flat-usage-colored2] */ /* [Flat-usage-colored2] */
} }
@ -204,9 +200,8 @@ GL::Texture2D texture;
Shaders::Flat3D shader{Shaders::Flat3D::Flag::Textured}; Shaders::Flat3D shader{Shaders::Flat3D::Flag::Textured};
shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix) shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.bindTexture(texture); .bindTexture(texture)
.draw(mesh);
mesh.draw(shader);
/* [Flat-usage-textured2] */ /* [Flat-usage-textured2] */
} }
@ -234,8 +229,8 @@ framebuffer.mapForDraw({
.clearColor(1, Vector4ui{0}) .clearColor(1, Vector4ui{0})
.bind(); .bind();
shader.setObjectId(meshId); shader.setObjectId(meshId)
mesh.draw(shader); .draw(mesh);
/* [Flat-usage-object-id] */ /* [Flat-usage-object-id] */
/* [shaders-generic-object-id] */ /* [shaders-generic-object-id] */
@ -271,9 +266,8 @@ Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Flag::Wireframe};
shader.setColor(0x2f83cc_rgbf) shader.setColor(0x2f83cc_rgbf)
.setWireframeColor(0xdcdcdc_rgbf) .setWireframeColor(0xdcdcdc_rgbf)
.setViewportSize(Vector2{GL::defaultFramebuffer.viewport().size()}) .setViewportSize(Vector2{GL::defaultFramebuffer.viewport().size()})
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(shader);
/* [MeshVisualizer-usage-geom2] */ /* [MeshVisualizer-usage-geom2] */
/* [MeshVisualizer-usage-no-geom-old] */ /* [MeshVisualizer-usage-no-geom-old] */
@ -310,9 +304,8 @@ Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Flag::Wireframe|
Shaders::MeshVisualizer::Flag::NoGeometryShader}; Shaders::MeshVisualizer::Flag::NoGeometryShader};
shader.setColor(0x2f83cc_rgbf) shader.setColor(0x2f83cc_rgbf)
.setWireframeColor(0xdcdcdc_rgbf) .setWireframeColor(0xdcdcdc_rgbf)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(shader);
/* [MeshVisualizer-usage-no-geom2] */ /* [MeshVisualizer-usage-no-geom2] */
} }
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__*100 + __GNUC_MINOR__ >= 500 #if !defined(__GNUC__) || defined(__clang__) || __GNUC__*100 + __GNUC_MINOR__ >= 500
@ -346,9 +339,8 @@ shader.setDiffuseColor(0x2f83cc_rgbf)
.setLightPosition({5.0f, 5.0f, 7.0f}) .setLightPosition({5.0f, 5.0f, 7.0f})
.setTransformationMatrix(transformationMatrix) .setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix()) .setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(projectionMatrix); .setProjectionMatrix(projectionMatrix)
.draw(mesh);
mesh.draw(shader);
/* [Phong-usage-colored2] */ /* [Phong-usage-colored2] */
} }
@ -383,9 +375,8 @@ shader.bindTextures(nullptr, &diffuseTexture, &specularTexture, nullptr)
.setLightPosition({5.0f, 5.0f, 7.0f}) .setLightPosition({5.0f, 5.0f, 7.0f})
.setTransformationMatrix(transformationMatrix) .setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix()) .setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(projectionMatrix); .setProjectionMatrix(projectionMatrix)
.draw(mesh);
mesh.draw(shader);
/* [Phong-usage-texture2] */ /* [Phong-usage-texture2] */
} }
#endif #endif
@ -430,9 +421,8 @@ GL::Texture2D texture;
Shaders::Vector2D shader; Shaders::Vector2D shader;
shader.setColor(0x2f83cc_rgbf) shader.setColor(0x2f83cc_rgbf)
.bindVectorTexture(texture) .bindVectorTexture(texture)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(shader);
/* [Vector-usage2] */ /* [Vector-usage2] */
} }
@ -461,9 +451,8 @@ Matrix4 projectionMatrix =
Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f); Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f);
Shaders::VertexColor3D shader; Shaders::VertexColor3D shader;
shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix); shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
mesh.draw(shader);
/* [VertexColor-usage2] */ /* [VertexColor-usage2] */
} }
#endif #endif

8
doc/snippets/MagnumText.cpp

@ -167,8 +167,8 @@ std::tie(mesh, std::ignore) = Text::Renderer2D::render(*font, cache, 0.15f,
/* Draw the text on the screen */ /* Draw the text on the screen */
shader.setTransformationProjectionMatrix(projectionMatrix) shader.setTransformationProjectionMatrix(projectionMatrix)
.setColor(0xffffff_rgbf) .setColor(0xffffff_rgbf)
.bindVectorTexture(cache.texture()); .bindVectorTexture(cache.texture())
mesh.draw(shader); .draw(mesh);
/* [Renderer-usage1] */ /* [Renderer-usage1] */
/* [Renderer-usage2] */ /* [Renderer-usage2] */
@ -182,8 +182,8 @@ renderer.render("Hello World Countdown: 10");
/* Draw the text on the screen */ /* Draw the text on the screen */
shader.setTransformationProjectionMatrix(projectionMatrix) shader.setTransformationProjectionMatrix(projectionMatrix)
.setColor(0xffffff_rgbf) .setColor(0xffffff_rgbf)
.bindVectorTexture(cache.texture()); .bindVectorTexture(cache.texture())
renderer.mesh().draw(shader); .draw(renderer.mesh());
/* [Renderer-usage2] */ /* [Renderer-usage2] */
} }

4
src/Magnum/DebugTools/ForceRenderer.cpp

@ -82,8 +82,8 @@ template<UnsignedInt dimensions> ForceRenderer<dimensions>::~ForceRenderer() = d
template<UnsignedInt dimensions> void ForceRenderer<dimensions>::draw(const MatrixTypeFor<dimensions, Float>& transformationMatrix, SceneGraph::Camera<dimensions, Float>& camera) { template<UnsignedInt dimensions> void ForceRenderer<dimensions>::draw(const MatrixTypeFor<dimensions, Float>& transformationMatrix, SceneGraph::Camera<dimensions, Float>& camera) {
_shader->setTransformationProjectionMatrix(camera.projectionMatrix()*Implementation::forceRendererTransformation<dimensions>(transformationMatrix.transformPoint(_forcePosition), _force)*MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{_options->size()})) _shader->setTransformationProjectionMatrix(camera.projectionMatrix()*Implementation::forceRendererTransformation<dimensions>(transformationMatrix.transformPoint(_forcePosition), _force)*MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{_options->size()}))
.setColor(_options->color()); .setColor(_options->color())
_mesh->draw(*_shader); .draw(*_mesh);
} }
template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer<2>; template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer<2>;

4
src/Magnum/DebugTools/ObjectRenderer.cpp

@ -68,8 +68,8 @@ template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(Reso
template<UnsignedInt dimensions> ObjectRenderer<dimensions>::~ObjectRenderer() = default; template<UnsignedInt dimensions> ObjectRenderer<dimensions>::~ObjectRenderer() = default;
template<UnsignedInt dimensions> void ObjectRenderer<dimensions>::draw(const MatrixTypeFor<dimensions, Float>& transformationMatrix, SceneGraph::Camera<dimensions, Float>& camera) { template<UnsignedInt dimensions> void ObjectRenderer<dimensions>::draw(const MatrixTypeFor<dimensions, Float>& transformationMatrix, SceneGraph::Camera<dimensions, Float>& camera) {
_shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix*MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{_options->size()})); _shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix*MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{_options->size()}))
_mesh->draw(*_shader); .draw(*_mesh);
} }
template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer<2>; template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer<2>;

2
src/Magnum/DebugTools/TextureImage.cpp

@ -164,7 +164,7 @@ void textureSubImage(GL::Texture2D& texture, const Int level, const Range2Di& ra
mesh.addVertexBuffer(std::move(buffer), 0, GL::Attribute<0, Vector2>{}); mesh.addVertexBuffer(std::move(buffer), 0, GL::Attribute<0, Vector2>{});
} }
mesh.draw(shader); shader.draw(mesh);
/* release() needs to be called after querying the size to avoid zeroing it out */ /* release() needs to be called after querying the size to avoid zeroing it out */
const Vector2i imageSize = image.size(); const Vector2i imageSize = image.size();

18
src/Magnum/GL/Test/MeshGLTest.cpp

@ -395,10 +395,10 @@ void MeshGLTest::constructMove() {
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), renderbuffer) framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), renderbuffer)
.bind(); .bind();
FloatShader shader{"float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"};
d.setPrimitive(MeshPrimitive::Points) d.setPrimitive(MeshPrimitive::Points)
.setCount(1) .setCount(1);
.draw(shader); FloatShader shader{"float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"};
shader.draw(d);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -663,7 +663,7 @@ Checker::Checker(AbstractShaderProgram&& shader, RenderbufferFormat format, Mesh
if(view.mesh().isIndexed()) view.setIndexRange(1); if(view.mesh().isIndexed()) view.setIndexRange(1);
view.draw(shader); shader.draw(view);
} }
template<class T> T Checker::get(PixelFormat format, PixelType type) { template<class T> T Checker::get(PixelFormat format, PixelType type) {
@ -2952,8 +2952,8 @@ void MeshGLTest::resetDivisorAfterInstancedDraw() {
mesh.setInstanceCount(2) mesh.setInstanceCount(2)
.addVertexBufferInstanced(buffer, 1, 0, Attribute{}) .addVertexBufferInstanced(buffer, 1, 0, Attribute{})
.setPrimitive(MeshPrimitive::Points) .setPrimitive(MeshPrimitive::Points)
.setCount(1) .setCount(1);
.draw(shader); shader.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -2968,8 +2968,8 @@ void MeshGLTest::resetDivisorAfterInstancedDraw() {
mesh.setInstanceCount(1) mesh.setInstanceCount(1)
.addVertexBuffer(buffer, 4, Attribute{}) .addVertexBuffer(buffer, 4, Attribute{})
.setPrimitive(MeshPrimitive::Points) .setPrimitive(MeshPrimitive::Points)
.setCount(2) .setCount(2);
.draw(shader); shader.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -3017,7 +3017,7 @@ MultiChecker::MultiChecker(AbstractShaderProgram&& shader, Mesh& mesh): framebuf
.setIndexRange(1); .setIndexRange(1);
} else c.setBaseVertex(1); } else c.setBaseVertex(1);
MeshView::draw(shader, {a, b, c}); shader.draw({a, b, c});
} }
template<class T> T MultiChecker::get(PixelFormat format, PixelType type) { template<class T> T MultiChecker::get(PixelFormat format, PixelType type) {

6
src/Magnum/GL/Test/MeshTest.cpp

@ -132,8 +132,7 @@ void MeshTest::drawCountNotSet() {
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
Mesh mesh{NoCreate}; Shader{NoCreate}.draw(Mesh{NoCreate});
mesh.draw(Shader{NoCreate});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?\n"); "GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?\n");
@ -144,8 +143,7 @@ void MeshTest::drawViewCountNotSet() {
Error redirectError{&out}; Error redirectError{&out};
Mesh mesh{NoCreate}; Mesh mesh{NoCreate};
MeshView view{mesh}; Shader{NoCreate}.draw(MeshView{mesh});
view.draw(Shader{NoCreate});
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?\n"); "GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?\n");

12
src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp

@ -162,7 +162,7 @@ void PrimitiveQueryGLTest::primitivesGenerated() {
q.begin(); q.begin();
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
mesh.draw(shader); shader.draw(mesh);
q.end(); q.end();
const bool availableBefore = q.resultAvailable(); const bool availableBefore = q.resultAvailable();
@ -232,7 +232,7 @@ void PrimitiveQueryGLTest::primitivesGeneratedIndexed() {
q.begin(0); q.begin(0);
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
mesh.draw(shader); shader.draw(mesh);
q.end(); q.end();
const UnsignedInt count = q.result<UnsignedInt>(); const UnsignedInt count = q.result<UnsignedInt>();
@ -308,9 +308,9 @@ void PrimitiveQueryGLTest::transformFeedbackPrimitivesWritten() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
mesh.draw(shader); /* Draw once without XFB (shouldn't be counted) */ shader.draw(mesh); /* Draw once without XFB (shouldn't be counted) */
feedback.begin(shader, TransformFeedback::PrimitiveMode::Triangles); feedback.begin(shader, TransformFeedback::PrimitiveMode::Triangles);
mesh.draw(shader); shader.draw(mesh);
feedback.end(); feedback.end();
q.end(); q.end();
@ -389,10 +389,10 @@ void PrimitiveQueryGLTest::transformFeedbackOverflow() {
PrimitiveQuery q1{PrimitiveQuery::Target::TransformFeedbackOverflow}, PrimitiveQuery q1{PrimitiveQuery::Target::TransformFeedbackOverflow},
q2{PrimitiveQuery::Target::TransformFeedbackOverflow}; q2{PrimitiveQuery::Target::TransformFeedbackOverflow};
q1.begin(); q1.begin();
mesh.draw(shader); shader.draw(mesh);
q1.end(); q1.end();
q2.begin(); q2.begin();
mesh.draw(shader); shader.draw(mesh);
q2.end(); q2.end();
feedback.end(); feedback.end();

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

@ -210,8 +210,8 @@ void RendererGLTest::pointCoord() {
#endif #endif
Mesh mesh{MeshPrimitive::Points}; Mesh mesh{MeshPrimitive::Points};
mesh.setCount(1) mesh.setCount(1);
.draw(shader); shader.draw(mesh);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
Renderer::disable(Renderer::Feature::ProgramPointSize); Renderer::disable(Renderer::Feature::ProgramPointSize);

8
src/Magnum/GL/Test/SampleQueryGLTest.cpp

@ -185,7 +185,7 @@ void SampleQueryGLTest::querySamplesPassed() {
#endif #endif
q.begin(); q.begin();
mesh.draw(shader); shader.draw(mesh);
q.end(); q.end();
const bool availableBefore = q.resultAvailable(); const bool availableBefore = q.resultAvailable();
@ -236,13 +236,13 @@ void SampleQueryGLTest::conditionalRender() {
/* This should generate some samples */ /* This should generate some samples */
qYes.begin(); qYes.begin();
mesh.draw(shader); shader.draw(mesh);
qYes.end(); qYes.end();
/* Thus this should be rendered */ /* Thus this should be rendered */
qYes.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); qYes.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait);
q.begin(); q.begin();
mesh.draw(shader); shader.draw(mesh);
q.end(); q.end();
qYes.endConditionalRender(); qYes.endConditionalRender();
@ -257,7 +257,7 @@ void SampleQueryGLTest::conditionalRender() {
/* Thus this should not be rendered */ /* Thus this should not be rendered */
qNo.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); qNo.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait);
q.begin(); q.begin();
mesh.draw(shader); shader.draw(mesh);
q.end(); q.end();
qNo.endConditionalRender(); qNo.endConditionalRender();

14
src/Magnum/GL/Test/TransformFeedbackGLTest.cpp

@ -289,7 +289,7 @@ void TransformFeedbackGLTest::attachBase() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points); feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader); shader.draw(mesh);
feedback.end(); feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -336,7 +336,7 @@ void TransformFeedbackGLTest::attachRange() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points); feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader); shader.draw(mesh);
feedback.end(); feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -427,7 +427,7 @@ void TransformFeedbackGLTest::attachBases() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points); feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader); shader.draw(mesh);
feedback.end(); feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -484,7 +484,7 @@ void TransformFeedbackGLTest::attachRanges() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points); feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader); shader.draw(mesh);
feedback.end(); feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -563,7 +563,7 @@ void TransformFeedbackGLTest::interleaved() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points); feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader); shader.draw(mesh);
feedback.end(); feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -650,7 +650,7 @@ void TransformFeedbackGLTest::draw() {
Renderer::enable(Renderer::Feature::RasterizerDiscard); Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(xfbShader, TransformFeedback::PrimitiveMode::Points); feedback.begin(xfbShader, TransformFeedback::PrimitiveMode::Points);
inputMesh.draw(xfbShader); xfbShader.draw(inputMesh);
feedback.end(); feedback.end();
Renderer::disable(Renderer::Feature::RasterizerDiscard); Renderer::disable(Renderer::Feature::RasterizerDiscard);
@ -700,7 +700,7 @@ void TransformFeedbackGLTest::draw() {
PrimitiveQuery q{PrimitiveQuery::Target::PrimitivesGenerated}; PrimitiveQuery q{PrimitiveQuery::Target::PrimitivesGenerated};
q.begin(); q.begin();
outputMesh.draw(drawShader, feedback, DrawData[testCaseInstanceId()].stream); drawShader.drawTransformFeedback(outputMesh, feedback, DrawData[testCaseInstanceId()].stream);
q.end(); q.end();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -357,8 +357,9 @@ template<class T> void CompileGLTest::twoDimensions() {
/* Check with the flat shader, it should always work */ /* Check with the flat shader, it should always work */
{ {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_flat2D.setColor(0xff3366_rgbf); _flat2D
mesh.draw(_flat2D); .setColor(0xff3366_rgbf)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -370,7 +371,7 @@ template<class T> void CompileGLTest::twoDimensions() {
/* Check with the colored shader, if we have colors */ /* Check with the colored shader, if we have colors */
if(data.flags & Flag::Colors) { if(data.flags & Flag::Colors) {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
mesh.draw(_color2D); _color2D.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -382,8 +383,9 @@ template<class T> void CompileGLTest::twoDimensions() {
/* Check with the textured shader, if we have texture coords */ /* Check with the textured shader, if we have texture coords */
if(data.flags & Flag::TextureCoordinates2D) { if(data.flags & Flag::TextureCoordinates2D) {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_flatTextured2D.bindTexture(_texture); _flatTextured2D
mesh.draw(_flatTextured2D); .bindTexture(_texture)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -502,8 +504,8 @@ template<class T> void CompileGLTest::threeDimensions() {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_flat3D _flat3D
.setTransformationProjectionMatrix(projection*transformation) .setTransformationProjectionMatrix(projection*transformation)
.setColor(0x6633ff_rgbf); .setColor(0x6633ff_rgbf)
mesh.draw(_flat3D); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -519,8 +521,8 @@ template<class T> void CompileGLTest::threeDimensions() {
.setDiffuseColor(0x33ff66_rgbf) .setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation) .setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix()) .setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection); .setProjectionMatrix(projection)
mesh.draw(_phong); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -539,8 +541,8 @@ template<class T> void CompileGLTest::threeDimensions() {
.setDiffuseColor(0x33ff66_rgbf) .setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation) .setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix()) .setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection); .setProjectionMatrix(projection)
mesh.draw(_phong); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -554,8 +556,8 @@ template<class T> void CompileGLTest::threeDimensions() {
.setDiffuseColor(0x33ff66_rgbf) .setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation) .setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix()) .setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection); .setProjectionMatrix(projection)
mesh.draw(_phong); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -569,8 +571,8 @@ template<class T> void CompileGLTest::threeDimensions() {
if(data.flags & Flag::Colors) { if(data.flags & Flag::Colors) {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_color3D _color3D
.setTransformationProjectionMatrix(projection*transformation); .setTransformationProjectionMatrix(projection*transformation)
mesh.draw(_color3D); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -585,8 +587,8 @@ template<class T> void CompileGLTest::threeDimensions() {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_flatTextured3D _flatTextured3D
.setTransformationProjectionMatrix(projection*transformation) .setTransformationProjectionMatrix(projection*transformation)
.bindTexture(_texture); .bindTexture(_texture)
mesh.draw(_flatTextured3D); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
@ -689,8 +691,8 @@ void CompileGLTest::packedAttributes() {
.setDiffuseColor(0x33ff66_rgbf) .setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation) .setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix()) .setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection); .setProjectionMatrix(projection)
mesh.draw(_phong); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
@ -701,8 +703,8 @@ void CompileGLTest::packedAttributes() {
/* Check colors */ /* Check colors */
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_color3D _color3D
.setTransformationProjectionMatrix(projection*transformation); .setTransformationProjectionMatrix(projection*transformation)
mesh.draw(_color3D); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
@ -714,8 +716,8 @@ void CompileGLTest::packedAttributes() {
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_flatTextured3D _flatTextured3D
.setTransformationProjectionMatrix(projection*transformation) .setTransformationProjectionMatrix(projection*transformation)
.bindTexture(_texture); .bindTexture(_texture)
mesh.draw(_flatTextured3D); .draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}), _framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
@ -869,8 +871,9 @@ void CompileGLTest::externalBuffers() {
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found."); CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
_framebuffer.clear(GL::FramebufferClear::Color); _framebuffer.clear(GL::FramebufferClear::Color);
_flat2D.setColor(0xff3366_rgbf); _flat2D
mesh.draw(_flat2D); .setColor(0xff3366_rgbf)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH( CORRADE_COMPARE_WITH(

3
src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp

@ -123,8 +123,7 @@ void main() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
GL::Mesh mesh = fullScreenTriangle(data.version); shader.draw(fullScreenTriangle(data.version));
mesh.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -240,9 +240,9 @@ void DistanceFieldVectorGLTest::renderDefaults2D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
DistanceFieldVector2D shader; DistanceFieldVector2D{}
shader.bindVectorTexture(texture); .bindVectorTexture(texture)
square.draw(shader); .draw(square);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -296,9 +296,9 @@ void DistanceFieldVectorGLTest::renderDefaults3D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
DistanceFieldVector2D shader; DistanceFieldVector2D{}
shader.bindVectorTexture(texture); .bindVectorTexture(texture)
plane.draw(shader); .draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -355,16 +355,15 @@ void DistanceFieldVectorGLTest::render2D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
DistanceFieldVector2D shader; DistanceFieldVector2D{}
shader
/** @todo implement background color */ /** @todo implement background color */
.setColor(0xffff99_rgbf) .setColor(0xffff99_rgbf)
.setOutlineColor(0x9999ff_rgbf) .setOutlineColor(0x9999ff_rgbf)
.setOutlineRange(data.outlineRangeStart, data.outlineRangeEnd) .setOutlineRange(data.outlineRangeStart, data.outlineRangeEnd)
.setSmoothness(data.smoothness) .setSmoothness(data.smoothness)
.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})) .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
.bindVectorTexture(texture); .bindVectorTexture(texture)
square.draw(shader); .draw(square);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -412,8 +411,7 @@ void DistanceFieldVectorGLTest::render3D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
DistanceFieldVector3D shader; DistanceFieldVector3D{}
shader
/** @todo implement background color */ /** @todo implement background color */
.setColor(0xffff99_rgbf) .setColor(0xffff99_rgbf)
.setOutlineColor(0x9999ff_rgbf) .setOutlineColor(0x9999ff_rgbf)
@ -424,8 +422,8 @@ void DistanceFieldVectorGLTest::render3D() {
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationZ(15.0_degf)) Matrix4::rotationZ(15.0_degf))
.bindVectorTexture(texture); .bindVectorTexture(texture)
plane.draw(shader); .draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -347,8 +347,8 @@ void FlatGLTest::renderTeardown() {
void FlatGLTest::renderDefaults2D() { void FlatGLTest::renderDefaults2D() {
GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32)); GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32));
Flat2D shader; Flat2D{}
circle.draw(shader); .draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -367,8 +367,8 @@ void FlatGLTest::renderDefaults2D() {
void FlatGLTest::renderDefaults3D() { void FlatGLTest::renderDefaults3D() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Flat3D shader; Flat3D{}
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -387,11 +387,10 @@ void FlatGLTest::renderDefaults3D() {
void FlatGLTest::renderColored2D() { void FlatGLTest::renderColored2D() {
GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32)); GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32));
Flat2D shader; Flat2D{}
shader.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})); .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
.draw(circle);
circle.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -415,15 +414,14 @@ void FlatGLTest::renderColored2D() {
void FlatGLTest::renderColored3D() { void FlatGLTest::renderColored3D() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Flat3D shader; Flat3D{}
shader.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)); Matrix4::rotationX(15.0_degf))
.draw(sphere);
sphere.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -473,10 +471,10 @@ void FlatGLTest::renderSinglePixelTextured2D() {
.setStorage(1, TextureFormatRGBA, Vector2i{1}) .setStorage(1, TextureFormatRGBA, Vector2i{1})
.setSubImage(0, {}, diffuseImage); .setSubImage(0, {}, diffuseImage);
Flat2D shader{Flat3D::Flag::Textured}; Flat2D{Flat3D::Flag::Textured}
shader.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})) .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
.bindTexture(texture); .bindTexture(texture)
circle.draw(shader); .draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -511,14 +509,14 @@ void FlatGLTest::renderSinglePixelTextured3D() {
.setStorage(1, TextureFormatRGBA, Vector2i{1}) .setStorage(1, TextureFormatRGBA, Vector2i{1})
.setSubImage(0, {}, diffuseImage); .setSubImage(0, {}, diffuseImage);
Flat3D shader{Flat3D::Flag::Textured}; Flat3D{Flat3D::Flag::Textured}
shader.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)) Matrix4::rotationX(15.0_degf))
.bindTexture(texture); .bindTexture(texture)
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -560,13 +558,13 @@ void FlatGLTest::renderTextured2D() {
.setStorage(1, TextureFormatRGB, image->size()) .setStorage(1, TextureFormatRGB, image->size())
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
Flat2D shader{Flat2D::Flag::Textured}; Flat2D{Flat2D::Flag::Textured}
shader.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})) .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
/* Colorized. Case without a color (where it should be white) is tested /* Colorized. Case without a color (where it should be white) is tested
in renderSinglePixelTextured() */ in renderSinglePixelTextured() */
.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.bindTexture(texture); .bindTexture(texture)
circle.draw(shader); .draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -604,8 +602,8 @@ void FlatGLTest::renderTextured3D() {
.setStorage(1, TextureFormatRGB, image->size()) .setStorage(1, TextureFormatRGB, image->size())
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
Flat3D shader{Flat3D::Flag::Textured}; Flat3D{Flat3D::Flag::Textured}
shader.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
@ -613,8 +611,8 @@ void FlatGLTest::renderTextured3D() {
/* Colorized. Case without a color (where it should be white) is tested /* Colorized. Case without a color (where it should be white) is tested
in renderSinglePixelTextured() */ in renderSinglePixelTextured() */
.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.bindTexture(texture); .bindTexture(texture)
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -664,11 +662,11 @@ template<class T> void FlatGLTest::renderVertexColor2D() {
.setStorage(1, TextureFormatRGB, image->size()) .setStorage(1, TextureFormatRGB, image->size())
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
Flat2D shader{Flat2D::Flag::Textured|Flat2D::Flag::VertexColor}; Flat2D{Flat2D::Flag::Textured|Flat2D::Flag::VertexColor}
shader.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})) .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.bindTexture(texture); .bindTexture(texture)
circle.draw(shader); .draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -718,15 +716,15 @@ template<class T> void FlatGLTest::renderVertexColor3D() {
.setStorage(1, TextureFormatRGB, image->size()) .setStorage(1, TextureFormatRGB, image->size())
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
Flat3D shader{Flat3D::Flag::Textured|Flat3D::Flag::VertexColor}; Flat3D{Flat3D::Flag::Textured|Flat3D::Flag::VertexColor}
shader.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)) Matrix4::rotationX(15.0_degf))
.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.bindTexture(texture); .bindTexture(texture)
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -791,7 +789,7 @@ void FlatGLTest::renderAlpha2D() {
if(data.flags & Flat3D::Flag::AlphaMask) if(data.flags & Flat3D::Flag::AlphaMask)
shader.setAlphaMask(data.threshold); shader.setAlphaMask(data.threshold);
circle.draw(shader); shader.draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -848,9 +846,9 @@ void FlatGLTest::renderAlpha3D() {
/* For proper Z order draw back faces first and then front faces */ /* For proper Z order draw back faces first and then front faces */
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front); GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front);
sphere.draw(shader); shader.draw(sphere);
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back); GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back);
sphere.draw(shader); shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -904,12 +902,11 @@ void FlatGLTest::renderObjectId2D() {
GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32)); GL::Mesh circle = MeshTools::compile(Primitives::circle2DSolid(32));
Flat2D shader{Flat3D::Flag::ObjectId}; Flat2D{Flat3D::Flag::ObjectId}
shader.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})) .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
.setObjectId(47523); .setObjectId(47523)
.draw(circle);
circle.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -949,16 +946,15 @@ void FlatGLTest::renderObjectId3D() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Flat3D shader{Flat3D::Flag::ObjectId}; Flat3D{Flat3D::Flag::ObjectId}
shader.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)) Matrix4::rotationX(15.0_degf))
.setObjectId(48526); .setObjectId(48526)
.draw(sphere);
sphere.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -284,8 +284,8 @@ void MeshVisualizerGLTest::renderTeardown() {
void MeshVisualizerGLTest::renderDefaults() { void MeshVisualizerGLTest::renderDefaults() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
MeshVisualizer shader; MeshVisualizer{}
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -325,7 +325,7 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
GL::Mesh sphere = MeshTools::compile(Primitives::icosphereSolid(1)); GL::Mesh sphere = MeshTools::compile(Primitives::icosphereSolid(1));
MeshVisualizer shader{MeshVisualizer::Flag::Wireframe}; MeshVisualizer shader{MeshVisualizer::Flag::Wireframe};
sphere.draw(shader); shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -343,8 +343,9 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
} }
/** @todo make this unnecessary */ /** @todo make this unnecessary */
shader.setViewportSize({80, 80}); shader
sphere.draw(shader); .setViewportSize({80, 80})
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -360,14 +361,14 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
void MeshVisualizerGLTest::render() { void MeshVisualizerGLTest::render() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
MeshVisualizer shader; MeshVisualizer{}
shader.setColor(0x9999ff_rgbf) .setColor(0x9999ff_rgbf)
.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)); Matrix4::rotationX(15.0_degf))
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -429,8 +430,8 @@ void MeshVisualizerGLTest::renderWireframe() {
} }
} else sphere = MeshTools::compile(sphereData); } else sphere = MeshTools::compile(sphereData);
MeshVisualizer shader{data.flags|MeshVisualizer::Flag::Wireframe}; MeshVisualizer{data.flags|MeshVisualizer::Flag::Wireframe}
shader.setColor(0xffff99_rgbf) .setColor(0xffff99_rgbf)
.setWireframeColor(0x9999ff_rgbf) .setWireframeColor(0x9999ff_rgbf)
.setWireframeWidth(data.width) .setWireframeWidth(data.width)
.setSmoothness(data.smoothness) .setSmoothness(data.smoothness)
@ -439,8 +440,8 @@ void MeshVisualizerGLTest::renderWireframe() {
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)); Matrix4::rotationX(15.0_degf))
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -514,8 +514,8 @@ void PhongGLTest::renderDefaults() {
MeshTools::transformVectorsInPlace(transformation.inverted().transposed(), meshData.mutableAttribute<Vector3>(Trade::MeshAttribute::Normal)); MeshTools::transformVectorsInPlace(transformation.inverted().transposed(), meshData.mutableAttribute<Vector3>(Trade::MeshAttribute::Normal));
GL::Mesh sphere = MeshTools::compile(meshData); GL::Mesh sphere = MeshTools::compile(meshData);
Phong shader; Phong{}
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -544,8 +544,8 @@ void PhongGLTest::renderColored() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Phong shader{{}, 2}; Phong{{}, 2}
shader.setLightColors({data.lightColor1, data.lightColor2}) .setLightColors({data.lightColor1, data.lightColor2})
.setLightPositions({{data.lightPosition1, -3.0f, 0.0f}, .setLightPositions({{data.lightPosition1, -3.0f, 0.0f},
{data.lightPosition2, -3.0f, 0.0f}}) {data.lightPosition2, -3.0f, 0.0f}})
.setAmbientColor(0x330033_rgbf) .setAmbientColor(0x330033_rgbf)
@ -554,9 +554,8 @@ void PhongGLTest::renderColored() {
.setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f))* .setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(data.rotation)) Matrix4::rotationY(data.rotation))
.setNormalMatrix(Matrix4::rotationY(data.rotation).rotationScaling()) .setNormalMatrix(Matrix4::rotationY(data.rotation).rotationScaling())
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)); .setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.draw(sphere);
sphere.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -642,7 +641,7 @@ void PhongGLTest::renderSinglePixelTextured() {
.bindDiffuseTexture(diffuse) .bindDiffuseTexture(diffuse)
.bindSpecularTexture(specular); .bindSpecularTexture(specular);
sphere.draw(shader); shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -742,9 +741,8 @@ void PhongGLTest::renderTextured() {
/** @todo use normalMatrix() instead */ /** @todo use normalMatrix() instead */
.setNormalMatrix((Matrix4::rotationY(-15.0_degf)* .setNormalMatrix((Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)).rotationScaling()) Matrix4::rotationX(15.0_degf)).rotationScaling())
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)); .setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.draw(sphere);
sphere.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -814,7 +812,7 @@ void PhongGLTest::renderTexturedNormal() {
else else
shader.bindNormalTexture(normal); shader.bindNormalTexture(normal);
plane.draw(shader); shader.draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -879,9 +877,9 @@ template<class T> void PhongGLTest::renderVertexColor() {
.setStorage(1, TextureFormatRGB, image->size()) .setStorage(1, TextureFormatRGB, image->size())
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
Phong shader{Phong::Flag::DiffuseTexture|Phong::Flag::VertexColor, 2}; Phong{Phong::Flag::DiffuseTexture|Phong::Flag::VertexColor, 2}
shader.setLightPositions({{-3.0f, -3.0f, 0.0f}, .setLightPositions({{-3.0f, -3.0f, 0.0f},
{ 3.0f, -3.0f, 0.0f}}) { 3.0f, -3.0f, 0.0f}})
.setTransformationMatrix( .setTransformationMatrix(
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
@ -891,8 +889,8 @@ template<class T> void PhongGLTest::renderVertexColor() {
Matrix4::rotationX(15.0_degf)).rotationScaling()) Matrix4::rotationX(15.0_degf)).rotationScaling())
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)) .setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.setDiffuseColor(0x9999ff_rgbf) .setDiffuseColor(0x9999ff_rgbf)
.bindDiffuseTexture(diffuse); .bindDiffuseTexture(diffuse)
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -917,15 +915,14 @@ void PhongGLTest::renderShininess() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Phong shader; Phong{}
shader.setLightPosition({-3.0f, -3.0f, 0.0f}) .setLightPosition({-3.0f, -3.0f, 0.0f})
.setDiffuseColor(0xff3333_rgbf) .setDiffuseColor(0xff3333_rgbf)
.setSpecularColor(data.specular) .setSpecularColor(data.specular)
.setShininess(data.shininess) .setShininess(data.shininess)
.setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f))) .setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f)))
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)); .setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.draw(sphere);
sphere.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1071,9 +1068,9 @@ void PhongGLTest::renderAlpha() {
/* For proper Z order draw back faces first and then front faces */ /* For proper Z order draw back faces first and then front faces */
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front); GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front);
sphere.draw(shader); shader.draw(sphere);
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back); GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back);
sphere.draw(shader); shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1129,8 +1126,8 @@ void PhongGLTest::renderObjectId() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32)); GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Phong shader{Phong::Flag::ObjectId, 2}; Phong{Phong::Flag::ObjectId, 2}
shader.setLightColors({0x993366_rgbf, 0x669933_rgbf}) .setLightColors({0x993366_rgbf, 0x669933_rgbf})
.setLightPositions({{-3.0f, -3.0f, 0.0f}, .setLightPositions({{-3.0f, -3.0f, 0.0f},
{ 3.0f, -3.0f, 0.0f}}) { 3.0f, -3.0f, 0.0f}})
.setAmbientColor(0x330033_rgbf) .setAmbientColor(0x330033_rgbf)
@ -1138,9 +1135,8 @@ void PhongGLTest::renderObjectId() {
.setSpecularColor(0x6666ff_rgbf) .setSpecularColor(0x6666ff_rgbf)
.setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f))) .setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f)))
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)) .setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.setObjectId(48526); .setObjectId(48526)
.draw(sphere);
sphere.draw(shader);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1233,9 +1229,9 @@ void PhongGLTest::renderZeroLights() {
/* For proper Z order draw back faces first and then front faces */ /* For proper Z order draw back faces first and then front faces */
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front); GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front);
sphere.draw(shader); shader.draw(sphere);
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back); GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back);
sphere.draw(shader); shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -225,9 +225,9 @@ void VectorGLTest::renderDefaults2D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
Vector2D shader; Vector2D{}
shader.bindVectorTexture(texture); .bindVectorTexture(texture)
square.draw(shader); .draw(square);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -272,9 +272,9 @@ void VectorGLTest::renderDefaults3D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
Vector3D shader; Vector3D{}
shader.bindVectorTexture(texture); .bindVectorTexture(texture)
plane.draw(shader); .draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -319,15 +319,14 @@ void VectorGLTest::render2D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
Vector2D shader; Vector2D{}
shader
.setBackgroundColor(0x9999ff_rgbf) .setBackgroundColor(0x9999ff_rgbf)
.setColor(0xffff99_rgbf) .setColor(0xffff99_rgbf)
.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix3::projection({2.1f, 2.1f})* Matrix3::projection({2.1f, 2.1f})*
Matrix3::rotation(5.0_degf)) Matrix3::rotation(5.0_degf))
.bindVectorTexture(texture); .bindVectorTexture(texture)
square.draw(shader); .draw(square);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -371,8 +370,7 @@ void VectorGLTest::render3D() {
.setSubImage(0, {}, *image); .setSubImage(0, {}, *image);
#endif #endif
Vector3D shader; Vector3D{}
shader
.setBackgroundColor(0x9999ff_rgbf) .setBackgroundColor(0x9999ff_rgbf)
.setColor(0xffff99_rgbf) .setColor(0xffff99_rgbf)
.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
@ -380,8 +378,8 @@ void VectorGLTest::render3D() {
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationZ(15.0_degf)) Matrix4::rotationZ(15.0_degf))
.bindVectorTexture(texture); .bindVectorTexture(texture)
plane.draw(shader); .draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -207,8 +207,8 @@ template<class T> void VertexColorGLTest::renderDefaults2D() {
GL::Mesh circle = MeshTools::compile(circleData); GL::Mesh circle = MeshTools::compile(circleData);
circle.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color3::Location, T>{}); circle.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color3::Location, T>{});
VertexColor2D shader; VertexColor2D{}
circle.draw(shader); .draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -248,8 +248,8 @@ template<class T> void VertexColorGLTest::renderDefaults3D() {
GL::Mesh sphere = MeshTools::compile(sphereData); GL::Mesh sphere = MeshTools::compile(sphereData);
sphere.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color4::Location, T>{}); sphere.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color4::Location, T>{});
VertexColor3D shader; VertexColor3D{}
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -283,9 +283,9 @@ template<class T> void VertexColorGLTest::render2D() {
GL::Mesh circle = MeshTools::compile(circleData); GL::Mesh circle = MeshTools::compile(circleData);
circle.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color3::Location, T>{}); circle.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color3::Location, T>{});
VertexColor2D shader; VertexColor2D{}
shader.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f})); .setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
circle.draw(shader); .draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -328,13 +328,13 @@ template<class T> void VertexColorGLTest::render3D() {
GL::Mesh sphere = MeshTools::compile(sphereData); GL::Mesh sphere = MeshTools::compile(sphereData);
sphere.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color4::Location, T>{}); sphere.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color4::Location, T>{});
VertexColor3D shader; VertexColor3D{}
shader.setTransformationProjectionMatrix( .setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)* Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))* Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)* Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)); Matrix4::rotationX(15.0_degf))
sphere.draw(shader); .draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

2
src/Magnum/TextureTools/DistanceField.cpp

@ -216,7 +216,7 @@ void DistanceField::operator()(GL::Texture2D& input, GL::Texture2D& output, cons
} }
/* Draw the mesh */ /* Draw the mesh */
_state->mesh.draw(_state->shader); _state->shader.draw(_state->mesh);
} }
}} }}

Loading…
Cancel
Save