22 #ifndef INCLUDED_VERTEXBUFFER
23 #define INCLUDED_VERTEXBUFFER
34 #define MAX_VB_SIZE_BYTES (4*1024*1024)
66 CVertexBuffer(
size_t vertexSize, GLenum usage, GLenum target);
96 VBChunk*
Allocate(
size_t vertexSize,
size_t numVertices, GLenum usage, GLenum target);
size_t GetVertexSize() const
size_t m_Index
Start index of this chunk in owner.
u8 * Bind()
Bind to this buffer; return pointer to address required as parameter to glVertexPointer ( + etc) call...
size_t GetBytesReserved() const
GLenum m_Usage
Usage type of the buffer (GL_STATIC_DRAW etc)
VBChunk: describes a portion of this vertex buffer.
GLenum m_Target
Buffer target (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER)
CVertexBuffer: encapsulation of ARB_vertex_buffer_object, also supplying some additional functionalit...
u8 * GetBindAddress()
Get the address that Bind() will return, without actually binding.
u8 * m_SysMem
Raw system memory for systems not supporting VBOs.
std::list< VBChunk * > m_FreeList
List of free chunks in this buffer.
size_t m_FreeVertices
Available free vertices - total of all free vertices in the free list.
NONCOPYABLE(CVertexBuffer)
CVertexBuffer(size_t vertexSize, GLenum usage, GLenum target)
void UpdateChunkVertices(VBChunk *chunk, void *data)
Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer...
void Release(VBChunk *chunk)
Return given chunk to this buffer.
size_t m_Count
Number of vertices used by chunk.
size_t m_MaxVertices
Number of vertices of above size in this buffer.
CVertexBuffer * m_Owner
Owning (parent) vertex buffer.
size_t GetBytesAllocated() const
GLuint m_Handle
Handle to the actual GL vertex buffer object.
size_t m_VertexSize
Vertex size of this vertex buffer.
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...
static void Unbind()
Unbind any currently-bound buffer, so glVertexPointer etc calls will not attempt to use it...
VBChunk * Allocate(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 - ...