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