template<UnsignedInt dimensions>
Magnum::Shaders::Vector class

Vector shader.

Renders vector art in plain grayscale form. See also DistanceFieldVector for more advanced effects. For rendering an unchanged texture you can use the Flat shader. You need to provide the Position and TextureCoordinates attributes in your triangle mesh and call at least bindVectorTexture(). By default, the shader renders the texture with a white color in an identity transformation. Use setTransformationProjectionMatrix(), setColor() and others to configure the shader.

Image

Example usage

Common mesh setup:

struct Vertex {
    Vector2 position;
    Vector2 textureCoordinates;
};
Vertex data[60]{
    // ...
};

GL::Buffer vertices;
vertices.setData(data, GL::BufferUsage::StaticDraw);

GL::Mesh mesh;
mesh.addVertexBuffer(vertices, 0,
    Shaders::Vector2D::Position{},
    Shaders::Vector2D::TextureCoordinates{});

Common rendering setup:

Matrix3 transformationMatrix, projectionMatrix;
GL::Texture2D texture;

Shaders::Vector2D shader;
shader.setColor(0x2f83cc_rgbf)
    .bindVectorTexture(texture)
    .setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);

mesh.draw(shader);

Base classes

template<UnsignedInt dimensions>
class AbstractVector
Base for vector shaders.

Constructors, destructors, conversion operators

Vector(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
Vector(const Vector<dimensions>&) deleted
Copying is not allowed.
Vector(Vector<dimensions>&&) noexcept defaulted
Move constructor.

Public functions

auto operator=(const Vector<dimensions>&) -> Vector<dimensions>& deleted
Copying is not allowed.
auto operator=(Vector<dimensions>&&) noexcept -> Vector<dimensions>& defaulted
Move assignment.
auto setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) -> Vector<dimensions>&
Set transformation and projection matrix.
auto setBackgroundColor(const Color4& color) -> Vector<dimensions>&
Set background color.
auto setColor(const Color4& color) -> Vector<dimensions>&
Set fill color.

Function documentation

template<UnsignedInt dimensions>
Magnum::Shaders::Vector<dimensions>::Vector(NoCreateT) explicit noexcept

Construct without creating the underlying OpenGL object.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active.

template<UnsignedInt dimensions>
Vector<dimensions>& Magnum::Shaders::Vector<dimensions>::setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix)

Set transformation and projection matrix.

Returns Reference to self (for method chaining)

Default is an identity matrix.

template<UnsignedInt dimensions>
Vector<dimensions>& Magnum::Shaders::Vector<dimensions>::setBackgroundColor(const Color4& color)

Set background color.

Returns Reference to self (for method chaining)

Default is 0x00000000_rgbaf.

template<UnsignedInt dimensions>
Vector<dimensions>& Magnum::Shaders::Vector<dimensions>::setColor(const Color4& color)

Set fill color.

Returns Reference to self (for method chaining)

Default is 0xffffffff_rgbaf.