xoreos  0.0.5
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Graphics::VertexBuffer Class Reference

Buffer containing vertex data. More...

#include <vertexbuffer.h>

Collaboration diagram for Graphics::VertexBuffer:
Collaboration graph
[legend]

Public Member Functions

 VertexBuffer ()
 
 VertexBuffer (const VertexBuffer &other)
 
 ~VertexBuffer ()
 
VertexBufferoperator= (const VertexBuffer &other)
 
void setSize (uint32 vertCount, uint32 vertSize)
 Change buffer size. More...
 
void setVertexDecl (const VertexDecl &decl)
 Set vertex declaration for this buffer. More...
 
void setVertexDeclLinear (uint32 vertCount, VertexDecl &decl)
 Set the linear vertex declaration for this buffer. More...
 
void setVertexDeclInterleave (uint32 vertCount, VertexDecl &decl)
 Set the interleaved vertex declaration for this buffer. More...
 
GLvoid * getData ()
 Access buffer data. More...
 
const GLvoid * getData () const
 Access buffer data. More...
 
GLvoid * getData (size_t vertexDecl)
 Access buffer data of a specific vertex declaration. More...
 
const GLvoid * getData (size_t vertexDecl) const
 Access buffer data of a specific vertex declaration. More...
 
const VertexDeclgetVertexDecl () const
 Access vertex declaration. More...
 
uint32 getCount () const
 Get vertex count. More...
 
uint32 getSize () const
 Get vertex element size in bytes. More...
 
void initGL (GLuint hint=GL_STATIC_DRAW)
 Initialise internal buffer object for GL handling. More...
 
void updateGL ()
 Update existing GL buffer object. More...
 
void updateGLBound () const
 Update an existing GL buffer object, assuming it is already bound. More...
 
void destroyGL ()
 Clear (destroy) GL resources associated with the buffer. More...
 
GLuint getVBO () const
 
void draw (GLenum mode, const IndexBuffer &indexBuffer) const
 Draw this IndexBuffer/VertexBuffer combination. More...
 

Static Private Member Functions

static uint32 getTypeSize (GLenum type)
 

Private Attributes

VertexDecl _decl
 Vertex declaration. More...
 
uint32 _count
 Number of elements in buffer. More...
 
uint32 _size
 Size of a buffer element in bytes (vertex attributes size sum). More...
 
byte_data
 Buffer data. More...
 
GLuint _vbo
 Vertex Buffer Object. More...
 
GLuint _hint
 GL hint for static or dynamic data. More...
 

Detailed Description

Buffer containing vertex data.

Definition at line 68 of file vertexbuffer.h.

Constructor & Destructor Documentation

◆ VertexBuffer() [1/2]

Graphics::VertexBuffer::VertexBuffer ( )

Definition at line 92 of file vertexbuffer.cpp.

◆ VertexBuffer() [2/2]

Graphics::VertexBuffer::VertexBuffer ( const VertexBuffer other)

Definition at line 95 of file vertexbuffer.cpp.

◆ ~VertexBuffer()

Graphics::VertexBuffer::~VertexBuffer ( )

Definition at line 99 of file vertexbuffer.cpp.

References _data, and destroyGL().

Here is the call graph for this function:

Member Function Documentation

◆ destroyGL()

void Graphics::VertexBuffer::destroyGL ( )

Clear (destroy) GL resources associated with the buffer.

Definition at line 275 of file vertexbuffer.cpp.

References _vbo.

Referenced by Graphics::Mesh::Mesh::destroyGL(), and ~VertexBuffer().

Here is the caller graph for this function:

◆ draw()

void Graphics::VertexBuffer::draw ( GLenum  mode,
const IndexBuffer indexBuffer 
) const

Draw this IndexBuffer/VertexBuffer combination.

Definition at line 286 of file vertexbuffer.cpp.

References _decl, Graphics::IndexBuffer::getCount(), getCount(), Graphics::IndexBuffer::getData(), and Graphics::IndexBuffer::getType().

Referenced by Graphics::Aurora::GeometryObject::render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCount()

uint32 Graphics::VertexBuffer::getCount ( ) const

◆ getData() [1/4]

GLvoid * Graphics::VertexBuffer::getData ( )

◆ getData() [2/4]

const GLvoid * Graphics::VertexBuffer::getData ( ) const

Access buffer data.

Definition at line 221 of file vertexbuffer.cpp.

References _data.

◆ getData() [3/4]

GLvoid * Graphics::VertexBuffer::getData ( size_t  vertexDecl)

Access buffer data of a specific vertex declaration.

Definition at line 225 of file vertexbuffer.cpp.

References _decl.

◆ getData() [4/4]

const GLvoid * Graphics::VertexBuffer::getData ( size_t  vertexDecl) const

Access buffer data of a specific vertex declaration.

Definition at line 231 of file vertexbuffer.cpp.

References _decl.

◆ getSize()

uint32 Graphics::VertexBuffer::getSize ( ) const

Get vertex element size in bytes.

Definition at line 245 of file vertexbuffer.cpp.

References _size.

Referenced by Graphics::Aurora::ModelNode::flushBuffers().

Here is the caller graph for this function:

◆ getTypeSize()

uint32 Graphics::VertexBuffer::getTypeSize ( GLenum  type)
staticprivate

Definition at line 157 of file vertexbuffer.cpp.

Referenced by setVertexDeclInterleave(), and setVertexDeclLinear().

Here is the caller graph for this function:

◆ getVBO()

GLuint Graphics::VertexBuffer::getVBO ( ) const

Definition at line 282 of file vertexbuffer.cpp.

References _vbo.

Referenced by Graphics::Mesh::Mesh::initGL(), Graphics::Mesh::Mesh::renderBind(), and Graphics::Aurora::TextureFont::renderBind().

Here is the caller graph for this function:

◆ getVertexDecl()

const VertexDecl & Graphics::VertexBuffer::getVertexDecl ( ) const

◆ initGL()

void Graphics::VertexBuffer::initGL ( GLuint  hint = GL_STATIC_DRAW)

Initialise internal buffer object for GL handling.

Definition at line 249 of file vertexbuffer.cpp.

References _count, _data, _hint, _size, and _vbo.

Referenced by Graphics::Mesh::Mesh::initGL().

Here is the caller graph for this function:

◆ operator=()

VertexBuffer & Graphics::VertexBuffer::operator= ( const VertexBuffer other)

Definition at line 104 of file vertexbuffer.cpp.

References _count, _data, _decl, _size, setSize(), and setVertexDecl().

Here is the call graph for this function:

◆ setSize()

void Graphics::VertexBuffer::setSize ( uint32  vertCount,
uint32  vertSize 
)

Change buffer size.

Will allocate memory, free previous.

Definition at line 141 of file vertexbuffer.cpp.

References _count, _data, and _size.

Referenced by Graphics::Mesh::MeshFont::MeshFont(), Graphics::Mesh::MeshWireBox::MeshWireBox(), operator=(), setVertexDeclInterleave(), and setVertexDeclLinear().

Here is the caller graph for this function:

◆ setVertexDecl()

void Graphics::VertexBuffer::setVertexDecl ( const VertexDecl decl)

Set vertex declaration for this buffer.

Definition at line 153 of file vertexbuffer.cpp.

References _decl.

Referenced by Graphics::Mesh::MeshWireBox::MeshWireBox(), and operator=().

Here is the caller graph for this function:

◆ setVertexDeclInterleave()

void Graphics::VertexBuffer::setVertexDeclInterleave ( uint32  vertCount,
VertexDecl decl 
)

Set the interleaved vertex declaration for this buffer.

Will allocate memory to fit vertCount vertices into this buffer and modify the declaration's pointers and strides to fit an interleaved layout.

Definition at line 199 of file vertexbuffer.cpp.

References _data, _decl, getTypeSize(), and setSize().

Referenced by Graphics::Aurora::ModelNode_Jade::createMesh(), Graphics::Aurora::ModelNode_DragonAge::createVertexBuffer(), Graphics::Aurora::Model_Sonic::evaluatePrimitive(), Graphics::Aurora::ModelNode_NWN2::loadRigid(), Graphics::Aurora::ModelNode_NWN2::loadSkin(), Engines::NWN2::TRXFile::loadTRRN(), Engines::NWN2::TRXFile::loadWATR(), Graphics::Aurora::ModelNode_NWN_Binary::readMesh(), and Graphics::Aurora::ModelNode_KotOR::readMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVertexDeclLinear()

void Graphics::VertexBuffer::setVertexDeclLinear ( uint32  vertCount,
VertexDecl decl 
)

Set the linear vertex declaration for this buffer.

Will allocate memory to fit vertCount vertices into this buffer and modify the declaration's pointers and strides to fit a linear layout.

Definition at line 181 of file vertexbuffer.cpp.

References _data, _decl, getTypeSize(), and setSize().

Referenced by Engines::Jade::Trigger::loadInstance(), Graphics::Mesh::MeshFont::MeshFont(), Graphics::Mesh::MeshQuad::MeshQuad(), Graphics::Aurora::ModelNode_Witcher::readMesh(), and Graphics::Aurora::ModelNode_Witcher::readTexturePaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGL()

void Graphics::VertexBuffer::updateGL ( )

Update existing GL buffer object.

Try not to call while rendering.

Definition at line 263 of file vertexbuffer.cpp.

References _count, _data, _hint, _size, and _vbo.

Referenced by Graphics::Aurora::ModelNode::render(), and Graphics::Mesh::Mesh::updateGL().

Here is the caller graph for this function:

◆ updateGLBound()

void Graphics::VertexBuffer::updateGLBound ( ) const

Update an existing GL buffer object, assuming it is already bound.

Definition at line 271 of file vertexbuffer.cpp.

References _count, _data, and _size.

Referenced by Graphics::Mesh::MeshFont::render().

Here is the caller graph for this function:

Member Data Documentation

◆ _count

uint32 Graphics::VertexBuffer::_count
private

Number of elements in buffer.

Definition at line 139 of file vertexbuffer.h.

Referenced by getCount(), initGL(), operator=(), setSize(), updateGL(), and updateGLBound().

◆ _data

byte* Graphics::VertexBuffer::_data
private

◆ _decl

VertexDecl Graphics::VertexBuffer::_decl
private

Vertex declaration.

Definition at line 138 of file vertexbuffer.h.

Referenced by draw(), getData(), getVertexDecl(), operator=(), setVertexDecl(), setVertexDeclInterleave(), and setVertexDeclLinear().

◆ _hint

GLuint Graphics::VertexBuffer::_hint
private

GL hint for static or dynamic data.

Definition at line 144 of file vertexbuffer.h.

Referenced by initGL(), and updateGL().

◆ _size

uint32 Graphics::VertexBuffer::_size
private

Size of a buffer element in bytes (vertex attributes size sum).

Definition at line 140 of file vertexbuffer.h.

Referenced by getSize(), initGL(), operator=(), setSize(), updateGL(), and updateGLBound().

◆ _vbo

GLuint Graphics::VertexBuffer::_vbo
private

Vertex Buffer Object.

Definition at line 143 of file vertexbuffer.h.

Referenced by destroyGL(), getVBO(), initGL(), and updateGL().


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