[ < ] | [ Up ] | [ > ] | [Top] | [Contents] | [Index] | [ ? ] |
HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( 3*sizeof(Real), // size of one whole vertex numVertices, // number of vertices HardwareBuffer::HBU_STATIC_WRITE_ONLY, // usage false); // no shadow buffer |
Notice that we use 5.1 The Hardware Buffer Manager to create our vertex buffer, and that a class called HardwareVertexBufferSharedPtr is returned from the method, rather than a raw pointer. This is because vertex buffers are reference counted - you are able to use a single vertex buffer as a source for multiple pieces of geometry therefore a standard pointer would not be good enough, because you would not know when all the different users of it had finished with it. The HardwareVertexBufferSharedPtr class manages its own destruction by keeping a reference count of the number of times it is being used - when the last HardwareVertexBufferSharedPtr is destroyed, the buffer itself automatically destroys itself.
The parameters to the creation of a vertex buffer are as follows:
vertexBufferBinding->setBinding(0, vbuf); |
[ < ] | [ Up ] | [ > ] | [Top] | [Contents] | [Index] | [ ? ] |