UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ugdk::graphic::opengl::VertexBuffer Class Referenceabstract

#include <ugdk/graphic/opengl/vertexbuffer.h>

Inheritance diagram for ugdk::graphic::opengl::VertexBuffer:

Classes

class  Bind
 
class  Mapper
 

Public Member Functions

 VertexBuffer (size_t size, GLenum target, GLenum usage)
 
virtual ~VertexBuffer ()
 
size_t getSize () const
 
GLenum getTarget () const
 
GLenum getUsage () const
 
virtual void * map ()=0
 
virtual void unmap ()=0
 
virtual void bind () const =0
 
virtual void unbind () const =0
 
virtual void fill (size_t offset, size_t size, const void *data)=0
 
virtual const void * getPointer (size_t offset) const =0
 

Static Public Member Functions

static VertexBufferCreate (size_t size, GLenum target, GLenum usage)
 
static std::shared_ptr< const
VertexBuffer
CreateDefaultShared ()
 
static const VertexBufferCreateDefault ()
 

Detailed Description

VertexBuffer is an abstraction over VBOs (Vertex Buffer Objecys), which falls back to regular vertex arrays if VBOs are not supported.

This allows code to take advantage of VBOs where available, but still work on older systems where it's not available. Everyone's happy.

The class is (for now) meant for internal use.

Constructor & Destructor Documentation

ugdk::graphic::opengl::VertexBuffer::VertexBuffer ( size_t  size,
GLenum  target,
GLenum  usage 
)

Constructor.

Parameters
sizeThe size of the VertexBuffer in bytes.
targetThe target VertexBuffer object, e.g. GL_ARRAY_BUFFER.
usageUsage hint, e.g. GL_DYNAMIC_DRAW.
virtual ugdk::graphic::opengl::VertexBuffer::~VertexBuffer ( )
virtual

Destructor. Does nothing, but must be declared virtual.

Member Function Documentation

virtual void ugdk::graphic::opengl::VertexBuffer::bind ( ) const
pure virtual

Bind the VertexBuffer to the specified target. (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).

Parameters
targetGL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.

Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.

static VertexBuffer* ugdk::graphic::opengl::VertexBuffer::Create ( size_t  size,
GLenum  target,
GLenum  usage 
)
static

Create a new VertexBuffer (either a plain vertex array, or a VBO), based on what's supported on the system.

If VBOs are not supported, a plain vertex array will automatically be created and returned instead.

Parameters
sizeThe size of the VertexBuffer (in bytes).
targetGL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER.
usageGL_DYNAMIC_DRAW, etc.
Returns
A new VertexBuffer.
static const VertexBuffer* ugdk::graphic::opengl::VertexBuffer::CreateDefault ( )
static
static std::shared_ptr<const VertexBuffer> ugdk::graphic::opengl::VertexBuffer::CreateDefaultShared ( )
static
virtual void ugdk::graphic::opengl::VertexBuffer::fill ( size_t  offset,
size_t  size,
const void *  data 
)
pure virtual

Fill a portion of the buffer with data.

The VertexBuffer must be bound to use this function.

Parameters
offsetThe offset in the VertexBuffer to store the data.
sizeThe size of the incoming data.
dataPointer to memory to copy data from.

Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.

virtual const void* ugdk::graphic::opengl::VertexBuffer::getPointer ( size_t  offset) const
pure virtual

Get a pointer which represents the specified byte offset.

Parameters
offsetThe byte offset. (0 is first byte).
Returns
A pointer which represents the offset.

Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.

size_t ugdk::graphic::opengl::VertexBuffer::getSize ( ) const
inline

Get the size of the VertexBuffer, in bytes.

Returns
The size of the VertexBuffer.
GLenum ugdk::graphic::opengl::VertexBuffer::getTarget ( ) const
inline

Get the target buffer object.

Returns
The target buffer object, e.g. GL_ARRAY_BUFFER.
GLenum ugdk::graphic::opengl::VertexBuffer::getUsage ( ) const
inline

Get the usage hint for this VertexBuffer.

Returns
The usage hint, e.g. GL_DYNAMIC_DRAW.
virtual void* ugdk::graphic::opengl::VertexBuffer::map ( )
pure virtual

Map the VertexBuffer to client memory.

This can be faster for large changes to the buffer. For smaller changes, see fill().

The VertexBuffer must be bound to use this function.

Returns
A pointer to memory which represents the buffer.

Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.

virtual void ugdk::graphic::opengl::VertexBuffer::unbind ( ) const
pure virtual

Unbind a prevously bound VertexBuffer.

Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.

virtual void ugdk::graphic::opengl::VertexBuffer::unmap ( )
pure virtual

Unmap a previously mapped VertexBuffer. The buffer must be unmapped when used to draw elements.

The VertexBuffer must be bound to use this function.

Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.


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