Go to the documentation of this file.
28 #ifndef __HardwareVertexBuffer__
29 #define __HardwareVertexBuffer__
39 class HardwareBufferManagerBase;
187 unsigned short getSource(
void)
const {
return mSource; }
195 unsigned short getIndex(
void)
const {
return mIndex; }
233 if (mType != rhs.
mType ||
254 *pElem =
static_cast<void*
>(
255 static_cast<unsigned char*
>(pBase) + mOffset);
269 *pElem =
static_cast<float*
>(
271 static_cast<unsigned char*
>(pBase) + mOffset));
283 *pElem =
static_cast<RGBA*
>(
285 static_cast<unsigned char*
>(pBase) + mOffset));
296 *pElem =
static_cast<unsigned char*
>(pBase) + mOffset;
308 *pElem =
static_cast<unsigned short*
>(
310 static_cast<unsigned char*
>(pBase) + mOffset));
392 bool vertexAnimation,
bool vertexAnimationNormals)
const;
489 VertexElementList::const_iterator i, iend, rhsi, rhsiend;
490 iend = mElementList.end();
493 for (i = mElementList.begin(); i != iend && rhsi != rhsiend; ++i, ++rhsi)
495 if ( !(*i == *rhsi) )
503 return !(*
this == rhs);
563 virtual unsigned short getNextIndex(
void)
const {
return mHighIndex++; }
bool isInstanceData() const
Get if this vertex buffer is an "instance data" buffer (per instance)
void baseVertexPointerToElement(void *pBase, RGBA **pElem) const
Adjusts a pointer to the base of a vertex to point at this element.
@ VES_TEXTURE_COORDINATES
Texture coordinates.
@ VES_TANGENT
Tangent (X axis if normal is Z)
VertexBufferBindingMap mBindingMap
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
virtual 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.
void baseVertexPointerToElement(void *pBase, unsigned short **pElem) const
Adjusts a pointer to the base of a vertex to point at this element.
HardwareBufferLockGuard< HardwareVertexBufferSharedPtr > HardwareVertexBufferLockGuard
Locking helper.
const VertexElement * getElement(unsigned short index) const
Get a single element.
virtual void unsetAllBindings(void)
Removes all the bindings.
void baseVertexPointerToElement(void *pBase, float **pElem) const
Adjusts a pointer to the base of a vertex to point at this element.
@ VES_COUNT
The number of VertexElementSemantic elements (note - the first value VES_POSITION is 1)
unsigned short getSource(void) const
Gets the vertex buffer index from where this element draws it's values.
void setIsInstanceData(const bool val)
Set if this vertex buffer is an "instance data" buffer (per instance)
HardwareVertexBufferSharedPtr(HardwareVertexBuffer *buf)
Base definition of a hardware buffer manager.
unsigned short mIndex
Index of the item, only applicable for some elements like texture coords.
virtual void setBinding(unsigned short index, const HardwareVertexBufferSharedPtr &buffer)
Set a binding, associating a vertex buffer with a given index.
VertexBufferBinding()
Constructor, should not be called direct, use HardwareBufferManager::createVertexBufferBinding.
size_t getOffset(void) const
Gets the offset into the buffer where this element starts.
list< VertexElement >::type VertexElementList
Defines the list of vertex elements that makes up this declaration.
size_t getVertexSize(void) const
Gets the size in bytes of a single vertex in this buffer.
virtual VertexDeclaration * clone(HardwareBufferManagerBase *mgr=0) const
Clones this declaration.
void baseVertexPointerToElement(void *pBase, void **pElem) const
Adjusts a pointer to the base of a vertex to point at this element.
static uint32 convertColourValue(const ColourValue &src, VertexElementType dst)
Utility method for converting colour to a packed 32-bit colour type.
virtual const VertexBufferBindingMap & getBindings(void) const
Gets a read-only version of the buffer bindings.
virtual bool hasGaps(void) const
Check whether any gaps in the bindings.
static unsigned short getTypeCount(VertexElementType etype)
Utility method which returns the count of values in a given type.
size_t getInstanceDataStepRate() const
Get the number of instances to draw using the same per-instance data before advancing in the buffer b...
virtual unsigned short getNextFreeTextureCoordinate() const
Return the index of the next free texture coordinate set which may be added to this declaration.
virtual void unsetBinding(unsigned short index)
Removes an existing binding.
static size_t getTypeSize(VertexElementType etype)
Utility method for helping to calculate offsets.
virtual size_t getVertexSize(unsigned short source) const
Gets the vertex size defined by this declaration for a given source.
unsigned short mSource
The source vertex buffer, as bound to an index using VertexBufferBinding.
size_t getElementCount(void) const
Get the number of elements in the declaration.
virtual void closeGaps(BindingIndexMap &bindingIndexMap)
Remove any gaps in the bindings.
unsigned short getIndex(void) const
Gets the index of this element, only applicable for repeating elements.
virtual 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.
@ VET_COLOUR_ARGB
D3D style compact colour.
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator,...
VertexElementSemantic
Vertex element semantics, used to identify the meaning of vertex buffer contents.
size_t getSize(void) const
Gets the size of this element in bytes.
Records the state of all the vertex buffer bindings required to provide a vertex declaration with the...
static VertexElementType multiplyTypeCount(VertexElementType baseType, unsigned short count)
Simple converter function which will turn a single-value type into a multi-value type based on a para...
VertexElementType
Vertex element type, used to identify the base types of the vertex contents.
VertexElementSemantic mSemantic
The meaning of the element.
static void convertColourValue(VertexElementType srcType, VertexElementType dstType, uint32 *ptr)
Utility method for converting colour from one packed 32-bit colour type to another.
VertexElementSemantic getSemantic(void) const
Gets the meaning of this element.
HardwareVertexBuffer(HardwareBufferManagerBase *mgr, size_t vertexSize, size_t numVertices, HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer)
Should be called by HardwareBufferManager.
virtual unsigned short getNextIndex(void) const
Gets the highest index which has already been set, plus 1.
virtual ~VertexDeclaration()
unsigned short getMaxSource(void) const
Gets the index of the highest source value referenced by this declaration.
This class declares the format of a set of vertex inputs, which can be issued to the rendering API th...
Shared pointer implementation used to share vertex buffers.
size_t mOffset
The offset in the buffer that this element starts at.
@ VES_BLEND_INDICES
Blending indices.
map< unsigned short, HardwareVertexBufferSharedPtr >::type VertexBufferBindingMap
Defines the vertex buffer bindings used as source for vertex declarations.
@ VES_DIFFUSE
Diffuse colours.
HardwareVertexBufferSharedPtr()
unsigned short mHighIndex
This class declares the usage of a single vertex buffer as a component of a complete VertexDeclaratio...
VertexDeclaration * getAutoOrganisedDeclaration(bool skeletalAnimation, bool vertexAnimation, bool vertexAnimationNormals) const
Generates a new VertexDeclaration for optimal usage based on the current vertex declaration,...
virtual void removeElement(unsigned short elem_index)
Remove the element at the given index from this declaration.
VertexDeclaration()
Standard constructor, not you should use HardwareBufferManager::createVertexDeclaration.
@ VET_COLOUR
alias to more specific colour type - use the current rendersystem's colour packing
virtual bool checkIfVertexInstanceDataIsSupported()
Checks if vertex instance data is supported by the render system.
virtual const VertexElement & addElement(unsigned short source, size_t offset, VertexElementType theType, VertexElementSemantic semantic, unsigned short index=0)
Adds a new VertexElement to this declaration.
VertexElementType getType(void) const
Gets the data format of this element.
static bool vertexElementLess(const VertexElement &e1, const VertexElement &e2)
Sort routine for vertex elements.
@ VES_BINORMAL
Binormal (Y axis if normal is Z)
void setInstanceDataStepRate(const size_t val)
Set the number of instances to draw using the same per-instance data before advancing in the buffer b...
VertexElement()
Constructor, should not be called directly, only needed because of list.
static VertexElementType getBaseType(VertexElementType multiType)
Simple converter function which will a type into it's single-value equivalent - makes switches on typ...
static VertexElementType getBestColourVertexElementType(void)
Utility method to get the most appropriate packed colour vertex element format.
virtual const VertexElement * findElementBySemantic(VertexElementSemantic sem, unsigned short index=0) const
Finds a VertexElement with the given semantic, and index if there is more than one element with the s...
Reference-counted shared pointer, used for objects where implicit destruction is required.
VertexElement(unsigned short source, size_t offset, VertexElementType theType, VertexElementSemantic semantic, unsigned short index=0)
Constructor, should not be called directly, call VertexDeclaration::addElement.
HardwareBufferManagerBase * mMgr
void baseVertexPointerToElement(void *pBase, unsigned char **pElem) const
Adjusts a pointer to the base of a vertex to point at this element.
void closeGapsInSource(void)
Remove any gaps in the source buffer list used by this declaration.
virtual ~VertexBufferBinding()
virtual const HardwareVertexBufferSharedPtr & getBuffer(unsigned short index) const
Gets the buffer bound to the given source index.
std::map< K, V, P, A > type
Abstract class defining common features of hardware buffers.
Class representing colour.
virtual size_t getBufferCount(void) const
VertexElementType mType
The type of element.
@ VET_COLOUR_ABGR
GL style compact colour.
Specialisation of HardwareBuffer for a vertex buffer.
Usage
Enums describing buffer usage; not mutually exclusive.
virtual unsigned short getLastBoundIndex(void) const
Gets the last bound index.
@ VES_NORMAL
Normal, 3 reals per vertex.
virtual bool isBufferBound(unsigned short index) const
Gets whether a buffer is bound to the given source index.
virtual void removeAllElements(void)
Remove all elements.
VertexElementList mElementList
virtual VertexElementList findElementsBySource(unsigned short source) const
Based on the current elements, gets the size of the vertex for a given buffer source.
@ VES_SPECULAR
Specular colours.
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator,...
@ VES_BLEND_WEIGHTS
Blending weights.
HardwareBufferManagerBase * getManager() const
Return the manager of this buffer, if any.
virtual void removeElement(VertexElementSemantic semantic, unsigned short index=0)
Remove the element with the given semantic and usage index.
size_t mInstanceDataStepRate
void sort(void)
Sorts the elements in this list to be compatible with the maximum number of rendering APIs / graphics...
virtual bool hasInstanceData() const
Returns true if this binding has an element that contains instance data.
const VertexElementList & getElements(void) const
Gets read-only access to the list of vertex elements.
map< ushort, ushort >::type BindingIndexMap
size_t getNumVertices(void) const
Get the number of vertices in this buffer.
@ VES_POSITION
Position, 3 reals per vertex.
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.