glcxx: A Modern C++ Interface to OpenGL Object Management
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
glcxx::Buffer Class Reference

C++ wrapper for an OpenGL buffer object. More...

#include <Buffer.hpp>

Public Member Functions

 Buffer ()
 Construct and allocate an OpenGL buffer object.
 
 ~Buffer ()
 Destroy the buffer object.
 
void set_buffer_data (GLenum target, GLenum usage, const void *ptr, size_t size)
 Set the buffer's data, target, and usage. More...
 
void set_buffer_data (GLenum target, GLenum usage, std::initializer_list< GLfloat > data)
 Set the buffer's data, target, and usage. More...
 
void set_buffer_data_d (GLenum target, GLenum usage, std::initializer_list< GLdouble > data)
 Set the buffer's data, target, and usage. More...
 
GLuint id () const
 Get the buffer object's ID. More...
 
void bind () const
 Bind the buffer object.
 

Static Public Member Functions

static std::shared_ptr< Buffercreate ()
 Factory method to construct a Buffer. More...
 
static std::shared_ptr< Buffercreate (GLenum target, GLenum usage, const void *ptr, size_t size)
 Factory method to construct a Buffer and fill it with data. More...
 
static std::shared_ptr< Buffercreate (GLenum target, GLenum usage, std::initializer_list< GLfloat > data)
 Factory method to construct a Buffer and fill it with data. More...
 
static std::shared_ptr< Buffercreate_d (GLenum target, GLenum usage, std::initializer_list< GLdouble > data)
 Factory method to construct a Buffer and fill it with data. More...
 

Protected Member Functions

void allocate ()
 Allocate the OpenGL buffer object.
 

Protected Attributes

GLuint m_id
 The buffer object's ID.
 
GLenum m_target
 The target for binding the buffer.
 

Detailed Description

C++ wrapper for an OpenGL buffer object.

Member Function Documentation

static std::shared_ptr<Buffer> glcxx::Buffer::create ( )
inlinestatic

Factory method to construct a Buffer.

This method does not fill the buffer with any data.

Returns
std::shared_ptr to the created Buffer.
static std::shared_ptr<Buffer> glcxx::Buffer::create ( GLenum  target,
GLenum  usage,
const void *  ptr,
size_t  size 
)
inlinestatic

Factory method to construct a Buffer and fill it with data.

Parameters
targetBuffer target (e.g. GL_ARRAY_BUFFER).
usageBuffer usage hint (e.g. GL_STATIC_DRAW).
ptrPointer to data to load in buffer.
sizeLength of the data to load in buffer.
Returns
std::shared_ptr to a Buffer.
static std::shared_ptr<Buffer> glcxx::Buffer::create ( GLenum  target,
GLenum  usage,
std::initializer_list< GLfloat >  data 
)
inlinestatic

Factory method to construct a Buffer and fill it with data.

Parameters
targetBuffer target (e.g. GL_ARRAY_BUFFER).
usageBuffer usage hint (e.g. GL_STATIC_DRAW).
dataData to load in buffer.
static std::shared_ptr<Buffer> glcxx::Buffer::create_d ( GLenum  target,
GLenum  usage,
std::initializer_list< GLdouble >  data 
)
inlinestatic

Factory method to construct a Buffer and fill it with data.

Parameters
targetBuffer target (e.g. GL_ARRAY_BUFFER).
usageBuffer usage hint (e.g. GL_STATIC_DRAW).
dataData to load in buffer.
GLuint glcxx::Buffer::id ( ) const
inline

Get the buffer object's ID.

Returns
The buffer object's ID.
void glcxx::Buffer::set_buffer_data ( GLenum  target,
GLenum  usage,
const void *  ptr,
size_t  size 
)

Set the buffer's data, target, and usage.

Parameters
targetBuffer target (e.g. GL_ARRAY_BUFFER).
usageBuffer usage hint (e.g. GL_STATIC_DRAW).
ptrPointer to data to load in buffer.
sizeLength of the data to load in buffer.
void glcxx::Buffer::set_buffer_data ( GLenum  target,
GLenum  usage,
std::initializer_list< GLfloat >  data 
)
inline

Set the buffer's data, target, and usage.

Parameters
targetBuffer target (e.g. GL_ARRAY_BUFFER).
usageBuffer usage hint (e.g. GL_STATIC_DRAW).
dataData to load in buffer.
void glcxx::Buffer::set_buffer_data_d ( GLenum  target,
GLenum  usage,
std::initializer_list< GLdouble >  data 
)
inline

Set the buffer's data, target, and usage.

Parameters
targetBuffer target (e.g. GL_ARRAY_BUFFER).
usageBuffer usage hint (e.g. GL_STATIC_DRAW).
dataData to load in buffer.

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