Magnum::GL::DynamicAttribute class

Base class for dynamic vertex attribute location and type.

Counterpart to Attribute that allows runtime specification of attribute location and base type. Note that unlike the compile-time specification, this class doesn't do any sanity verification and leaves most of the responsibility on the user.

Public types

enum class Kind: UnsignedByte { Generic, GenericNormalized, Integral, Long }
Attribute kind.
enum class Components: GLint { One = 1, Two = 2, Three = 3, Four = 4, BGRA = GL_BGRA }
Component count.
enum class DataType: GLenum { UnsignedByte = GL_UNSIGNED_BYTE, Byte = GL_BYTE, UnsignedShort = GL_UNSIGNED_SHORT, Short = GL_SHORT, UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT, Half = GL_HALF_FLOAT new in 2020.06, HalfFloat deprecated in 2020.06, Float = GL_FLOAT, Double = GL_DOUBLE, UnsignedInt10f11f11fRev = GL_UNSIGNED_INT_10F_11F_11F_REV, UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV, Int2101010Rev = GL_INT_2_10_10_10_REV }
Data type.

Constructors, destructors, conversion operators

DynamicAttribute(Kind kind, UnsignedInt location, Components components, DataType dataType) explicit
Constructor.
DynamicAttribute(Kind kind, UnsignedInt location, Components components, UnsignedInt vectors, DataType dataType) explicit new in 2020.06
Construct a matrix attribute.
DynamicAttribute(Kind kind, UnsignedInt location, Components components, UnsignedInt vectors, UnsignedInt vectorStride, DataType dataType) explicit constexpr new in 2020.06
Construct a matrix attribute with custom vector stride.
template<UnsignedInt location_, class T>
DynamicAttribute(const Attribute<location_, T>& attribute) constexpr new in 2019.10
Construct from a compile-time attribute.
DynamicAttribute(Kind kind, UnsignedInt location, VertexFormat format) explicit new in 2020.06
Construct from a generic mesh attribute type.
template<UnsignedInt location_, class T>
DynamicAttribute(const Attribute<location_, T>&, VertexFormat format) explicit new in 2020.06
Construct from a compile-time attribute with a generic mesh attribute type override.

Public functions

auto kind() const -> Kind constexpr
Attribute kind.
auto location() const -> UnsignedInt constexpr
Attribute location.
auto components() const -> Components constexpr
Component count.
auto vectors() const -> UnsignedInt constexpr new in 2020.06
Vector count.
auto vectorStride() const -> UnsignedInt constexpr new in 2020.06
Vector stride.
auto dataType() const -> DataType constexpr
Type of passed data.

Enum documentation

enum class Magnum::GL::DynamicAttribute::Kind: UnsignedByte

Attribute kind.

Specifies what kind of shader type matches the attribute.

Enumerators
Generic

Generic, matches single-precision floating-point shader type

GenericNormalized

Normalized integral, matches single-precision floating-point shader type

Integral

Integral, matches integral shader type

Long

Long, matches double-precision shader type

enum class Magnum::GL::DynamicAttribute::Components: GLint

Component count.

Count of components passed to the shader. If passing smaller count of components than corresponding type has, unspecified components are set to default values (second and third to 0, fourth to 1).

Enumerators
One

Only first component is specified. Second, third and fourth component are set to 0, 0, 1, respectively. Only for scalar and vector types, not matrices.

Two

First two components are specified. Third and fourth component are set to 0, 1, respectively. Only for two, three and four-component vector types and 2x2, 3x2 and 4x2 matrix types.

Three

First three components are specified. Fourth component is set to 1. Only for three and four-component vector types, 2x3, 3x3 and 4x3 matrix types.

Four

All four components are specified. Only for four-component vector types and 2x4, 3x4 and 4x4 matrix types.

BGRA

Four components with BGRA ordering. Only for four-component float vector type. Must be used along with DataType::UnsignedByte and Kind::GenericNormalized.

enum class Magnum::GL::DynamicAttribute::DataType: GLenum

Data type.

Type of data passed to shader.

Enumerators
UnsignedByte

Unsigned byte

Byte

Byte

UnsignedShort

Unsigned short

Short

Short

UnsignedInt

Unsigned int

Int

Int

Half new in 2020.06

Half float. Only for float attribute types.

HalfFloat

Half float.

Float

Float. Only for float attribute types.

Double

Double. Only for float and double attribute types.

UnsignedInt10f11f11fRev

Unsigned 10.11.11 packed float. Only for three-component float vector attribute type.

UnsignedInt2101010Rev

Unsigned 2.10.10.10 packed integer. Only for four-component float vector attribute type.

Int2101010Rev

Signed 2.10.10.10 packed integer. Only for four-component float vector attribute type.

Function documentation

Magnum::GL::DynamicAttribute::DynamicAttribute(Kind kind, UnsignedInt location, Components components, DataType dataType) explicit

Constructor.

Parameters
kind Attribute kind
location Attribute location
components Component count
dataType Type of passed data

Vector count is set to 1, vector stride to size of the data type times component count.

Magnum::GL::DynamicAttribute::DynamicAttribute(Kind kind, UnsignedInt location, Components components, UnsignedInt vectors, DataType dataType) explicit new in 2020.06

Construct a matrix attribute.

Parameters
kind Attribute kind
location Attribute location
components Component count
vectors Vector count
dataType Type of passed data

Vector stride is set to size of the data type times component count.

Magnum::GL::DynamicAttribute::DynamicAttribute(Kind kind, UnsignedInt location, Components components, UnsignedInt vectors, UnsignedInt vectorStride, DataType dataType) explicit constexpr new in 2020.06

Construct a matrix attribute with custom vector stride.

Parameters
kind Attribute kind
location Attribute location
components Component count
vectors Vector count
vectorStride Stride between consecutive matrix column vectors
dataType Type of passed data

Magnum::GL::DynamicAttribute::DynamicAttribute(Kind kind, UnsignedInt location, VertexFormat format) explicit new in 2020.06

Construct from a generic mesh attribute type.

The type is expected to be available on given target and be compatible with kind — i.e., normalized or floating-point for Kind::GenericNormalized, non-normalized for Kind::Integral / Kind::Long and integral for Kind::Integral.

template<UnsignedInt location_, class T>
Magnum::GL::DynamicAttribute::DynamicAttribute(const Attribute<location_, T>&, VertexFormat format) explicit new in 2020.06

Construct from a compile-time attribute with a generic mesh attribute type override.

Extracts kind and location from passed Attribute type and calls DynamicAttribute(Kind, UnsignedInt, VertexFormat). Expects that type's component count is not larger than the component count defined in the Attribute type. Note that only the compile-time-defined properties of the Attribute type are used, the instance-specific data type, options and component count is ignored.

UnsignedInt Magnum::GL::DynamicAttribute::vectors() const constexpr new in 2020.06

Vector count.

Returns 1 for non-matrix attributes.

Debug& operator<<(Debug& debug, DynamicAttribute::Kind)

Debug output operator.