OGRE-Next
3.0.0
Object-Oriented Graphics Rendering Engine
|
Vertex array objects (Vaos) are immutable objects that describe a combination of vertex buffers and index buffer with a given operation type. More...
#include <OgreVertexArrayObject.h>
Classes | |
struct | ReadRequests |
Public Types | |
typedef vector< ReadRequests >::type | ReadRequestsVec |
Public Member Functions | |
VertexArrayObject (uint32 vaoName, uint32 renderQueueId, uint16 inputLayoutId, const VertexBufferPackedVec &vertexBuffers, IndexBufferPacked *indexBuffer, OperationType operationType) | |
VertexArrayObject * | clone (VaoManager *vaoManager, SharedVertexBufferMap *sharedBuffers, int vertexBufferType=-1, int indexBufferType=-1) const |
Clones the vertex & index buffers and creates a new VertexArrayObject. More... | |
const VertexElement2 * | findBySemantic (VertexElementSemantic semantic, size_t &outIndex, size_t &outOffset, size_t repeat=0) const |
Returns the entire VertexElement2 descriptor in the vertex buffers. More... | |
VertexBufferPacked * | getBaseVertexBuffer () const |
IndexBufferPacked * | getIndexBuffer () const |
uint16 | getInputLayoutId () const |
OperationType | getOperationType () const |
uint32 | getPrimitiveCount () const |
uint32 | getPrimitiveStart () const |
uint32 | getRenderQueueId () const |
uint32 | getVaoName () const |
const VertexBufferPackedVec & | getVertexBuffers () const |
VertexElement2VecVec | getVertexDeclaration () const |
Gets the combined vertex declaration of all the vertex buffers. More... | |
void | readRequests (ReadRequestsVec &requests, size_t elementStart=0, size_t elementCount=0, bool skipRequestIfBufferHasShadowCopy=false) |
Utility to get multiple pointers & read specific elements of the vertex, even if they're in separate buffers. More... | |
void | setPrimitiveRange (uint32 primStart, uint32 primCount) |
Limits the range of triangle primitives that is rendered. More... | |
Static Public Member Functions | |
static VertexElement2VecVec | getVertexDeclaration (const VertexBufferPackedVec &vertexBuffers) |
static void | mapAsyncTickets (ReadRequestsVec &tickets) |
Maps the buffers requested via. More... | |
static void | unmapAsyncTickets (ReadRequestsVec &tickets) |
Unmaps the buffers mapped via. More... | |
Static Public Attributes | |
static VertexBufferPacked | msDummyVertexBuffer |
When a Vao doesn't have a vertex buffer, a dummy one is assigned for performance reasons (avoid checking if pointer is null, avoid crashing inside Ogre) More... | |
Vertex array objects (Vaos) are immutable objects that describe a combination of vertex buffers and index buffer with a given operation type.
Once created, they can't be modified. You have to destroy them and create a new one.
typedef vector<ReadRequests>::type Ogre::VertexArrayObject::ReadRequestsVec |
Ogre::VertexArrayObject::VertexArrayObject | ( | uint32 | vaoName, |
uint32 | renderQueueId, | ||
uint16 | inputLayoutId, | ||
const VertexBufferPackedVec & | vertexBuffers, | ||
IndexBufferPacked * | indexBuffer, | ||
OperationType | operationType | ||
) |
VertexArrayObject* Ogre::VertexArrayObject::clone | ( | VaoManager * | vaoManager, |
SharedVertexBufferMap * | sharedBuffers, | ||
int | vertexBufferType = -1 , |
||
int | indexBufferType = -1 |
||
) | const |
Clones the vertex & index buffers and creates a new VertexArrayObject.
The only exception is when one of the vertex buffers is already in sharedBuffers, in which case the buffer in sharedBuffers.find(vertexBuffer)->second will be used without cloning (useful for cloning LODs).
vaoManager | The VaoManager needed to create the structures |
sharedBuffers | [in/out] Maps old vertex buffers to new vertex buffers so that we can reuse them. Optional. Use a null pointer to disable this feature. |
vertexBufferType | See BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned. |
indexBufferType | See BufferType. Must be set to a valid BufferType. Pass a negative value to keep the same type of the original buffer being cloned. |
const VertexElement2* Ogre::VertexArrayObject::findBySemantic | ( | VertexElementSemantic | semantic, |
size_t & | outIndex, | ||
size_t & | outOffset, | ||
size_t | repeat = 0 |
||
) | const |
Returns the entire VertexElement2 descriptor in the vertex buffers.
semantic | Semantic to look for. |
outIndex | The index to mVertexBuffers[index] if it's found. Otherwise the value is left untouched. |
outIndex | The offset in bytes to retrieve the element in the vertex data. If the semantic isn't found, the value is left untouched. |
repeat | The number of times to skip a semantic before returning the hit. Useful when you have more than one VES_TEXTURE_COORDINATES for example. Set repeat = 0 to retrieve the first set of VES_TEXTURE_COORDINATES Set repeat = 1 to retrieve the second set of VES_TEXTURE_COORDINATES etc. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
VertexElement2VecVec Ogre::VertexArrayObject::getVertexDeclaration | ( | ) | const |
Gets the combined vertex declaration of all the vertex buffers.
Note that we iterate through all of them and allocate the vector. You should cache the result rather than calling this function frequently.
|
static |
|
static |
Maps the buffers requested via.
void Ogre::VertexArrayObject::readRequests | ( | ReadRequestsVec & | requests, |
size_t | elementStart = 0 , |
||
size_t | elementCount = 0 , |
||
bool | skipRequestIfBufferHasShadowCopy = false |
||
) |
Utility to get multiple pointers & read specific elements of the vertex, even if they're in separate buffers.
When two elements share the same buffer, only one ticket is created.
Example usage: VertexArrayObject::ReadRequestsVec requests; requests.push_back( VertexArrayObject::ReadRequests( VES_POSITION ) ); requests.push_back( VertexArrayObject::ReadRequests( VES_NORMALS ) ); vao->readRequests( requests ); vao->mapAsyncTickets( requests );
for( size_t i=0; i<numVertices; ++i ) { float const position = reinterpret_cast<const float>( requests[0].data ); float const normals = reinterpret_cast<const float>( requests[1].data );
requests[0].data += requests[0].vertexBuffer->getBytesPerElement(); requests[1].data += requests[1].vertexBuffer->getBytesPerElement(); }
vao->unmapAsyncTickets( requests );
requests | [in/out] Array filled with the semantic. |
skipRequestIfBufferHasShadowCopy | Avoid generating the AsyncTicket if the buffer has a shadow copy. Useful if you want to read directly from the shadow copy instead of downloading from the GPU. The 'data' variable will be filled immediately if there's a shadow copy available, and mapAsyncTickets can be safely called even if skipRequestIfBufferHasShadowCopy=true |
Limits the range of triangle primitives that is rendered.
For VAOs with index buffers, this controls the index start & count, akin to indexStart & indexCount from the v1 objects.
|
static |
Unmaps the buffers mapped via.
|
static |
When a Vao doesn't have a vertex buffer, a dummy one is assigned for performance reasons (avoid checking if pointer is null, avoid crashing inside Ogre)