Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | Static Public Attributes | List of all members
om::graphics::materials::ConstantSet Class Reference

A class that stores a collection of shader constants with their associated usages. More...

#include <omGraphicsConstantSet.h>

Public Member Functions

 ConstantSet ()
 Create a new constant set object with no constants stored. More...
 
 ConstantSet (Size constantDataCapacity)
 Create a new constant set object with the specified initial capacity in bytes. More...
 
 ~ConstantSet ()
 Destroy a constant set, releasing all internal resources. More...
 
Size getConstantCount () const
 Return the number of constants that are stored in this constant set. More...
 
UBytegetConstantData (Index constantIndex)
 Return a pointer to the storage for the specified constant index. More...
 
const UBytegetConstantData (Index constantIndex) const
 Return a pointer to the storage for the specified constant index. More...
 
const AttributeTypegetConstantType (Index constantIndex) const
 Return the type of the constant at the specified index. More...
 
template<typename T >
const T * getConstant (ConstantUsage::Enum usage) const
 Return a pointer to the storage for the specified constant usage if it is part of this buffer. More...
 
template<typename T >
const T * getConstant (const ConstantUsage &usage) const
 Return a pointer to the storage for the specified constant usage if it is part of this buffer. More...
 
Bool getConstant (Index constantIndex, AttributeValue &value) const
 Get the value for the specified constant index if it is part of this buffer. More...
 
Bool getConstant (ConstantUsage::Enum usage, AttributeValue &value) const
 Get the value for the specified constant usage if it is part of this buffer. More...
 
Bool getConstant (const ConstantUsage &usage, AttributeValue &value) const
 Get the value for the specified constant usage if it is part of this buffer. More...
 
Bool getConstant (Index constantIndex, const AttributeType &outputType, void *value) const
 Get the value for the specified constant index if it is part of this buffer. More...
 
Bool getConstant (ConstantUsage::Enum usage, const AttributeType &outputType, void *value) const
 Get the value for the specified constant usage if it is part of this buffer. More...
 
Bool getConstant (const ConstantUsage &usage, const AttributeType &outputType, void *value) const
 Get the value for the specified constant usage if it is part of this buffer. More...
 
template<typename T >
Bool setConstant (ConstantUsage::Enum usage, const T &value)
 Set the value of the stored constant with the given usage. More...
 
template<typename T >
Bool setConstant (const ConstantUsage &usage, const T &value)
 Set the value of the stored constant with the given usage. More...
 
Bool setConstant (ConstantUsage::Enum usage, const AttributeValue &value)
 Set the value of the stored constant with the given usgae. More...
 
Bool setConstant (const ConstantUsage &usage, const AttributeValue &value)
 Set the value of the stored constant with the given usgae. More...
 
const ConstantUsagegetConstantUsage (Index constantIndex) const
 Return the usage of the constant at the specified index in this constant set. More...
 
void setConstantUsage (Index constantIndex, const ConstantUsage &newUsage)
 Set the usage of the constant at the specified index in this constant set. More...
 
template<typename T >
Bool addConstant (const ConstantUsage &usage, const T &value)
 Add a new constant with the specified usage and value to this constant set. More...
 
Bool addConstant (const ConstantUsage &usage, const AttributeValue &value)
 Add a new constant with the specified usage and value to this constant set. More...
 
Bool addConstant (const ConstantUsage &usage, const AttributeType &type, const void *value=((void *) 0))
 Add a new constant with the specified usage and value to this constant set. More...
 
void clearConstants ()
 Remove all stored constants from this constant set object. More...
 
Size getConstantDataSize () const
 Return the size of the constant data in bytes. More...
 
UBytegetConstantData ()
 Return a pointer to the internal array of shader constant data. More...
 
const UBytegetConstantData () const
 Return a const pointer to the internal array of shader constant data. More...
 

Static Public Attributes

static const Size DEFAULT_CONSTANT_BUFFER_SIZE = 64
 The default size of a constant set's constant buffer in bytes. More...
 
static const ResourceType RESOURCE_TYPE
 The resource type for a constant set. More...
 

Detailed Description

A class that stores a collection of shader constants with their associated usages.

This allows objects like meshes and shapes to store constants (such as color) independently of the shader pass that is used to render the object. At render time, the constant set is used as source of constant data for shader constant variables that require input for certain constant usages.

Constructor & Destructor Documentation

om::graphics::materials::ConstantSet::ConstantSet ( )

Create a new constant set object with no constants stored.

om::graphics::materials::ConstantSet::ConstantSet ( Size  constantDataCapacity)

Create a new constant set object with the specified initial capacity in bytes.

om::graphics::materials::ConstantSet::~ConstantSet ( )

Destroy a constant set, releasing all internal resources.

Member Function Documentation

Size om::graphics::materials::ConstantSet::getConstantCount ( ) const
inline

Return the number of constants that are stored in this constant set.

UByte* om::graphics::materials::ConstantSet::getConstantData ( Index  constantIndex)
inline

Return a pointer to the storage for the specified constant index.

const UByte* om::graphics::materials::ConstantSet::getConstantData ( Index  constantIndex) const
inline

Return a pointer to the storage for the specified constant index.

const AttributeType& om::graphics::materials::ConstantSet::getConstantType ( Index  constantIndex) const
inline

Return the type of the constant at the specified index.

template<typename T >
const T* om::graphics::materials::ConstantSet::getConstant ( ConstantUsage::Enum  usage) const
inline

Return a pointer to the storage for the specified constant usage if it is part of this buffer.

If the method succeeds in finds a constant with that usage that is compatible with the templated return type, a pointer to the stored value is returned. Otherwise, the method fails and returns NULL.

template<typename T >
const T* om::graphics::materials::ConstantSet::getConstant ( const ConstantUsage usage) const
inline

Return a pointer to the storage for the specified constant usage if it is part of this buffer.

If the method succeeds in finds a constant with that usage that is compatible with the templated return type, a pointer to the stored value is returned. Otherwise, the method fails and returns NULL.

Bool om::graphics::materials::ConstantSet::getConstant ( Index  constantIndex,
AttributeValue value 
) const
inline

Get the value for the specified constant index if it is part of this buffer.

If the method succeeds in finds a constant with that index, the constant's value is stored in the output parameter and the method returns TRUE. Otherwise the method has no effect and returns FALSE.

Bool om::graphics::materials::ConstantSet::getConstant ( ConstantUsage::Enum  usage,
AttributeValue value 
) const
inline

Get the value for the specified constant usage if it is part of this buffer.

If the method succeeds in finds a constant with that usage, the constant's value is stored in the output parameter and the method returns TRUE. Otherwise the method has no effect and returns FALSE.

Bool om::graphics::materials::ConstantSet::getConstant ( const ConstantUsage usage,
AttributeValue value 
) const
inline

Get the value for the specified constant usage if it is part of this buffer.

If the method succeeds in finds a constant with that usage, the constant's value is stored in the output parameter and the method returns TRUE. Otherwise the method has no effect and returns FALSE.

Bool om::graphics::materials::ConstantSet::getConstant ( Index  constantIndex,
const AttributeType outputType,
void *  value 
) const
inline

Get the value for the specified constant index if it is part of this buffer.

If the method succeeds in finds a constant with that index that is compatible with the specified value output type, the constant's value is stored in the output value parameter and the method returns TRUE. Otherwise the method has no effect and returns FALSE.

Bool om::graphics::materials::ConstantSet::getConstant ( ConstantUsage::Enum  usage,
const AttributeType outputType,
void *  value 
) const
inline

Get the value for the specified constant usage if it is part of this buffer.

If the method succeeds in finds a constant with that usage that is compatible with the specified value output type, the constant's value is stored in the output value parameter and the method returns TRUE. Otherwise the method has no effect and returns FALSE.

Bool om::graphics::materials::ConstantSet::getConstant ( const ConstantUsage usage,
const AttributeType outputType,
void *  value 
) const
inline

Get the value for the specified constant usage if it is part of this buffer.

If the method succeeds in finds a constant with that usage that is compatible with the specified value output type, the constant's value is stored in the output value parameter and the method returns TRUE. Otherwise the method has no effect and returns FALSE.

template<typename T >
Bool om::graphics::materials::ConstantSet::setConstant ( ConstantUsage::Enum  usage,
const T &  value 
)
inline

Set the value of the stored constant with the given usage.

If the method finds a stored constant with the specified usage and the given templated value type is compatible with the stored value, the constants value is set to the new value and TRUE is returned. If not found, the method adds the given constant value to the buffer as if calling addConstant(). If the value is incompatible with the usage, the method fails and FALSE is returned.

template<typename T >
Bool om::graphics::materials::ConstantSet::setConstant ( const ConstantUsage usage,
const T &  value 
)
inline

Set the value of the stored constant with the given usage.

If the method finds a stored constant with the specified usage and the given templated value type is compatible with the stored value, the constants value is set to the new value and TRUE is returned. If not found, the method adds the given constant value to the buffer as if calling addConstant(). If the value is incompatible with the usage, the method fails and FALSE is returned.

Bool om::graphics::materials::ConstantSet::setConstant ( ConstantUsage::Enum  usage,
const AttributeValue value 
)
inline

Set the value of the stored constant with the given usgae.

If the method finds a stored constant with the specified usage and the given value type is compatible with the stored value, the constants value is set to the new value and TRUE is returned. If not found, the method adds the given constant value to the buffer as if calling addConstant(). If the value is incompatible with the usage, the method fails and FALSE is returned.

Bool om::graphics::materials::ConstantSet::setConstant ( const ConstantUsage usage,
const AttributeValue value 
)
inline

Set the value of the stored constant with the given usgae.

If the method finds a stored constant with the specified usage and the given value type is compatible with the stored value, the constants value is set to the new value and TRUE is returned. If not found, the method adds the given constant value to the buffer as if calling addConstant(). If the value is incompatible with the usage, the method fails and FALSE is returned.

const ConstantUsage& om::graphics::materials::ConstantSet::getConstantUsage ( Index  constantIndex) const
inline

Return the usage of the constant at the specified index in this constant set.

void om::graphics::materials::ConstantSet::setConstantUsage ( Index  constantIndex,
const ConstantUsage newUsage 
)
inline

Set the usage of the constant at the specified index in this constant set.

template<typename T >
Bool om::graphics::materials::ConstantSet::addConstant ( const ConstantUsage usage,
const T &  value 
)
inline

Add a new constant with the specified usage and value to this constant set.

The method returns whether or not a new constant was successfully added to this buffer. The method can fail if the specified value does not have a type that is compatible with the given usage.

Bool om::graphics::materials::ConstantSet::addConstant ( const ConstantUsage usage,
const AttributeValue value 
)
inline

Add a new constant with the specified usage and value to this constant set.

The method returns whether or not a new constant was successfully added to this buffer. The method can fail if the specified value does not have a type that is compatible with the given usage.

Bool om::graphics::materials::ConstantSet::addConstant ( const ConstantUsage usage,
const AttributeType type,
const void *  value = ((void *)0) 
)
inline

Add a new constant with the specified usage and value to this constant set.

The method returns whether or not a new constant was successfully added to this buffer. The method can fail if the specified value does not have a type that is compatible with the given usage. If the value pointer is NULL, the constant value is uninitialized.

void om::graphics::materials::ConstantSet::clearConstants ( )
inline

Remove all stored constants from this constant set object.

Size om::graphics::materials::ConstantSet::getConstantDataSize ( ) const
inline

Return the size of the constant data in bytes.

UByte* om::graphics::materials::ConstantSet::getConstantData ( )
inline

Return a pointer to the internal array of shader constant data.

const UByte* om::graphics::materials::ConstantSet::getConstantData ( ) const
inline

Return a const pointer to the internal array of shader constant data.

Member Data Documentation

const Size om::graphics::materials::ConstantSet::DEFAULT_CONSTANT_BUFFER_SIZE = 64
static

The default size of a constant set's constant buffer in bytes.

const ResourceType om::graphics::materials::ConstantSet::RESOURCE_TYPE
static

The resource type for a constant set.


The documentation for this class was generated from the following file: