Magnum::Shaders namespace

Builtin shaders.

Collection of shaders for easy prototyping and basic usage.

This library is built if MAGNUM_WITH_SHADERS is enabled when building Magnum. To use this library with CMake, request the Shaders component of the Magnum package and link to the Magnum::Shaders target:

find_package(Magnum REQUIRED Shaders)

# ...
target_link_libraries(your-app PRIVATE Magnum::Shaders)

See Downloading and building, Usage with CMake and Builtin shaders for more information.

Image FlatGL 2D 3D
Image LineGL 2D 3D

Classes

struct DistanceFieldVectorDrawUniform new in Git master
Per-draw uniform for distance field vector shaders.
template<UnsignedInt dimensions>
class DistanceFieldVectorGL new in Git master
Distance field vector OpenGL shader.
struct DistanceFieldVectorMaterialUniform new in Git master
Material uniform for distance field vector shaders.
struct FlatDrawUniform new in Git master
Per-draw uniform for flat shaders.
template<UnsignedInt dimensions>
class FlatGL new in Git master
Flat OpenGL shader.
struct FlatMaterialUniform new in Git master
Material uniform for flat shaders.
template<UnsignedInt dimensions>
struct GenericGL new in Git master
Generic OpenGL shader definition.
struct LineDrawUniform new in Git master
Per-draw uniform for line shaders.
template<UnsignedInt dimensions>
class LineGL new in Git master
Line GL shader.
struct LineMaterialUniform new in Git master
Material uniform for line shaders.
struct MeshVisualizerDrawUniform2D new in Git master
Per-draw uniform for 2D mesh visualizer shaders.
struct MeshVisualizerDrawUniform3D new in Git master
Per-draw uniform for 3D mesh visualizer shaders.
class MeshVisualizerGL2D new in Git master
2D mesh visualization OpenGL shader
class MeshVisualizerGL3D new in Git master
3D mesh visualization OpenGL shader
struct MeshVisualizerMaterialUniform new in Git master
Material uniform for mesh visualizer shaders.
struct PhongDrawUniform new in Git master
Per-draw uniform for Phong shaders.
class PhongGL new in Git master
Phong OpenGL shader.
struct PhongLightUniform new in Git master
Light parameters for Phong shaders.
struct PhongMaterialUniform new in Git master
Material uniform for Phong shaders.
struct ProjectionUniform2D new in Git master
2D projection uniform common for all shaders
struct ProjectionUniform3D new in Git master
3D projection uniform common for all shaders
struct TextureTransformationUniform new in Git master
Texture transformation uniform common for all shaders.
struct TransformationProjectionUniform2D new in Git master
Combined 2D projection and transformation uniform common for all shaders.
struct TransformationProjectionUniform3D new in Git master
Combined 3D projection and transformation uniform common for all shaders.
struct TransformationUniform2D new in Git master
2D transformation uniform common for all shaders
struct TransformationUniform3D new in Git master
3D transformation uniform common for all shaders
struct VectorDrawUniform new in Git master
Per-draw uniform for vector shaders.
template<UnsignedInt dimensions>
class VectorGL new in Git master
Vector OpenGL shader.
struct VectorMaterialUniform new in Git master
Material uniform for vector shaders.
template<UnsignedInt dimensions>
class VertexColorGL new in Git master
Vertex color OpenGL shader.

Enums

enum class LineCapStyle: UnsignedByte { Butt, Square, Round, Triangle } new in Git master
Line cap style.
enum class LineJoinStyle: UnsignedByte { Miter, Bevel } new in Git master
Line join style.
enum class LineVertexAnnotation: UnsignedInt { Up = 1 << 0, Join = 1 << 1, Begin = 1 << 2 } new in Git master
Line vertex annotation.

Typedefs

template<UnsignedInt dimensions>
using DistanceFieldVector = DistanceFieldVectorGL<dimensions> deprecated in Git master
Distance field vector OpenGL shader.
using DistanceFieldVector2D = DistanceFieldVectorGL2D deprecated in Git master
Two-dimensional distance field vector OpenGL shader.
using DistanceFieldVector3D = DistanceFieldVectorGL3D deprecated in Git master
Three-dimensional distance field vector OpenGL shader.
using DistanceFieldVectorGL2D = DistanceFieldVectorGL<2> new in Git master
Two-dimensional distance field vector OpenGL shader.
using DistanceFieldVectorGL3D = DistanceFieldVectorGL<3> new in Git master
Three-dimensional distance field vector OpenGL shader.
template<UnsignedInt dimensions>
using Flat = FlatGL<dimensions> deprecated in Git master
Flat OpenGL shader.
using Flat2D = FlatGL2D deprecated in Git master
2D flat OpenGL shader
using Flat3D = FlatGL3D deprecated in Git master
3D flat OpenGL shader
using FlatGL2D = FlatGL<2> new in Git master
2D flat OpenGL shader
using FlatGL3D = FlatGL<3> new in Git master
3D flat OpenGL shader
using GenericGL2D = GenericGL<2> new in Git master
Generic 2D OpenGL shader definition.
using GenericGL3D = GenericGL<3> new in Git master
Generic 3D OpenGL shader definition.
template<UnsignedInt dimensions>
using Generic = GenericGL<dimensions> deprecated in Git master
Generic OpenGL shader definition.
using Generic2D = GenericGL2D deprecated in Git master
Generic 2D OpenGL shader definition.
using Generic3D = GenericGL3D deprecated in Git master
Generic 3D OpenGL shader definition.
using LineVertexAnnotations = Containers::EnumSet<LineVertexAnnotation> new in Git master
Line vertex annotations.
using LineGL2D = LineGL<2> new in Git master
2D line OpenGL shader
using LineGL3D = LineGL<3> new in Git master
3D LineGL OpenGL shader
using MeshVisualizer2D = MeshVisualizerGL2D deprecated in Git master
2D mesh visualization OpenGL shader
using MeshVisualizer3D = MeshVisualizerGL3D deprecated in Git master
3D mesh visualization OpenGL shader
using MeshVisualizer = MeshVisualizerGL3D deprecated in 2020.06
3D mesh visualization OpenGL shader
using Phong = PhongGL deprecated in Git master
Phong OpenGL shader.
template<UnsignedInt dimensions>
using Vector = VectorGL<dimensions> deprecated in Git master
Vector OpenGL shader.
using Vector2D = VectorGL2D deprecated in Git master
Two-dimensional vector OpenGL shader.
using Vector3D = VectorGL3D deprecated in Git master
Three-dimensional vector OpenGL shader.
using VectorGL2D = VectorGL<2> new in Git master
Two-dimensional vector OpenGL shader.
using VectorGL3D = VectorGL<3> new in Git master
Three-dimensional vector OpenGL shader.
template<UnsignedInt dimensions>
using VertexColor = VertexColorGL<dimensions> deprecated in Git master
Vertex color OpenGL shader.
using VertexColor2D = VertexColorGL2D deprecated in Git master
2D vertex color OpenGL shader
using VertexColor3D = VertexColorGL3D deprecated in Git master
3D vertex color OpenGL shader
using VertexColorGL2D = VertexColorGL<2> new in Git master
2D vertex color OpenGL shader
using VertexColorGL3D = VertexColorGL<3> new in Git master
3D vertex color OpenGL shader

Functions

template<UnsignedInt dimensions>
auto operator<<(Debug& debug, DistanceFieldVectorGL<dimensions>::Flag value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, DistanceFieldVectorGL<dimensions>::Flags value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, FlatGL<dimensions>::Flag value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, FlatGL<dimensions>::Flags value) -> Debug&
Debug output operator.
auto operator<<(Debug& debug, LineCapStyle value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, LineJoinStyle value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, LineVertexAnnotation value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, LineVertexAnnotations value) -> Debug& new in Git master
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, LineGL<dimensions>::Flag value) -> Debug& new in Git master
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, LineGL<dimensions>::Flags value) -> Debug& new in Git master
Debug output operator.
auto operator<<(Debug& debug, MeshVisualizerGL2D::Flag value) -> Debug&
Debug output operator.
auto operator<<(Debug& debug, MeshVisualizerGL3D::Flag value) -> Debug&
Debug output operator.
auto operator<<(Debug& debug, MeshVisualizerGL2D::Flags value) -> Debug&
Debug output operator.
auto operator<<(Debug& debug, PhongGL::Flag value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, VectorGL<dimensions>::Flag value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, VectorGL<dimensions>::Flags value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, VertexColorGL<dimensions>::Flag value) -> Debug&
Debug output operator.
template<UnsignedInt dimensions>
auto operator<<(Debug& debug, VertexColorGL<dimensions>::Flags value) -> Debug&
Debug output operator.

Enum documentation

enum class Magnum::Shaders::LineCapStyle: UnsignedByte new in Git master

Line cap style.

Enumerators
Butt

Butt cap. The line is cut off right at the endpoint. Lines of zero length will be invisible.

Square

Square cap. The line is extended by half of its width past the endpoint. Lines of zero length will be shown as squares.

Round

Round cap. The line is extended by half of its width past the endpoint. It's still rendered as a quad but pixels outside of the half-circle have the background color. Lines of zero length will be shown as circles.

Triangle

Triangle cap. The line is extended by half of its width past the endpoint. It's still rendered as a quad but pixels outside of the triangle have the background color. Lines of zero length will be shown as squares rotated by 45°.

enum class Magnum::Shaders::LineJoinStyle: UnsignedByte new in Git master

Line join style.

Enumerators
Miter

Miter join. The outer edges of both line segments extend until they intersect.

B A l α C

In this style, the points A, B and C collapse to a zero-area triangle. If the miter length l would be larger than the limit set in LineGL::setMiterLengthLimit() / LineMaterialUniform::setMiterLengthLimit() or the angle between the two segments α would be less than the limit set in LineGL::setMiterAngleLimit() / LineMaterialUniform::setMiterAngleLimit(), it switches to LineJoinStyle::Bevel instead.

Bevel

Bevel join. Outer edges of both line segments are cut off at a right angle at their endpoints.

A B C

The area between points A, B and C is filled with an extra triangle.

enum class Magnum::Shaders::LineVertexAnnotation: UnsignedInt new in Git master

Line vertex annotation.

A line segment drawn by the LineGL shader consists of four vertices, first two having the LineGL::Position attribute set to the first point of the segment and second two having it set to the second point of the segment. In order to distinguish the direction in which the point should be expanded to form a quad and whether the expansion should be for a line join or line cap, each vertex contains LineVertexAnnotations in the LineGL::Annotation attribute.

U·B ··B UJ· ·J· ·JB UJB ·J· ·JB UJ· UJB U·· ···

In the above diagram, there's a line strip consisting of three line segments and six pairs of points, with green and white forming (square) line caps, while azure, red form a miter line join, and blue and yellow form a bevel join. The twelve corresponding annotations, forming three quads (and one extra triangle for the bevel), are shown with U, J and B letters, color-coded to show which original line point they correspond to. Line cap style and join style isn't a part of the annotation, it's set with LineCapStyle and LineJoinStyle at shader compilation time instead.

The type is 32-bit in order to match the default type of the LineGL::Annotation attribute, but the values are guaranteed to fit into 8 bits.

Enumerators
Up

The point extends upwards assuming a left-to-right direction of the line segment. If not set, it extends downwards. Visualized as U in the above diagram.

Join

The point is forming a join with a neighboring line segment defined by either LineGL::PreviousPosition or LineGL::NextPosition based on whether LineVertexAnnotation::Begin is set. If not set, the point is forming a line cap, extending in the opposite of the line segment direction if LineVertexAnnotation::Begin is set, and in the direction if not set. Visualized as J in the above diagram.

Begin

The point is forming the beginning of the line segment, i.e. LineGL::NextPosition contains the other point of the line segment. If not set, LineGL::PreviousPosition contains the other point of the line segment instead.

If LineVertexAnnotation::Join is set as well, the point is a common point of two neighboring line segments and LineGL::PreviousPosition contains the other point of the neighboring line segment. If LineVertexAnnotation::Join is set and this bit is not set, LineGL::NextPosition contaons the other point of the neighboring line segment instead. Visualized as B in the above diagram.

Typedef documentation

template<UnsignedInt dimensions>
using Magnum::Shaders::DistanceFieldVector = DistanceFieldVectorGL<dimensions>

Distance field vector OpenGL shader.

typedef DistanceFieldVectorGL2D Magnum::Shaders::DistanceFieldVector2D

Two-dimensional distance field vector OpenGL shader.

typedef DistanceFieldVectorGL3D Magnum::Shaders::DistanceFieldVector3D

Three-dimensional distance field vector OpenGL shader.

typedef DistanceFieldVectorGL<2> Magnum::Shaders::DistanceFieldVectorGL2D new in Git master

Two-dimensional distance field vector OpenGL shader.

typedef DistanceFieldVectorGL<3> Magnum::Shaders::DistanceFieldVectorGL3D new in Git master

Three-dimensional distance field vector OpenGL shader.

template<UnsignedInt dimensions>
using Magnum::Shaders::Flat = FlatGL<dimensions>

Flat OpenGL shader.

typedef FlatGL2D Magnum::Shaders::Flat2D

2D flat OpenGL shader

typedef FlatGL3D Magnum::Shaders::Flat3D

3D flat OpenGL shader

typedef FlatGL<2> Magnum::Shaders::FlatGL2D new in Git master

2D flat OpenGL shader

typedef FlatGL<3> Magnum::Shaders::FlatGL3D new in Git master

3D flat OpenGL shader

typedef GenericGL<2> Magnum::Shaders::GenericGL2D new in Git master

Generic 2D OpenGL shader definition.

typedef GenericGL<3> Magnum::Shaders::GenericGL3D new in Git master

Generic 3D OpenGL shader definition.

template<UnsignedInt dimensions>
using Magnum::Shaders::Generic = GenericGL<dimensions>

Generic OpenGL shader definition.

typedef GenericGL2D Magnum::Shaders::Generic2D

Generic 2D OpenGL shader definition.

typedef GenericGL3D Magnum::Shaders::Generic3D

Generic 3D OpenGL shader definition.

typedef Containers::EnumSet<LineVertexAnnotation> Magnum::Shaders::LineVertexAnnotations new in Git master

Line vertex annotations.

Contents of the LineGL::Annotation attribute. See LineVertexAnnotation for more information.

typedef LineGL<2> Magnum::Shaders::LineGL2D new in Git master

2D line OpenGL shader

typedef LineGL<3> Magnum::Shaders::LineGL3D new in Git master

3D LineGL OpenGL shader

typedef MeshVisualizerGL2D Magnum::Shaders::MeshVisualizer2D

2D mesh visualization OpenGL shader

typedef MeshVisualizerGL3D Magnum::Shaders::MeshVisualizer3D

3D mesh visualization OpenGL shader

typedef MeshVisualizerGL3D Magnum::Shaders::MeshVisualizer

3D mesh visualization OpenGL shader

typedef PhongGL Magnum::Shaders::Phong

Phong OpenGL shader.

template<UnsignedInt dimensions>
using Magnum::Shaders::Vector = VectorGL<dimensions>

Vector OpenGL shader.

typedef VectorGL2D Magnum::Shaders::Vector2D

Two-dimensional vector OpenGL shader.

typedef VectorGL3D Magnum::Shaders::Vector3D

Three-dimensional vector OpenGL shader.

typedef VectorGL<2> Magnum::Shaders::VectorGL2D new in Git master

Two-dimensional vector OpenGL shader.

typedef VectorGL<3> Magnum::Shaders::VectorGL3D new in Git master

Three-dimensional vector OpenGL shader.

template<UnsignedInt dimensions>
using Magnum::Shaders::VertexColor = VertexColorGL<dimensions>

Vertex color OpenGL shader.

typedef VertexColorGL2D Magnum::Shaders::VertexColor2D

2D vertex color OpenGL shader

typedef VertexColorGL3D Magnum::Shaders::VertexColor3D

3D vertex color OpenGL shader

typedef VertexColorGL<2> Magnum::Shaders::VertexColorGL2D new in Git master

2D vertex color OpenGL shader

typedef VertexColorGL<3> Magnum::Shaders::VertexColorGL3D new in Git master

3D vertex color OpenGL shader

Function documentation

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, DistanceFieldVectorGL<dimensions>::Flag value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, DistanceFieldVectorGL<dimensions>::Flags value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, FlatGL<dimensions>::Flag value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, FlatGL<dimensions>::Flags value)

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, LineCapStyle value) new in Git master

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, LineJoinStyle value) new in Git master

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, LineVertexAnnotation value) new in Git master

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, LineVertexAnnotations value) new in Git master

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, LineGL<dimensions>::Flag value) new in Git master

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, LineGL<dimensions>::Flags value) new in Git master

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, MeshVisualizerGL2D::Flag value)

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, MeshVisualizerGL3D::Flag value)

Debug output operator.

Debug& Magnum::Shaders::operator<<(Debug& debug, PhongGL::Flag value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, VectorGL<dimensions>::Flag value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, VectorGL<dimensions>::Flags value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, VertexColorGL<dimensions>::Flag value)

Debug output operator.

template<UnsignedInt dimensions>
Debug& Magnum::Shaders::operator<<(Debug& debug, VertexColorGL<dimensions>::Flags value)

Debug output operator.