class new in Git master
#include <Magnum/Trade/MaterialData.h>
MaterialAttributeData Material attribute data.
See MaterialData for more information.
Constructors, destructors, conversion operators
- MaterialAttributeData() explicit constexpr noexcept
- Default constructor.
-
template<class T>MaterialAttributeData(Containers::
StringView name, const T& value) constexpr noexcept - Construct with a string name.
-
MaterialAttributeData(Containers::
StringView name, Containers:: StringView value) constexpr noexcept - Construct with a string name and a string value.
-
MaterialAttributeData(Containers::
StringView name, Containers:: ArrayView<const void> value) noexcept - Construct with a string name and a buffer value.
-
template<class T>MaterialAttributeData(MaterialAttribute name, const T& value) noexcept
- Construct with a predefined name.
-
MaterialAttributeData(MaterialAttribute name,
Containers::
StringView value) noexcept - Construct with a predefined name and a string value.
-
MaterialAttributeData(Containers::
StringView name, MaterialAttributeType type, const void* value) noexcept - Construct from a type-erased value.
- MaterialAttributeData(MaterialAttribute name, MaterialAttributeType type, const void* value) noexcept
- Construct with a predefined name and a type-erased value.
- MaterialAttributeData(MaterialLayer layerName) noexcept
- Construct a layer name attribute.
Public functions
- auto type() const -> MaterialAttributeType
- Attribute type.
-
auto name() const -> Containers::
StringView - Attribute name.
- auto value() const -> const void*
- Type-erased attribute value.
-
template<class T>auto value() const -> T
- Attribute value.
Function documentation
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData() explicit constexpr noexcept
Default constructor.
Leaves contents at unspecified values. Provided as a convenience for initialization of the attribute array for MaterialData, expected to be replaced with concrete values later.
template<class T>
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(Containers:: StringView name,
const T& value) constexpr noexcept
Construct with a string name.
Parameters | |
---|---|
name | Attribute name |
value | Attribute value |
The name
is expected to be non-empty and together with value
is expected to fit into 62 bytes. MaterialAttributeType is inferred from the type passed.
This function is useful in constexpr
contexts and for creating custom material attributes. For known attributes prefer to use MaterialAttributeData(MaterialAttribute, const T&) if you don't need constexpr
, as it additionally checks that given attribute has the expected type.
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(Containers:: StringView name,
Containers:: StringView value) constexpr noexcept
Construct with a string name and a string value.
Parameters | |
---|---|
name | Attribute name |
value | Attribute value |
The name
is expected to be non-empty and the combined length of name
and value
is expected to fit into 60 bytes. Type is set to MaterialAttributeType::
This function is useful in constexpr
contexts and for creating custom material attributes. For known attributes prefer to use MaterialAttributeData(MaterialAttribute, Containers::constexpr
, as it additionally checks that given attribute has the expected type.
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(Containers:: StringView name,
Containers:: ArrayView<const void> value) noexcept
Construct with a string name and a buffer value.
Parameters | |
---|---|
name | Attribute name |
value | Attribute value |
The name
is expected to be non-empty and the combined length of name
and value
is expected to fit into 61 bytes. Type is set to MaterialAttributeType::
This function is useful for creating custom material attributes. Currently there isn't any builtin MaterialAttribute with a buffer data type.
template<class T>
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(MaterialAttribute name,
const T& value) noexcept
Construct with a predefined name.
Parameters | |
---|---|
name | Attribute name |
value | Attribute value |
Compared to MaterialAttributeData(Containers::
Trade::MaterialAttributeData a{ Trade::MaterialAttribute::DiffuseColor, 0x3bd267ff_srgbaf}; Trade::MaterialAttributeData b{"DiffuseColor", 0x3bd267ff_srgbaf};
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(MaterialAttribute name,
Containers:: StringView value) noexcept
Construct with a predefined name and a string value.
Parameters | |
---|---|
name | Attribute name |
value | Attribute value |
Compared to MaterialAttributeData(Containers::
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(Containers:: StringView name,
MaterialAttributeType type,
const void* value) noexcept
Construct from a type-erased value.
Parameters | |
---|---|
name | Attribute name |
type | Attribute type |
value | Type-erased value |
The name
is expected to be non-empty.
In case type
is neither MaterialAttributeType::value
. The name
together with value
is expected to fit into 62 bytes. Note that in case of a MaterialAttributeType::
In case type
is MaterialAttributeType::value
is expected to point to a Containers::name
and value
strings is expected to fit into 60 bytes. In case type
is MaterialAttributeType::value
is expected to point to a Containers::name
and value
views is expected to fit into 61 bytes.
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(MaterialAttribute name,
MaterialAttributeType type,
const void* value) noexcept
Construct with a predefined name and a type-erased value.
Parameters | |
---|---|
name | Attribute name |
type | Attribute type |
value | Attribute value |
Compared to MaterialAttributeData(Containers::
Magnum:: Trade:: MaterialAttributeData:: MaterialAttributeData(MaterialLayer layerName) noexcept
Construct a layer name attribute.
Parameters | |
---|---|
layerName | Material layer name |
Equivalent to calling MaterialAttributeData(MaterialAttribute, Containers::layerName
.
Containers:: StringView Magnum:: Trade:: MaterialAttributeData:: name() const
Attribute name.
The returned view always has Containers::
const void* Magnum:: Trade:: MaterialAttributeData:: value() const
Type-erased attribute value.
Cast the pointer to a concrete type based on type(). Note that in case of a MaterialAttributeType::
In case of a MaterialAttributeType::const char*
(not a pointer to Containers::'\0'
bytes, thus prefer to use typed access in that case.
In case of a MaterialAttributeType::