buffer object mapping helper class. More...
#include <Inventor/devices/SoAutoMap.h>
Public Member Functions | |
SoAutoMap (SoBufferObject *bufferObject, SoBufferObject::AccessMode accessMode) | |
~SoAutoMap () | |
T & | operator[] (const size_t i) |
const T & | operator[] (const size_t i) const |
size_t | getSize () const |
This class provides an safe and simplified way to access data through typed a cpu array. It allows to use the following syntax while app wants to read or write some data from an SoBufferObject. Example:
void updateABufferObject(SoBufferObject* bufferObject); { SoAutoMap<SbVec3f> vec3array(bufferObject,SoBufferObject::SET); for (int i=0;i<vec3array.getSize();++i) vec3array[i] = SbVec3f(0.f,0.f,0.f); } // which replace and add safety to the follwoing code void updateABufferObject(SoBufferObject* bufferObject); { SoRef<SoCpuBufferObject> cpuBufferObject = new SoCpuBufferObject; bufferObject->map(cpuBufferObject,SoBufferObject::SET); SbVec3f* vec3array = static_cast<SbVec3f*>(cpuBufferObject->map(SoBufferObject::SET)); size_t arraySize=cpuBufferObject.getSize()/sizeof(SbVec3f); for (int i=0;i<arraySize;++i) vec3array[i] = SbVec3f(0.f,0.f,0.f); cpuBufferObject->unmap(); bufferObject->unmap(cpuBufferObject); }
SoAutoMap< T >::SoAutoMap | ( | SoBufferObject * | bufferObject, | |
SoBufferObject::AccessMode | accessMode | |||
) | [inline] |
Constructor.
In charge of setting mapping
Destructor.
In charge of releasing mapping
size_t SoAutoMap< T >::getSize | ( | ) | const [inline] |
return the number of T element in the mapped array
const T& SoAutoMap< T >::operator[] | ( | const size_t | i | ) | const [inline] |
const accessor to T element at index i
T& SoAutoMap< T >::operator[] | ( | const size_t | i | ) | [inline] |
accessor to T element at index i