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

Alpha / transparency is supported by the shader implicitly, but to have it working on the framebuffer, you need to enable GL::Renderer::Feature::Blending and set up the blending function. See GL::Renderer::setBlendFunction() for details.

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)
    .draw(mesh);

Base classes

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

Public types

enum class Flag: UnsignedByte { TextureTransformation = 1 << 0 new in Git master } new in Git master
Flag.
using Flags = Containers::EnumSet<Flag> new in Git master
Flags.

Constructors, destructors, conversion operators

Vector(Flags flags = {}) explicit
Constructor.
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 flags() const -> Flags new in Git master
Flags.
auto setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) -> Vector<dimensions>&
Set transformation and projection matrix.
auto setTextureMatrix(const Matrix3& matrix) -> Vector<dimensions>& new in Git master
Set texture coordinate transformation matrix.
auto setBackgroundColor(const Color4& color) -> Vector<dimensions>&
Set background color.
auto setColor(const Color4& color) -> Vector<dimensions>&
Set fill color.

Enum documentation

template<UnsignedInt dimensions>
enum class Magnum::Shaders::Vector<dimensions>::Flag: UnsignedByte new in Git master

Flag.

Enumerators
TextureTransformation new in Git master

Enable texture coordinate transformation.

Typedef documentation

template<UnsignedInt dimensions>
typedef Containers::EnumSet<Flag> Magnum::Shaders::Vector<dimensions>::Flags new in Git master

Flags.

Function documentation

template<UnsignedInt dimensions>
Magnum::Shaders::Vector<dimensions>::Vector(Flags flags = {}) explicit

Constructor.

Parameters
flags Flags

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>::setTextureMatrix(const Matrix3& matrix) new in Git master

Set texture coordinate transformation matrix.

Returns Reference to self (for method chaining)

Expects that the shader was created with Flag::TextureTransformation enabled. Initial value 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.

template<UnsignedInt dimensions> template<UnsignedInt dimensions>
Debug& operator<<(Debug& debug, Vector<dimensions>::Flag value)

Debug output operator.

template<UnsignedInt dimensions> template<UnsignedInt dimensions>
Debug& operator<<(Debug& debug, Vector<dimensions>::Flags value)

Debug output operator.