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.


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,

Common rendering setup:

Matrix3 transformationMatrix, projectionMatrix;
GL::Texture2D texture;

Shaders::Vector2D 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>&&) defaulted noexcept
Move constructor.

Public functions

auto operator=(const Vector<dimensions>&) -> Vector<dimensions>& deleted
Copying is not allowed.
auto operator=(Vector<dimensions>&&) -> Vector<dimensions>& defaulted noexcept
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 a 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. However note that this is a low-level and a potentially dangerous API, see the documentation of NoCreate for alternatives.

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.