UGDK
0.5.0
|
#include <ugdk/graphic/opengl/vertexbuffer.h>
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 VertexBuffer * | Create (size_t size, GLenum target, GLenum usage) |
static std::shared_ptr< const VertexBuffer > | CreateDefaultShared () |
static const VertexBuffer * | CreateDefault () |
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.
ugdk::graphic::opengl::VertexBuffer::VertexBuffer | ( | size_t | size, |
GLenum | target, | ||
GLenum | usage | ||
) |
Constructor.
size | The size of the VertexBuffer in bytes. |
target | The target VertexBuffer object, e.g. GL_ARRAY_BUFFER. |
usage | Usage hint, e.g. GL_DYNAMIC_DRAW. |
|
virtual |
Destructor. Does nothing, but must be declared virtual.
|
pure virtual |
Bind the VertexBuffer to the specified target. (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).
target | GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER. |
Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.
|
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.
size | The size of the VertexBuffer (in bytes). |
target | GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER. |
usage | GL_DYNAMIC_DRAW, etc. |
|
static |
|
static |
|
pure virtual |
Fill a portion of the buffer with data.
The VertexBuffer must be bound to use this function.
offset | The offset in the VertexBuffer to store the data. |
size | The size of the incoming data. |
data | Pointer to memory to copy data from. |
Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.
|
pure virtual |
Get a pointer which represents the specified byte offset.
offset | The byte offset. (0 is first byte). |
Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.
|
inline |
Get the size of the VertexBuffer, in bytes.
|
inline |
Get the target buffer object.
|
inline |
Get the usage hint for this VertexBuffer.
|
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.
Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.
|
pure virtual |
Unbind a prevously bound VertexBuffer.
Implemented in ugdk::graphic::opengl::VBO, and ugdk::graphic::opengl::VertexArray.
|
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.