template<UnsignedInt location, class T>
Attribute class
Base class for attribute location and type.
Contents
For use in AbstractShaderProgram subclasses. Template parameter location
is vertex attribute location, number between 0
and AbstractShaderProgram::0
.
Template parameter T
is the type which is used for shader attribute, e.g. Vector4i for ivec4
. DataType is type of passed data when adding vertex buffers to mesh. By default it is the same as type used in shader (e.g. DataType::0
– 255
to 0.0f
– 1.0f
) — see DataOption::
Only some types are allowed as attribute types, see Mapping between GLSL and Magnum types for more information.
See Subclassing workflow for example usage in shaders and Mesh configuration for example usage when adding vertex buffers to mesh.
Public types
- enum (anonymous): UnsignedInt { Location = location, VectorCount = Implementation::Attribute<T>::VectorCount }
- 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, HalfFloat = GL_HALF_FLOAT, 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.
- enum class DataOption: UnsignedByte { Normalized = 1 << 0 }
- Data option.
- using Type = T
- Type.
- using ScalarType = Implementation::Attribute<T>::ScalarType
- Scalar type.
-
using DataOptions = Containers::
EnumSet<DataOption> - Data options.
Constructors, destructors, conversion operators
- Attribute(Components components, DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()) constexpr
- Constructor.
- Attribute(DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()) constexpr
- Constructor.
Public functions
- auto components() const -> Components constexpr
- Component count of passed data.
- auto dataType() const -> DataType constexpr
- Type of passed data.
- auto vectorSize() const -> UnsignedInt
- Size of each vector in passed data.
- auto dataOptions() const -> DataOptions constexpr
- Data options.
Enum documentation
template<UnsignedInt location, class T>
enum Magnum:: GL:: Attribute<location, T>:: (anonymous): UnsignedInt
Enumerators | |
---|---|
Location |
Location to which the attribute is bound |
VectorCount |
Count of vectors in this type |
template<UnsignedInt location, class T>
enum class Magnum:: GL:: Attribute<location, T>:: 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 |
Two |
First two components are specified. Third and fourth component are set to |
Three |
First three components are specified. Fourth component is set to |
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:: |
template<UnsignedInt location, class T>
enum class Magnum:: GL:: Attribute<location, T>:: 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 |
HalfFloat |
Half float. Only for float attribute types. |
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. |
template<UnsignedInt location, class T>
enum class Magnum:: GL:: Attribute<location, T>:: DataOption: UnsignedByte
Data option.
Enumerators | |
---|---|
Normalized |
Normalize integer components. Only for float attribute types. Default is to not normalize. |
Typedef documentation
template<UnsignedInt location, class T>
typedef T Magnum:: GL:: Attribute<location, T>:: Type
Type.
Type used in shader code.
template<UnsignedInt location, class T>
typedef Implementation::Attribute<T>::ScalarType Magnum:: GL:: Attribute<location, T>:: ScalarType
Scalar type.
The underlying scalar type of the attribute.
template<UnsignedInt location, class T>
typedef Containers:: EnumSet<DataOption> Magnum:: GL:: Attribute<location, T>:: DataOptions
Data options.
Function documentation
template<UnsignedInt location, class T>
Magnum:: GL:: Attribute<location, T>:: Attribute(Components components,
DataType dataType = Implementation::Attribute<T>::DefaultDataType,
DataOptions dataOptions = DataOptions()) constexpr
Constructor.
Parameters | |
---|---|
components | Component count |
dataType | Type of passed data. Default is the same as type used in shader (e.g. DataType:: |
dataOptions | Data options. Default is no options. |
template<UnsignedInt location, class T>
Magnum:: GL:: Attribute<location, T>:: Attribute(DataType dataType = Implementation::Attribute<T>::DefaultDataType,
DataOptions dataOptions = DataOptions()) constexpr
Constructor.
Parameters | |
---|---|
dataType | Type of passed data. Default is the same as type used in shader (e.g. DataType:: |
dataOptions | Data options. Default is no options. |
Component count is set to the same value as in type used in shader (e.g. Components::
template<UnsignedInt location, class T>
UnsignedInt Magnum:: GL:: Attribute<location, T>:: vectorSize() const
Size of each vector in passed data.
template<UnsignedInt location, class T>
template<class T>
Debug& operator<<(Debug& debug,
Attribute<T>::Components)
Debug output operator.
template<UnsignedInt location, class T>
template<class T>
Debug& operator<<(Debug& debug,
Attribute<T>::DataType)
Debug output operator.