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

53
doc/generated/shaders.cpp

@ -154,14 +154,15 @@ namespace {
}
std::string ShaderVisualizer::phong() {
MeshTools::compile(Primitives::uvSphereSolid(16, 32)).draw(Shaders::Phong{}
Shaders::Phong{}
.setAmbientColor(0x22272e_srgbf)
.setDiffuseColor(BaseColor)
.setShininess(200.0f)
.setLightPosition({5.0f, 5.0f, 7.0f})
.setProjectionMatrix(Projection)
.setTransformationMatrix(Transformation)
.setNormalMatrix(Transformation.normalMatrix()));
.setNormalMatrix(Transformation.normalMatrix())
.draw(MeshTools::compile(Primitives::uvSphereSolid(16, 32)));
return "phong.png";
}
@ -171,21 +172,22 @@ std::string ShaderVisualizer::meshVisualizer() {
Matrix4::rotationZ(13.7_degf)*
Matrix4::rotationX(-12.6_degf);
MeshTools::compile(Primitives::icosphereSolid(1))
.draw(Shaders::MeshVisualizer{Shaders::MeshVisualizer::Flag::Wireframe}
.setColor(BaseColor)
.setWireframeColor(OutlineColor)
.setWireframeWidth(2.0f)
.setViewportSize(Vector2{ImageSize})
.setTransformationProjectionMatrix(projection));
Shaders::MeshVisualizer{Shaders::MeshVisualizer::Flag::Wireframe}
.setColor(BaseColor)
.setWireframeColor(OutlineColor)
.setWireframeWidth(2.0f)
.setViewportSize(Vector2{ImageSize})
.setTransformationProjectionMatrix(projection)
.draw(MeshTools::compile(Primitives::icosphereSolid(1)));
return "meshvisualizer.png";
}
std::string ShaderVisualizer::flat() {
MeshTools::compile(Primitives::uvSphereSolid(16, 32)).draw(Shaders::Flat3D{}
Shaders::Flat3D{}
.setColor(BaseColor)
.setTransformationProjectionMatrix(Projection*Transformation));
.setTransformationProjectionMatrix(Projection*Transformation)
.draw(MeshTools::compile(Primitives::uvSphereSolid(16, 32)));
return "flat.png";
}
@ -213,9 +215,8 @@ std::string ShaderVisualizer::vertexColor() {
.setIndexBuffer(indices, 0, GL::MeshIndexType::UnsignedInt);
Shaders::VertexColor3D shader;
shader.setTransformationProjectionMatrix(Projection*Transformation);
mesh.draw(shader);
shader.setTransformationProjectionMatrix(Projection*Transformation)
.draw(mesh);
return "vertexcolor.png";
}
@ -238,11 +239,11 @@ std::string ShaderVisualizer::vector() {
GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::One, GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add);
MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate))
.draw(Shaders::Vector2D{}
.setColor(BaseColor)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({}));
Shaders::Vector2D{}
.setColor(BaseColor)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({})
.draw(MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate)));
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::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::BlendEquation::Add);
MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate))
.draw(Shaders::DistanceFieldVector2D{}
.setColor(BaseColor)
.setOutlineColor(OutlineColor)
.setOutlineRange(0.6f, 0.4f)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({}));
Shaders::DistanceFieldVector2D{}
.setColor(BaseColor)
.setOutlineColor(OutlineColor)
.setOutlineRange(0.6f, 0.4f)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix({})
.draw(MeshTools::compile(Primitives::squareSolid(Primitives::SquareTextureCoords::Generate)));
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>
MyResourceManager;
struct MyShader: GL::AbstractShaderProgram {
void bindTexture(GL::Texture2D&) {}
MyShader& bindTexture(GL::Texture2D&) { return *this; }
};
/* [ResourceManager-fill] */
MyResourceManager manager;
@ -248,8 +248,9 @@ if(!cube) {
/* [ResourceManager-fill] */
/* [ResourceManager-use] */
shader->bindTexture(*texture);
cube->draw(*shader);
(*shader)
.bindTexture(*texture)
.draw(*cube);
/* [ResourceManager-use] */
}

13
doc/snippets/MagnumGL.cpp

@ -160,7 +160,7 @@ struct: GL::AbstractShaderProgram {} someShader;
GL::Buffer buffer;
GL::Mesh mesh;
// ...
mesh.draw(someShader);
someShader.draw(mesh);
{
/* Entering a section with 3rd-party OpenGL code -- clean up all state that
@ -406,9 +406,8 @@ GL::Texture2D diffuseTexture, specularTexture;
shader.setTransformationMatrix(transformation)
.setProjectionMatrix(projection)
.bindDiffuseTexture(diffuseTexture)
.bindSpecularTexture(specularTexture);
mesh.draw(shader);
.bindSpecularTexture(specularTexture)
.draw(mesh);
/* [AbstractShaderProgram-rendering] */
}
#endif
@ -832,7 +831,7 @@ GL::DebugOutput::setEnabled(
GL::DebugOutput::Severity::Notification, "Rendering a transparent mesh");
GL::Renderer::enable(GL::Renderer::Feature::Blending);
mesh.draw(shader);
shader.draw(mesh);
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::Renderer::enable(GL::Renderer::Feature::Blending);
mesh.draw(shader);
shader.draw(mesh);
GL::Renderer::disable(GL::Renderer::Feature::Blending);
/* 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");
GL::Renderer::enable(GL::Renderer::Feature::Blending);
mesh.draw(shader);
shader.draw(mesh);
GL::Renderer::disable(GL::Renderer::Feature::Blending);
group.pop();

4
doc/snippets/MagnumSceneGraph-gl.cpp

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

59
doc/snippets/MagnumShaders.cpp

@ -83,9 +83,8 @@ shader.bindDiffuseTexture(diffuseTexture)
.setLightPosition({5.0f, 5.0f, 7.0f})
.setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(projectionMatrix);
mesh.draw(shader);
.setProjectionMatrix(projectionMatrix)
.draw(mesh);
/* [shaders-rendering] */
/* [shaders-generic] */
@ -101,9 +100,8 @@ visualizerShader
.setColor(0x2f83cc_rgbf)
.setWireframeColor(0xdcdcdc_rgbf)
.setViewportSize(Vector2{GL::defaultFramebuffer.viewport().size()})
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(visualizerShader);
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [shaders-meshvisualizer] */
}
@ -140,9 +138,8 @@ shader.setColor(0x2f83cc_rgbf)
.setOutlineColor(0xdcdcdc_rgbf)
.setOutlineRange(0.6f, 0.4f)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(shader);
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [DistanceFieldVector-usage2] */
}
@ -171,9 +168,8 @@ Matrix4 projectionMatrix =
Shaders::Flat3D shader;
shader.setColor(0x2f83cc_rgbf)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(shader);
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [Flat-usage-colored2] */
}
@ -204,9 +200,8 @@ GL::Texture2D texture;
Shaders::Flat3D shader{Shaders::Flat3D::Flag::Textured};
shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.bindTexture(texture);
mesh.draw(shader);
.bindTexture(texture)
.draw(mesh);
/* [Flat-usage-textured2] */
}
@ -234,8 +229,8 @@ framebuffer.mapForDraw({
.clearColor(1, Vector4ui{0})
.bind();
shader.setObjectId(meshId);
mesh.draw(shader);
shader.setObjectId(meshId)
.draw(mesh);
/* [Flat-usage-object-id] */
/* [shaders-generic-object-id] */
@ -271,9 +266,8 @@ Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Flag::Wireframe};
shader.setColor(0x2f83cc_rgbf)
.setWireframeColor(0xdcdcdc_rgbf)
.setViewportSize(Vector2{GL::defaultFramebuffer.viewport().size()})
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(shader);
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [MeshVisualizer-usage-geom2] */
/* [MeshVisualizer-usage-no-geom-old] */
@ -310,9 +304,8 @@ Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Flag::Wireframe|
Shaders::MeshVisualizer::Flag::NoGeometryShader};
shader.setColor(0x2f83cc_rgbf)
.setWireframeColor(0xdcdcdc_rgbf)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(shader);
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [MeshVisualizer-usage-no-geom2] */
}
#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})
.setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(projectionMatrix);
mesh.draw(shader);
.setProjectionMatrix(projectionMatrix)
.draw(mesh);
/* [Phong-usage-colored2] */
}
@ -383,9 +375,8 @@ shader.bindTextures(nullptr, &diffuseTexture, &specularTexture, nullptr)
.setLightPosition({5.0f, 5.0f, 7.0f})
.setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.normalMatrix())
.setProjectionMatrix(projectionMatrix);
mesh.draw(shader);
.setProjectionMatrix(projectionMatrix)
.draw(mesh);
/* [Phong-usage-texture2] */
}
#endif
@ -430,9 +421,8 @@ GL::Texture2D texture;
Shaders::Vector2D shader;
shader.setColor(0x2f83cc_rgbf)
.bindVectorTexture(texture)
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(shader);
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [Vector-usage2] */
}
@ -461,9 +451,8 @@ Matrix4 projectionMatrix =
Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f);
Shaders::VertexColor3D shader;
shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(shader);
shader.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix)
.draw(mesh);
/* [VertexColor-usage2] */
}
#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 */
shader.setTransformationProjectionMatrix(projectionMatrix)
.setColor(0xffffff_rgbf)
.bindVectorTexture(cache.texture());
mesh.draw(shader);
.bindVectorTexture(cache.texture())
.draw(mesh);
/* [Renderer-usage1] */
/* [Renderer-usage2] */
@ -182,8 +182,8 @@ renderer.render("Hello World Countdown: 10");
/* Draw the text on the screen */
shader.setTransformationProjectionMatrix(projectionMatrix)
.setColor(0xffffff_rgbf)
.bindVectorTexture(cache.texture());
renderer.mesh().draw(shader);
.bindVectorTexture(cache.texture())
.draw(renderer.mesh());
/* [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) {
_shader->setTransformationProjectionMatrix(camera.projectionMatrix()*Implementation::forceRendererTransformation<dimensions>(transformationMatrix.transformPoint(_forcePosition), _force)*MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{_options->size()}))
.setColor(_options->color());
_mesh->draw(*_shader);
.setColor(_options->color())
.draw(*_mesh);
}
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> 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()}));
_mesh->draw(*_shader);
_shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix*MatrixTypeFor<dimensions, Float>::scaling(VectorTypeFor<dimensions, Float>{_options->size()}))
.draw(*_mesh);
}
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.draw(shader);
shader.draw(mesh);
/* release() needs to be called after querying the size to avoid zeroing it out */
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)
.bind();
FloatShader shader{"float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"};
d.setPrimitive(MeshPrimitive::Points)
.setCount(1)
.draw(shader);
.setCount(1);
FloatShader shader{"float", "vec4(valueInterpolated, 0.0, 0.0, 0.0)"};
shader.draw(d);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -663,7 +663,7 @@ Checker::Checker(AbstractShaderProgram&& shader, RenderbufferFormat format, Mesh
if(view.mesh().isIndexed()) view.setIndexRange(1);
view.draw(shader);
shader.draw(view);
}
template<class T> T Checker::get(PixelFormat format, PixelType type) {
@ -2952,8 +2952,8 @@ void MeshGLTest::resetDivisorAfterInstancedDraw() {
mesh.setInstanceCount(2)
.addVertexBufferInstanced(buffer, 1, 0, Attribute{})
.setPrimitive(MeshPrimitive::Points)
.setCount(1)
.draw(shader);
.setCount(1);
shader.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -2968,8 +2968,8 @@ void MeshGLTest::resetDivisorAfterInstancedDraw() {
mesh.setInstanceCount(1)
.addVertexBuffer(buffer, 4, Attribute{})
.setPrimitive(MeshPrimitive::Points)
.setCount(2)
.draw(shader);
.setCount(2);
shader.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -3017,7 +3017,7 @@ MultiChecker::MultiChecker(AbstractShaderProgram&& shader, Mesh& mesh): framebuf
.setIndexRange(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) {

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

@ -132,8 +132,7 @@ void MeshTest::drawCountNotSet() {
std::ostringstream out;
Error redirectError{&out};
Mesh mesh{NoCreate};
mesh.draw(Shader{NoCreate});
Shader{NoCreate}.draw(Mesh{NoCreate});
CORRADE_COMPARE(out.str(),
"GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?\n");
@ -144,8 +143,7 @@ void MeshTest::drawViewCountNotSet() {
Error redirectError{&out};
Mesh mesh{NoCreate};
MeshView view{mesh};
view.draw(Shader{NoCreate});
Shader{NoCreate}.draw(MeshView{mesh});
CORRADE_COMPARE(out.str(),
"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();
Renderer::enable(Renderer::Feature::RasterizerDiscard);
mesh.draw(shader);
shader.draw(mesh);
q.end();
const bool availableBefore = q.resultAvailable();
@ -232,7 +232,7 @@ void PrimitiveQueryGLTest::primitivesGeneratedIndexed() {
q.begin(0);
Renderer::enable(Renderer::Feature::RasterizerDiscard);
mesh.draw(shader);
shader.draw(mesh);
q.end();
const UnsignedInt count = q.result<UnsignedInt>();
@ -308,9 +308,9 @@ void PrimitiveQueryGLTest::transformFeedbackPrimitivesWritten() {
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);
mesh.draw(shader);
shader.draw(mesh);
feedback.end();
q.end();
@ -389,10 +389,10 @@ void PrimitiveQueryGLTest::transformFeedbackOverflow() {
PrimitiveQuery q1{PrimitiveQuery::Target::TransformFeedbackOverflow},
q2{PrimitiveQuery::Target::TransformFeedbackOverflow};
q1.begin();
mesh.draw(shader);
shader.draw(mesh);
q1.end();
q2.begin();
mesh.draw(shader);
shader.draw(mesh);
q2.end();
feedback.end();

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

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

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

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

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

@ -289,7 +289,7 @@ void TransformFeedbackGLTest::attachBase() {
Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader);
shader.draw(mesh);
feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR();
@ -336,7 +336,7 @@ void TransformFeedbackGLTest::attachRange() {
Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader);
shader.draw(mesh);
feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR();
@ -427,7 +427,7 @@ void TransformFeedbackGLTest::attachBases() {
Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader);
shader.draw(mesh);
feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR();
@ -484,7 +484,7 @@ void TransformFeedbackGLTest::attachRanges() {
Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader);
shader.draw(mesh);
feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR();
@ -563,7 +563,7 @@ void TransformFeedbackGLTest::interleaved() {
Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(shader, TransformFeedback::PrimitiveMode::Points);
mesh.draw(shader);
shader.draw(mesh);
feedback.end();
MAGNUM_VERIFY_NO_GL_ERROR();
@ -650,7 +650,7 @@ void TransformFeedbackGLTest::draw() {
Renderer::enable(Renderer::Feature::RasterizerDiscard);
feedback.begin(xfbShader, TransformFeedback::PrimitiveMode::Points);
inputMesh.draw(xfbShader);
xfbShader.draw(inputMesh);
feedback.end();
Renderer::disable(Renderer::Feature::RasterizerDiscard);
@ -700,7 +700,7 @@ void TransformFeedbackGLTest::draw() {
PrimitiveQuery q{PrimitiveQuery::Target::PrimitivesGenerated};
q.begin();
outputMesh.draw(drawShader, feedback, DrawData[testCaseInstanceId()].stream);
drawShader.drawTransformFeedback(outputMesh, feedback, DrawData[testCaseInstanceId()].stream);
q.end();
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 */
{
_framebuffer.clear(GL::FramebufferClear::Color);
_flat2D.setColor(0xff3366_rgbf);
mesh.draw(_flat2D);
_flat2D
.setColor(0xff3366_rgbf)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -370,7 +371,7 @@ template<class T> void CompileGLTest::twoDimensions() {
/* Check with the colored shader, if we have colors */
if(data.flags & Flag::Colors) {
_framebuffer.clear(GL::FramebufferClear::Color);
mesh.draw(_color2D);
_color2D.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -382,8 +383,9 @@ template<class T> void CompileGLTest::twoDimensions() {
/* Check with the textured shader, if we have texture coords */
if(data.flags & Flag::TextureCoordinates2D) {
_framebuffer.clear(GL::FramebufferClear::Color);
_flatTextured2D.bindTexture(_texture);
mesh.draw(_flatTextured2D);
_flatTextured2D
.bindTexture(_texture)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -502,8 +504,8 @@ template<class T> void CompileGLTest::threeDimensions() {
_framebuffer.clear(GL::FramebufferClear::Color);
_flat3D
.setTransformationProjectionMatrix(projection*transformation)
.setColor(0x6633ff_rgbf);
mesh.draw(_flat3D);
.setColor(0x6633ff_rgbf)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -519,8 +521,8 @@ template<class T> void CompileGLTest::threeDimensions() {
.setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection);
mesh.draw(_phong);
.setProjectionMatrix(projection)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -539,8 +541,8 @@ template<class T> void CompileGLTest::threeDimensions() {
.setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection);
mesh.draw(_phong);
.setProjectionMatrix(projection)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -554,8 +556,8 @@ template<class T> void CompileGLTest::threeDimensions() {
.setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection);
mesh.draw(_phong);
.setProjectionMatrix(projection)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -569,8 +571,8 @@ template<class T> void CompileGLTest::threeDimensions() {
if(data.flags & Flag::Colors) {
_framebuffer.clear(GL::FramebufferClear::Color);
_color3D
.setTransformationProjectionMatrix(projection*transformation);
mesh.draw(_color3D);
.setTransformationProjectionMatrix(projection*transformation)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -585,8 +587,8 @@ template<class T> void CompileGLTest::threeDimensions() {
_framebuffer.clear(GL::FramebufferClear::Color);
_flatTextured3D
.setTransformationProjectionMatrix(projection*transformation)
.bindTexture(_texture);
mesh.draw(_flatTextured3D);
.bindTexture(_texture)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
@ -689,8 +691,8 @@ void CompileGLTest::packedAttributes() {
.setDiffuseColor(0x33ff66_rgbf)
.setTransformationMatrix(transformation)
.setNormalMatrix(transformation.normalMatrix())
.setProjectionMatrix(projection);
mesh.draw(_phong);
.setProjectionMatrix(projection)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
@ -701,8 +703,8 @@ void CompileGLTest::packedAttributes() {
/* Check colors */
_framebuffer.clear(GL::FramebufferClear::Color);
_color3D
.setTransformationProjectionMatrix(projection*transformation);
mesh.draw(_color3D);
.setTransformationProjectionMatrix(projection*transformation)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
@ -714,8 +716,8 @@ void CompileGLTest::packedAttributes() {
_framebuffer.clear(GL::FramebufferClear::Color);
_flatTextured3D
.setTransformationProjectionMatrix(projection*transformation)
.bindTexture(_texture);
mesh.draw(_flatTextured3D);
.bindTexture(_texture)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
@ -869,8 +871,9 @@ void CompileGLTest::externalBuffers() {
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
_framebuffer.clear(GL::FramebufferClear::Color);
_flat2D.setColor(0xff3366_rgbf);
mesh.draw(_flat2D);
_flat2D
.setColor(0xff3366_rgbf)
.draw(mesh);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_WITH(

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

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

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

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

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

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

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

@ -284,8 +284,8 @@ void MeshVisualizerGLTest::renderTeardown() {
void MeshVisualizerGLTest::renderDefaults() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
MeshVisualizer shader;
sphere.draw(shader);
MeshVisualizer{}
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -325,7 +325,7 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
GL::Mesh sphere = MeshTools::compile(Primitives::icosphereSolid(1));
MeshVisualizer shader{MeshVisualizer::Flag::Wireframe};
sphere.draw(shader);
shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -343,8 +343,9 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
}
/** @todo make this unnecessary */
shader.setViewportSize({80, 80});
sphere.draw(shader);
shader
.setViewportSize({80, 80})
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -360,14 +361,14 @@ void MeshVisualizerGLTest::renderDefaultsWireframe() {
void MeshVisualizerGLTest::render() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
MeshVisualizer shader;
shader.setColor(0x9999ff_rgbf)
MeshVisualizer{}
.setColor(0x9999ff_rgbf)
.setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf));
sphere.draw(shader);
Matrix4::rotationX(15.0_degf))
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -429,8 +430,8 @@ void MeshVisualizerGLTest::renderWireframe() {
}
} else sphere = MeshTools::compile(sphereData);
MeshVisualizer shader{data.flags|MeshVisualizer::Flag::Wireframe};
shader.setColor(0xffff99_rgbf)
MeshVisualizer{data.flags|MeshVisualizer::Flag::Wireframe}
.setColor(0xffff99_rgbf)
.setWireframeColor(0x9999ff_rgbf)
.setWireframeWidth(data.width)
.setSmoothness(data.smoothness)
@ -439,8 +440,8 @@ void MeshVisualizerGLTest::renderWireframe() {
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf));
sphere.draw(shader);
Matrix4::rotationX(15.0_degf))
.draw(sphere);
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));
GL::Mesh sphere = MeshTools::compile(meshData);
Phong shader;
sphere.draw(shader);
Phong{}
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -544,8 +544,8 @@ void PhongGLTest::renderColored() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Phong shader{{}, 2};
shader.setLightColors({data.lightColor1, data.lightColor2})
Phong{{}, 2}
.setLightColors({data.lightColor1, data.lightColor2})
.setLightPositions({{data.lightPosition1, -3.0f, 0.0f},
{data.lightPosition2, -3.0f, 0.0f}})
.setAmbientColor(0x330033_rgbf)
@ -554,9 +554,8 @@ void PhongGLTest::renderColored() {
.setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(data.rotation))
.setNormalMatrix(Matrix4::rotationY(data.rotation).rotationScaling())
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f));
sphere.draw(shader);
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -642,7 +641,7 @@ void PhongGLTest::renderSinglePixelTextured() {
.bindDiffuseTexture(diffuse)
.bindSpecularTexture(specular);
sphere.draw(shader);
shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -742,9 +741,8 @@ void PhongGLTest::renderTextured() {
/** @todo use normalMatrix() instead */
.setNormalMatrix((Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf)).rotationScaling())
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f));
sphere.draw(shader);
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -814,7 +812,7 @@ void PhongGLTest::renderTexturedNormal() {
else
shader.bindNormalTexture(normal);
plane.draw(shader);
shader.draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -879,9 +877,9 @@ template<class T> void PhongGLTest::renderVertexColor() {
.setStorage(1, TextureFormatRGB, image->size())
.setSubImage(0, {}, *image);
Phong shader{Phong::Flag::DiffuseTexture|Phong::Flag::VertexColor, 2};
shader.setLightPositions({{-3.0f, -3.0f, 0.0f},
{ 3.0f, -3.0f, 0.0f}})
Phong{Phong::Flag::DiffuseTexture|Phong::Flag::VertexColor, 2}
.setLightPositions({{-3.0f, -3.0f, 0.0f},
{ 3.0f, -3.0f, 0.0f}})
.setTransformationMatrix(
Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)*
@ -891,8 +889,8 @@ template<class T> void PhongGLTest::renderVertexColor() {
Matrix4::rotationX(15.0_degf)).rotationScaling())
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.setDiffuseColor(0x9999ff_rgbf)
.bindDiffuseTexture(diffuse);
sphere.draw(shader);
.bindDiffuseTexture(diffuse)
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -917,15 +915,14 @@ void PhongGLTest::renderShininess() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Phong shader;
shader.setLightPosition({-3.0f, -3.0f, 0.0f})
Phong{}
.setLightPosition({-3.0f, -3.0f, 0.0f})
.setDiffuseColor(0xff3333_rgbf)
.setSpecularColor(data.specular)
.setShininess(data.shininess)
.setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f)))
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f));
sphere.draw(shader);
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -1071,9 +1068,9 @@ void PhongGLTest::renderAlpha() {
/* For proper Z order draw back faces first and then front faces */
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front);
sphere.draw(shader);
shader.draw(sphere);
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back);
sphere.draw(shader);
shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -1129,8 +1126,8 @@ void PhongGLTest::renderObjectId() {
GL::Mesh sphere = MeshTools::compile(Primitives::uvSphereSolid(16, 32));
Phong shader{Phong::Flag::ObjectId, 2};
shader.setLightColors({0x993366_rgbf, 0x669933_rgbf})
Phong{Phong::Flag::ObjectId, 2}
.setLightColors({0x993366_rgbf, 0x669933_rgbf})
.setLightPositions({{-3.0f, -3.0f, 0.0f},
{ 3.0f, -3.0f, 0.0f}})
.setAmbientColor(0x330033_rgbf)
@ -1138,9 +1135,8 @@ void PhongGLTest::renderObjectId() {
.setSpecularColor(0x6666ff_rgbf)
.setTransformationMatrix(Matrix4::translation(Vector3::zAxis(-2.15f)))
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.setObjectId(48526);
sphere.draw(shader);
.setObjectId(48526)
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -1233,9 +1229,9 @@ void PhongGLTest::renderZeroLights() {
/* For proper Z order draw back faces first and then front faces */
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Front);
sphere.draw(shader);
shader.draw(sphere);
GL::Renderer::setFaceCullingMode(GL::Renderer::PolygonFacing::Back);
sphere.draw(shader);
shader.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();

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

@ -225,9 +225,9 @@ void VectorGLTest::renderDefaults2D() {
.setSubImage(0, {}, *image);
#endif
Vector2D shader;
shader.bindVectorTexture(texture);
square.draw(shader);
Vector2D{}
.bindVectorTexture(texture)
.draw(square);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -272,9 +272,9 @@ void VectorGLTest::renderDefaults3D() {
.setSubImage(0, {}, *image);
#endif
Vector3D shader;
shader.bindVectorTexture(texture);
plane.draw(shader);
Vector3D{}
.bindVectorTexture(texture)
.draw(plane);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -319,15 +319,14 @@ void VectorGLTest::render2D() {
.setSubImage(0, {}, *image);
#endif
Vector2D shader;
shader
Vector2D{}
.setBackgroundColor(0x9999ff_rgbf)
.setColor(0xffff99_rgbf)
.setTransformationProjectionMatrix(
Matrix3::projection({2.1f, 2.1f})*
Matrix3::rotation(5.0_degf))
.bindVectorTexture(texture);
square.draw(shader);
.bindVectorTexture(texture)
.draw(square);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -371,8 +370,7 @@ void VectorGLTest::render3D() {
.setSubImage(0, {}, *image);
#endif
Vector3D shader;
shader
Vector3D{}
.setBackgroundColor(0x9999ff_rgbf)
.setColor(0xffff99_rgbf)
.setTransformationProjectionMatrix(
@ -380,8 +378,8 @@ void VectorGLTest::render3D() {
Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationZ(15.0_degf))
.bindVectorTexture(texture);
plane.draw(shader);
.bindVectorTexture(texture)
.draw(plane);
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);
circle.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color3::Location, T>{});
VertexColor2D shader;
circle.draw(shader);
VertexColor2D{}
.draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -248,8 +248,8 @@ template<class T> void VertexColorGLTest::renderDefaults3D() {
GL::Mesh sphere = MeshTools::compile(sphereData);
sphere.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color4::Location, T>{});
VertexColor3D shader;
sphere.draw(shader);
VertexColor3D{}
.draw(sphere);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -283,9 +283,9 @@ template<class T> void VertexColorGLTest::render2D() {
GL::Mesh circle = MeshTools::compile(circleData);
circle.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color3::Location, T>{});
VertexColor2D shader;
shader.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}));
circle.draw(shader);
VertexColor2D{}
.setTransformationProjectionMatrix(Matrix3::projection({2.1f, 2.1f}))
.draw(circle);
MAGNUM_VERIFY_NO_GL_ERROR();
@ -328,13 +328,13 @@ template<class T> void VertexColorGLTest::render3D() {
GL::Mesh sphere = MeshTools::compile(sphereData);
sphere.addVertexBuffer(colors, 0, GL::Attribute<Shaders::VertexColor2D::Color4::Location, T>{});
VertexColor3D shader;
shader.setTransformationProjectionMatrix(
VertexColor3D{}
.setTransformationProjectionMatrix(
Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f)*
Matrix4::translation(Vector3::zAxis(-2.15f))*
Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf));
sphere.draw(shader);
Matrix4::rotationX(15.0_degf))
.draw(sphere);
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 */
_state->mesh.draw(_state->shader);
_state->shader.draw(_state->mesh);
}
}}

Loading…
Cancel
Save