VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Classes | Public Types | Public Member Functions | List of all members
AttributeArray< T > Class Template Reference

A helper class to access and iterate over an interleaved vertex attribute array. More...

Classes

class  Iterator
 An iterator over a vertex attribute array. More...
 

Public Types

typedef Iterator iterator
 
typedef const Iterator const_iterator
 

Public Member Functions

 AttributeArray ()
 Constructs an attribute array which is marked as invalid. More...
 
 AttributeArray (int count, GLbyte *arrayBase, int stride, const Attribute *attribute)
 Constructs an attribute array which points to a buffer in memory. More...
 
bool isValid () const
 Returns whether this attribute array points to a valid array and can be accessed. More...
 
const AttributegetAttribute () const
 Gets the definition of the attributes in this array. More...
 
const T & operator[] (int index) const
 Gets a constant reference to the element at the given index. More...
 
T & operator[] (int index)
 Gets a mutable reference to the element at the given index. More...
 
const Iterator begin () const
 Gets a const iterator pointing to the beginning of the array. More...
 
Iterator begin ()
 Gets an iterator pointing to the beginning of the array. More...
 
const Iterator end () const
 Gets a const iterator pointing to immediately beyond the last element of the array. More...
 
Iterator end ()
 Gets an iterator pointing to immediately beyond the last element of the array. More...
 
template<typename Y >
AttributeArray< Y > getAsType () const
 Reinterprets this array as an array of a different type. More...
 

Detailed Description

template<typename T>
class AttributeArray< T >

A helper class to access and iterate over an interleaved vertex attribute array.

Vertex data is stored as a list of packed vertices. Each vertex is defined by a set of attributes. This means that for any particular attribute, subsequent values are separated by the size of the vertex. This class helps deal with these discontigious arrays as iterable lists.

Member Typedef Documentation

template<typename T>
typedef const Iterator AttributeArray< T >::const_iterator

A const iterator over the array.

template<typename T>
typedef Iterator AttributeArray< T >::iterator

A mutable iterator over the array.

Constructor & Destructor Documentation

template<typename T>
AttributeArray< T >::AttributeArray ( )
inline

Constructs an attribute array which is marked as invalid.

template<typename T>
AttributeArray< T >::AttributeArray ( int  count,
GLbyte *  arrayBase,
int  stride,
const Attribute attribute 
)
inline

Constructs an attribute array which points to a buffer in memory.

Parameters
countNumber of elements in the array
arrayBasePointer to the first element in the array
strideNumber of bytes between elements
attributePointer to the definition of the attributes in this array

Member Function Documentation

template<typename T>
const Iterator AttributeArray< T >::begin ( ) const
inline

Gets a const iterator pointing to the beginning of the array.

template<typename T>
Iterator AttributeArray< T >::begin ( )
inline

Gets an iterator pointing to the beginning of the array.

template<typename T>
const Iterator AttributeArray< T >::end ( ) const
inline

Gets a const iterator pointing to immediately beyond the last element of the array.

template<typename T>
Iterator AttributeArray< T >::end ( )
inline

Gets an iterator pointing to immediately beyond the last element of the array.

template<typename T>
template<typename Y >
AttributeArray<Y> AttributeArray< T >::getAsType ( ) const
inline

Reinterprets this array as an array of a different type.

This method allows the data in the array to be reinterpreted as a different C++ type. For example, if the data being accessed is a 2D float vector, this method can be used to get the array as an AttributeArray with custom 2D vector container elements.

Returns
Reinterpreted array
template<typename T>
const Attribute* AttributeArray< T >::getAttribute ( ) const
inline

Gets the definition of the attributes in this array.

Returns
Attribute definition of elements in this array
template<typename T>
bool AttributeArray< T >::isValid ( ) const
inline

Returns whether this attribute array points to a valid array and can be accessed.

If this attribute array was associated with a mesh, an invalid array indicates that the attribute requested did not exist in the mesh.

Returns
Whether or not this array is valid
template<typename T>
const T& AttributeArray< T >::operator[] ( int  index) const
inline

Gets a constant reference to the element at the given index.

Parameters
indexIndex of the element to get
Returns
Element at the given index
template<typename T>
T& AttributeArray< T >::operator[] ( int  index)
inline

Gets a mutable reference to the element at the given index.

Parameters
indexIndex of the element to get
Returns
Mutable reference to the element at the given index