Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

VertexBuffer Class Reference

#include <vertexbuffer.h>

Inheritance diagram for VertexBuffer:

Inheritance graph
[legend]
Collaboration diagram for VertexBuffer:

Collaboration graph
[legend]
List of all members.

Detailed Description

Vertex storage in buffer Vertex buffer with flexible format, with possible agp/video ram storage managed by device.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  BUFFERTYPE {
  DYNAMIC = 0x00000000, STATIC = 0x00000001, READPRIORITIZED = 0x00000002, WRITEPRIORITIZED = 0x00000004,
  NOREADWRITE = 0x00000008, NORENDER = 0x00000010, NORMAL = ( DYNAMIC | READPRIORITIZED | WRITEPRIORITIZED )
}
 Buffer type identifiers. Any combination of the flags is valid. More...

enum  BUFFERUPLOADPOLICY { ONUNLOCK, ONRENDER, ONFLUSH }
 Upload policy identifiers. More...

enum  BUFFERLOCK { READ = 1, WRITE = 2, NOUPLOAD = 4, FORCEUPLOAD = 8 }
 Lock type identifiers. More...


Public Member Functions

 VertexBuffer (unsigned int uiType, unsigned int uiNumVertices, const VertexDeclaration *pkFormat, const void *pData=0)
virtual ~VertexBuffer ()
virtual void AllocateVertices (unsigned int uiNumVertices, const VertexDeclaration *pkFormat, const void *pData=0)
void LoadVertexData (const void *pData)
void * GetVertex (unsigned int uiElement=0)
const VertexDeclarationGetVertexFormat () const
unsigned int GetVertexSize () const
virtual const void * GetRenderData ()
bool Lock (unsigned int uiLockType)
void Unlock ()
virtual void Upload ()
bool IsLocked () const
bool IsDirty () const
unsigned int GetType () const
unsigned int GetNumAllocated () const
unsigned int GetNumElements () const
void SetNumElements (unsigned int uiNumElements)
void IncRef ()
void DecRef ()
int GetRefCount () const

Static Public Member Functions

std::string GetTypeAsString (unsigned int uiType)
unsigned int GetTypeFromString (std::string const &strType)

Static Public Attributes

BUFFERUPLOADPOLICY s_eUploadPolicy

Protected Member Functions

virtual bool AcquireLock ()
virtual void ReleaseLock ()

Protected Attributes

VertexDeclarationm_pkVertexFormat
unsigned int m_uiVertexFormatSize
unsigned char * m_pucBuffer
unsigned char * m_pucVertices
unsigned int m_uiType
unsigned int m_uiLock
bool m_bDirty
unsigned int m_uiNumAllocated
unsigned int m_uiNumCurrent


Member Enumeration Documentation

enum BUFFERTYPE [inherited]
 

Buffer type identifiers. Any combination of the flags is valid.

Enumeration values:
DYNAMIC  Dynamic buffer with system RAM backing store
STATIC  AGP or VRAM storage if possible
READPRIORITIZED  Prioritize read access
WRITEPRIORITIZED  Prioritize write accesss
NOREADWRITE  Buffer that can never be read from or written to, must pass data pointer to ctor
NORENDER  Buffer that must never be sent for rendering, guaranteed to not use video RAM resources
NORMAL  Default type

enum BUFFERUPLOADPOLICY [inherited]
 

Upload policy identifiers.

Enumeration values:
ONUNLOCK  Upload after WRITE lock released
ONRENDER  Upload when used in render primitive queued for render
ONFLUSH  Upload when used in render pipeline flush

enum BUFFERLOCK [inherited]
 

Lock type identifiers.

Enumeration values:
READ  Read access
WRITE  Write access (implies read access)
NOUPLOAD  No upload on unlock, will cause upload-on-render
FORCEUPLOAD  Force upload on unlock


Constructor & Destructor Documentation

VertexBuffer unsigned int  uiType,
unsigned int  uiNumVertices,
const VertexDeclaration pkFormat,
const void *  pData = 0
 

Parameters:
uiType Buffer type
uiNumVertices Number of vertices to allocate memory for
pkFormat Vertex format declaration
pData Optional pointer to data to load buffer with

virtual ~VertexBuffer  )  [virtual]
 


Member Function Documentation

virtual bool AcquireLock  )  [inline, protected, virtual]
 

Called by Lock. Lock type member m_uiLock has been set at this point

Returns:
true if lock successful, false if not

Implements Buffer.

virtual void ReleaseLock  )  [inline, protected, virtual]
 

Called by Unlock when a lock should be released. Lock type member m_uiLock is still holding lock type at this point.

Implements Buffer.

virtual void AllocateVertices unsigned int  uiNumVertices,
const VertexDeclaration pkFormat,
const void *  pData = 0
[virtual]
 

Resize buffer. There must not be any active lock held on buffer when calling this method

Parameters:
uiNumVertices New vertex count
pkFormat Vertex format declaration
pData Optional pointer to data to copy

void LoadVertexData const void *  pData  )  [inline]
 

Load data into buffer. Data must have same internal layout and size as vertex buffer format. An active WRITE lock must have been acquired on the buffer prior to calling this method.

Parameters:
pData Vertex data (will read m_uiNumVertices vertices)

void* GetVertex unsigned int  uiElement = 0  )  [inline]
 

Get ptr to element

Parameters:
uiElement Element to access

const VertexDeclaration* GetVertexFormat  )  const [inline]
 

Returns:
Vertex format declaration

unsigned int GetVertexSize  )  const [inline]
 

Get size of a single element in array

Returns:
Element size in bytes

virtual const void* GetRenderData  )  [inline, virtual]
 

Get pointer to render data. Used by derived buffer classes in device with AGP/video RAM storage to return pointer to data used for rendering.

Returns:
Render data pointer

bool Lock unsigned int  uiLockType  )  [inline, inherited]
 

Lock buffer for read/write operation

Parameters:
uiLockType Lock type
Returns:
true if lock acquired, false if failed (already locked)

void Unlock  )  [inline, inherited]
 

Unlock buffer

virtual void Upload  )  [inline, virtual, inherited]
 

Upload data to backing store, reset dirty flag

bool IsLocked  )  const [inline, inherited]
 

Returns:
true if buffer is locked, false if not

bool IsDirty  )  const [inline, inherited]
 

Returns:
true if buffer is dirty, false if not

unsigned int GetType  )  const [inline, inherited]
 

Returns:
Buffer type

unsigned int GetNumAllocated  )  const [inline, inherited]
 

Returns:
Number of allocated elements

unsigned int GetNumElements  )  const [inline, inherited]
 

Returns:
Number of currently used elements

void SetNumElements unsigned int  uiNumElements  )  [inline, inherited]
 

Set new count of currently used elements

Parameters:
uiNumElements Number of elements currently used, will be clamped to [0,numallocated] range

std::string GetTypeAsString unsigned int  uiType  )  [static, inherited]
 

Get buffer type as string

Parameters:
uiType Type identifier
Returns:
Type as string

unsigned int GetTypeFromString std::string const &  strType  )  [static, inherited]
 

Get buffer type from string

Parameters:
strType String type identifier
Returns:
Type id

void IncRef  )  [inline, inherited]
 

Increase reference count

void DecRef  )  [inline, inherited]
 

Decrease reference count and garbage collect if 0

int GetRefCount  )  const [inline, inherited]
 

Returns:
Current reference count


Member Data Documentation

VertexDeclaration* m_pkVertexFormat [protected]
 

Vertex format declaration

unsigned int m_uiVertexFormatSize [protected]
 

Size of a vertex

unsigned char* m_pucBuffer [protected]
 

Real buffer pointer

unsigned char* m_pucVertices [protected]
 

Read/write access buffer pointer

unsigned int m_uiType [protected, inherited]
 

Buffer type

unsigned int m_uiLock [protected, inherited]
 

Current lock type held

bool m_bDirty [protected, inherited]
 

Dirty flag

unsigned int m_uiNumAllocated [protected, inherited]
 

Number of allocated elements

unsigned int m_uiNumCurrent [protected, inherited]
 

Number of currently used elements

BUFFERUPLOADPOLICY s_eUploadPolicy [static, inherited]
 

Buffer upload policy


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:16 2004 for NeoEngine by doxygen 1.3.5