Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CVertexBuffer Class Reference

CVertexBuffer: encapsulation of ARB_vertex_buffer_object, also supplying some additional functionality for sharing buffers between multiple objects. More...

#include <VertexBuffer.h>

Classes

struct  VBChunk
 VBChunk: describes a portion of this vertex buffer. More...
 

Public Member Functions

 CVertexBuffer (size_t vertexSize, GLenum usage, GLenum target)
 
 ~CVertexBuffer ()
 
u8Bind ()
 Bind to this buffer; return pointer to address required as parameter to glVertexPointer ( + etc) calls. More...
 
u8GetBindAddress ()
 Get the address that Bind() will return, without actually binding. More...
 
void UpdateChunkVertices (VBChunk *chunk, void *data)
 Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer. More...
 
size_t GetVertexSize () const
 
size_t GetBytesReserved () const
 
size_t GetBytesAllocated () const
 
bool CompatibleVertexType (size_t vertexSize, GLenum usage, GLenum target)
 Returns true if this vertex buffer is compatible with the specified vertex type and intended usage. More...
 
void DumpStatus ()
 

Static Public Member Functions

static void Unbind ()
 Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it. More...
 

Protected Member Functions

VBChunkAllocate (size_t vertexSize, size_t numVertices, GLenum usage, GLenum target)
 Try to allocate a buffer of given number of vertices (each of given size), and with the given type - return null if no free chunks available. More...
 
void Release (VBChunk *chunk)
 Return given chunk to this buffer. More...
 

Private Member Functions

 NONCOPYABLE (CVertexBuffer)
 

Private Attributes

size_t m_VertexSize
 Vertex size of this vertex buffer. More...
 
size_t m_MaxVertices
 Number of vertices of above size in this buffer. More...
 
std::list< VBChunk * > m_FreeList
 List of free chunks in this buffer. More...
 
size_t m_FreeVertices
 Available free vertices - total of all free vertices in the free list. More...
 
GLuint m_Handle
 Handle to the actual GL vertex buffer object. More...
 
u8m_SysMem
 Raw system memory for systems not supporting VBOs. More...
 
GLenum m_Usage
 Usage type of the buffer (GL_STATIC_DRAW etc) More...
 
GLenum m_Target
 Buffer target (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER) More...
 

Friends

class CVertexBufferManager
 

Detailed Description

CVertexBuffer: encapsulation of ARB_vertex_buffer_object, also supplying some additional functionality for sharing buffers between multiple objects.

Definition at line 40 of file VertexBuffer.h.

Constructor & Destructor Documentation

CVertexBuffer::CVertexBuffer ( size_t  vertexSize,
GLenum  usage,
GLenum  target 
)

Definition at line 31 of file VertexBuffer.cpp.

CVertexBuffer::~CVertexBuffer ( )

Definition at line 68 of file VertexBuffer.cpp.

Member Function Documentation

CVertexBuffer::VBChunk * CVertexBuffer::Allocate ( size_t  vertexSize,
size_t  numVertices,
GLenum  usage,
GLenum  target 
)
protected

Try to allocate a buffer of given number of vertices (each of given size), and with the given type - return null if no free chunks available.

Definition at line 93 of file VertexBuffer.cpp.

u8 * CVertexBuffer::Bind ( )

Bind to this buffer; return pointer to address required as parameter to glVertexPointer ( + etc) calls.

Definition at line 197 of file VertexBuffer.cpp.

bool CVertexBuffer::CompatibleVertexType ( size_t  vertexSize,
GLenum  usage,
GLenum  target 
)

Returns true if this vertex buffer is compatible with the specified vertex type and intended usage.

Definition at line 81 of file VertexBuffer.cpp.

void CVertexBuffer::DumpStatus ( )

Definition at line 237 of file VertexBuffer.cpp.

u8 * CVertexBuffer::GetBindAddress ( )

Get the address that Bind() will return, without actually binding.

Definition at line 210 of file VertexBuffer.cpp.

size_t CVertexBuffer::GetBytesAllocated ( ) const

Definition at line 232 of file VertexBuffer.cpp.

size_t CVertexBuffer::GetBytesReserved ( ) const

Definition at line 227 of file VertexBuffer.cpp.

size_t CVertexBuffer::GetVertexSize ( ) const
inline

Definition at line 82 of file VertexBuffer.h.

CVertexBuffer::NONCOPYABLE ( CVertexBuffer  )
private
void CVertexBuffer::Release ( VBChunk chunk)
protected

Return given chunk to this buffer.

Definition at line 143 of file VertexBuffer.cpp.

void CVertexBuffer::Unbind ( )
static

Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it.

Definition at line 218 of file VertexBuffer.cpp.

void CVertexBuffer::UpdateChunkVertices ( VBChunk chunk,
void *  data 
)

Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer.

Definition at line 178 of file VertexBuffer.cpp.

Friends And Related Function Documentation

friend class CVertexBufferManager
friend

Definition at line 92 of file VertexBuffer.h.

Member Data Documentation

std::list<VBChunk*> CVertexBuffer::m_FreeList
private

List of free chunks in this buffer.

Definition at line 107 of file VertexBuffer.h.

size_t CVertexBuffer::m_FreeVertices
private

Available free vertices - total of all free vertices in the free list.

Definition at line 109 of file VertexBuffer.h.

GLuint CVertexBuffer::m_Handle
private

Handle to the actual GL vertex buffer object.

Definition at line 111 of file VertexBuffer.h.

size_t CVertexBuffer::m_MaxVertices
private

Number of vertices of above size in this buffer.

Definition at line 105 of file VertexBuffer.h.

u8* CVertexBuffer::m_SysMem
private

Raw system memory for systems not supporting VBOs.

Definition at line 113 of file VertexBuffer.h.

GLenum CVertexBuffer::m_Target
private

Buffer target (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER)

Definition at line 117 of file VertexBuffer.h.

GLenum CVertexBuffer::m_Usage
private

Usage type of the buffer (GL_STATIC_DRAW etc)

Definition at line 115 of file VertexBuffer.h.

size_t CVertexBuffer::m_VertexSize
private

Vertex size of this vertex buffer.

Definition at line 103 of file VertexBuffer.h.


The documentation for this class was generated from the following files: