VertexBufferHandle Class Reference
 
 
 
VertexBufferHandle Class Reference

This reference page is linked to from the following overview topics: Low-level Device API.


#include <VertexBufferHandle.h>

Inheritance diagram for VertexBufferHandle:
SmartHandle Noncopyable MaxHeapOperators

Class Description

VertexBufferHandle is a memory buffer that contain vertex data.

Vertex buffers can contain any vertex type - transformed or untransformed, lit or unlit - that can be rendered through the use of the rendering methods.

Public Member Functions

GraphicsDriverAPI  VertexBufferHandle ()
GraphicsDriverAPI  VertexBufferHandle (const VertexBufferHandle &from)
GraphicsDriverAPI
VertexBufferHandle
operator= (const VertexBufferHandle &from)
virtual GraphicsDriverAPI  ~VertexBufferHandle ()
GraphicsDriverAPI bool  Initialize (size_t stride)
  Initialize this vertex buffer.
GraphicsDriverAPI void  Clear ()
  Clear all vertices in the buffer and set the size of the buffer to zero.
GraphicsDriverAPI size_t  GetVertexStride () const
  Get the size of each vertex of this buffer.
GraphicsDriverAPI size_t  GetNumberOfVertices () const
  Get the real number of vertices in the buffer.
GraphicsDriverAPI void  SetNumberOfVertices (size_t numberOfVertices)
  Sets the real number of vertices in the buffer.
GraphicsDriverAPI size_t  GetCapacity () const
  Get the capacity of the buffer.
GraphicsDriverAPI void  SetCapacity (size_t capacity)
  Sets the reserved capacity of the buffer.
GraphicsDriverAPI void  SetInstanceCount (size_t count)
  Sets the number of instance contained in the buffer.
GraphicsDriverAPI size_t  GetInstanceCount ()
  Get the number of instance contained in the buffer.
GraphicsDriverAPI void  SetStartOffset (size_t offset)
  Set start offset of this vertex buffer Sometimes geometry data may store in different position when using multiple vertex buffers.
GraphicsDriverAPI size_t  GetStartOffset ()
  Get start offset of this vertex buffer.
GraphicsDriverAPI unsigned char *  Lock (size_t vertexIndex, size_t numberOfVertices)
  This function is used for reading/writing data from/into the vertex buffer.
GraphicsDriverAPI void  Unlock ()
  Unlock the buffer to update.
GraphicsDriverAPI void  SetBufferUsageType (BufferUsageType bufferType)
  Sets the buffer usage type.

Constructor & Destructor Documentation

GraphicsDriverAPI VertexBufferHandle ( )
GraphicsDriverAPI VertexBufferHandle ( const VertexBufferHandle from )
virtual GraphicsDriverAPI ~VertexBufferHandle ( ) [virtual]

Member Function Documentation

GraphicsDriverAPI VertexBufferHandle& operator= ( const VertexBufferHandle from )
GraphicsDriverAPI bool Initialize ( size_t  stride )

Initialize this vertex buffer.

Parameters:
stride The stride in bytes of each vertex of the newly created buffer.
Returns:
true if successfully initialized, false otherwise.
GraphicsDriverAPI void Clear ( )

Clear all vertices in the buffer and set the size of the buffer to zero.

GraphicsDriverAPI size_t GetVertexStride ( ) const

Get the size of each vertex of this buffer.

Measured in bytes.

Returns:
the size in bytes of each vertex.
GraphicsDriverAPI size_t GetNumberOfVertices ( ) const

Get the real number of vertices in the buffer.

Returns:
the number of vertices.
GraphicsDriverAPI void SetNumberOfVertices ( size_t  numberOfVertices )

Sets the real number of vertices in the buffer.

Parameters:
numberOfVertices the new number of vertices.
GraphicsDriverAPI size_t GetCapacity ( ) const

Get the capacity of the buffer.

Returns:
the capacity
GraphicsDriverAPI void SetCapacity ( size_t  capacity )

Sets the reserved capacity of the buffer.

Parameters:
new capacity of the buffer
GraphicsDriverAPI void SetInstanceCount ( size_t  count )

Sets the number of instance contained in the buffer.

Parameters:
instance count
GraphicsDriverAPI size_t GetInstanceCount ( )

Get the number of instance contained in the buffer.

Returns:
instance count
GraphicsDriverAPI void SetStartOffset ( size_t  offset )

Set start offset of this vertex buffer Sometimes geometry data may store in different position when using multiple vertex buffers.

For example, assuming VertexBuffer1 stores geometry1 and geometry2's position data, and VertexBuffer2 stores geometry2's normal. When you want to render geometry2, you need VertexBuffer1's start offset to correct value, otherwise you'll use geometry1's position and geometry2's normal. Another situation is steam-out. When you need to stream-out data to specific position of a vertex buffer, you need to set start offset to that output buffer.

Parameters:
offset the start offset of this vertex buffer
GraphicsDriverAPI size_t GetStartOffset ( )

Get start offset of this vertex buffer.

Returns:
start offset of this vertex buffer
GraphicsDriverAPI unsigned char* Lock ( size_t  vertexIndex,
size_t  numberOfVertices 
)

This function is used for reading/writing data from/into the vertex buffer.

Remarks:
if the input parameter is invalid (eg. vertexIndex + numberOfVertices is greater than the total number of vertices of the buffer), the function returns NULL.
Parameters:
vertexIndex the vertex index that the lock operation starts
numberOfVertices the number of vertices that this function will lock.
Returns:
the buffer for developers to read/write vertex data. The size of the buffer is numberOfVertices * vertexStride.
GraphicsDriverAPI void Unlock ( )

Unlock the buffer to update.

This function must be called after Lock. Once this function is called, the buffer that returned by Lock become invalid and should not be used any more.

GraphicsDriverAPI void SetBufferUsageType ( BufferUsageType  bufferType )

Sets the buffer usage type.

Parameters:
bufferType buffer usage type