This class declares the format of a set of vertex inputs, which can be issued to the rendering API through a RenderOperation.
More...
|
| VertexDeclaration () |
| Standard constructor, not you should use HardwareBufferManager::createVertexDeclaration. More...
|
|
virtual | ~VertexDeclaration () |
|
const VertexElement & | addElement (unsigned short source, size_t offset, VertexElementType theType, VertexElementSemantic semantic, unsigned short index=0) |
| Adds a new VertexElement to this declaration. More...
|
|
VertexDeclaration * | clone (HardwareBufferManagerBase *mgr=0) const |
| Clones this declaration. More...
|
|
void | closeGapsInSource (void) |
| Remove any gaps in the source buffer list used by this declaration. More...
|
|
const VertexElement * | findElementBySemantic (VertexElementSemantic sem, unsigned short index=0) const |
| Finds a VertexElement with the given semantic and index. More...
|
|
VertexElementList | findElementsBySource (unsigned short source) const |
| Based on the current elements, gets the size of the vertex for a given buffer source. More...
|
|
VertexDeclaration * | getAutoOrganisedDeclaration (bool skeletalAnimation, bool vertexAnimation, bool vertexAnimationNormals) const |
| Generates a new VertexDeclaration for optimal usage based on the current vertex declaration, which can be used with VertexData::reorganiseBuffers later if you wish, or simply used as a template. More...
|
|
const VertexElement * | getElement (unsigned short index) const |
| Get a single element. More...
|
|
size_t | getElementCount (void) const |
| Get the number of elements in the declaration. More...
|
|
const VertexElementList & | getElements (void) const |
| Gets read-only access to the list of vertex elements. More...
|
|
unsigned short | getMaxSource (void) const |
| Gets the index of the highest source value referenced by this declaration. More...
|
|
unsigned short | getNextFreeTextureCoordinate () const |
| Return the index of the next free texture coordinate set which may be added to this declaration. More...
|
|
size_t | getVertexSize (unsigned short source) const |
| Gets the vertex size defined by this declaration for a given source. More...
|
|
const VertexElement & | insertElement (unsigned short atPosition, unsigned short source, size_t offset, VertexElementType theType, VertexElementSemantic semantic, unsigned short index=0) |
| Inserts a new VertexElement at a given position in this declaration. More...
|
|
void | modifyElement (unsigned short elem_index, unsigned short source, size_t offset, VertexElementType theType, VertexElementSemantic semantic, unsigned short index=0) |
| Modify an element in-place, params as addElement. More...
|
|
bool | operator!= (const VertexDeclaration &rhs) const |
|
bool | operator== (const VertexDeclaration &rhs) const |
|
void | removeAllElements (void) |
| Remove all elements. More...
|
|
void | removeElement (unsigned short elem_index) |
| Remove the element at the given index from this declaration. More...
|
|
void | removeElement (VertexElementSemantic semantic, unsigned short index=0) |
| Remove the element with the given semantic and usage index. More...
|
|
void | sort (void) |
| Sorts the elements in this list to be compatible with D3D7 graphics cards. More...
|
|
This class declares the format of a set of vertex inputs, which can be issued to the rendering API through a RenderOperation.
The ordering is important on Direct3D9 with Direct3D 7 grade cards. Calling closeGapsInSource() will format this VertexDeclaration accordingly.
Whilst GL and more modern graphics cards in D3D will allow you to defy these rules, sticking to them will reduce state changes and improve performance on modern APIs as well.
Like the other classes in this functional area, these declarations should be created and destroyed using the HardwareBufferManager.
void Ogre::VertexDeclaration::sort |
( |
void |
| ) |
|
Sorts the elements in this list to be compatible with D3D7 graphics cards.
the order is as follows: position, blending weights, normals, diffuse colours, specular colours, texture coordinates
void Ogre::VertexDeclaration::closeGapsInSource |
( |
void |
| ) |
|
Remove any gaps in the source buffer list used by this declaration.
This is useful if you've modified a declaration and want to remove any gaps in the list of buffers being used. Note, however, that if this declaration is already being used with a VertexBufferBinding, you will need to alter that too. This method is mainly useful when reorganising buffers based on an altered declaration.
Whilst in theory you have completely full reign over the format of you vertices, in reality there are some restrictions. D3D7 grade hardware imposes a fixed ordering on the elements which are pulled from each buffer:
- VertexElements should be added in the following order, and the order of the elements within any shared buffer should be as follows:
- Positions
- Blending weights
- Normals
- Diffuse colours
- Specular colours
- Texture coordinates (starting at 0, listed in order, with no gaps)
- You must not have unused gaps in your buffers which are not referenced by any VertexElement
- You must not cause the buffer & offset settings of 2 VertexElements to overlap
OpenGL and D3D9 compatible hardware are not required to follow these strict limitations, so you might find, for example that if you broke these rules your application would run under OpenGL and under DirectX on recent cards, but it is not guaranteed to run on older hardware under DirectX unless you stick to the above rules.
- Note
- This will also call sort()