Cinder  0.9.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
cinder::gl::BufferObj Class Reference

#include <BufferObj.h>

Inherited by cinder::gl::Pbo, cinder::gl::Ssbo, cinder::gl::Ubo, and cinder::gl::Vbo.

Public Member Functions

 ~BufferObj ()
 
void bind () const
 
void unbind () const
 
void bufferData (GLsizeiptr size, const GLvoid *data, GLenum usage)
 
void bufferSubData (GLintptr offset, GLsizeiptr size, const GLvoid *data)
 
void getBufferSubData (GLintptr offset, GLsizeiptr size, GLvoid *data)
 
void copyData (GLsizeiptr size, const GLvoid *data)
 
void ensureMinimumSize (GLsizeiptr minimumSize)
 
void * map (GLenum access) const
 
void * mapWriteOnly ()
 
void * mapReplace ()
 
void * mapBufferRange (GLintptr offset, GLsizeiptr length, GLbitfield access) const
 
void unmap () const
 
GLuint getId () const
 
size_t getSize () const
 
GLenum getTarget () const
 
void setTarget (GLenum target)
 
GLenum getUsage () const
 
void setUsage (GLenum usage)
 
const std::string & getLabel () const
 
void setLabel (const std::string &label)
 

Static Public Member Functions

static BufferObjRef create (GLenum target, GLsizeiptr allocationSize, const void *data, GLenum usage)
 
static GLuint getBindingConstantForTarget (GLenum target)
 

Protected Member Functions

 BufferObj (GLenum target)
 
 BufferObj (GLenum target, GLsizeiptr allocationSize, const void *data, GLenum usage)
 

Protected Attributes

GLuint mId
 
size_t mSize
 
GLenum mTarget
 
GLenum mUsage
 
std::string mLabel
 

Friends

std::ostream & operator<< (std::ostream &os, const BufferObj &rhs)
 

Constructor & Destructor Documentation

cinder::gl::BufferObj::~BufferObj ( )
cinder::gl::BufferObj::BufferObj ( GLenum  target)
protected
cinder::gl::BufferObj::BufferObj ( GLenum  target,
GLsizeiptr  allocationSize,
const void *  data,
GLenum  usage 
)
protected

Member Function Documentation

BufferObjRef cinder::gl::BufferObj::create ( GLenum  target,
GLsizeiptr  allocationSize,
const void *  data,
GLenum  usage 
)
static
void cinder::gl::BufferObj::bind ( ) const
void cinder::gl::BufferObj::unbind ( ) const
void cinder::gl::BufferObj::bufferData ( GLsizeiptr  size,
const GLvoid *  data,
GLenum  usage 
)

Analogous to glBufferData()

void cinder::gl::BufferObj::bufferSubData ( GLintptr  offset,
GLsizeiptr  size,
const GLvoid *  data 
)

Analogous to glBufferSubData()

void cinder::gl::BufferObj::getBufferSubData ( GLintptr  offset,
GLsizeiptr  size,
GLvoid *  data 
)

Returns some or all of the data from the buffer object currently bound for this objects target.

void cinder::gl::BufferObj::copyData ( GLsizeiptr  size,
const GLvoid *  data 
)

Calls bufferSubData when the size is adequate, otherwise calls bufferData, forcing a reallocation of the data store.

void cinder::gl::BufferObj::ensureMinimumSize ( GLsizeiptr  minimumSize)

Reallocates the buffer if its size is smaller than minimumSize. This destroys the contents of the buffer if it must be reallocated.

void * cinder::gl::BufferObj::map ( GLenum  access) const

Analogous to glMapBuffer(). access must be GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE. On iOS ES 2 only GL_WRITE_ONLY_OES is valid.

void * cinder::gl::BufferObj::mapWriteOnly ( )

Maps the Buffer for writing, but does not invalidate the Buffer's existing contents. Slower than mapReplace(). Abstracts glMapBuffer() vs. glMapBufferRange() with appropriate write-only parameters for the platform.

void * cinder::gl::BufferObj::mapReplace ( )

Invalidates the Buffer's existing contents and maps it for writing. Preferable to mapWriteOnly() when invalidation is acceptable. Abstracts glMapBuffer() vs. glMapBufferRange() with appropriate write-only parameters for the platform.

void * cinder::gl::BufferObj::mapBufferRange ( GLintptr  offset,
GLsizeiptr  length,
GLbitfield  access 
) const

Analogous to glMapBufferRange(). On iOS ES 2 only GL_WRITE_ONLY_OES is valid.

void cinder::gl::BufferObj::unmap ( ) const
GLuint cinder::gl::BufferObj::getId ( ) const
size_t cinder::gl::BufferObj::getSize ( ) const
GLenum cinder::gl::BufferObj::getTarget ( ) const
void cinder::gl::BufferObj::setTarget ( GLenum  target)
GLenum cinder::gl::BufferObj::getUsage ( ) const
void cinder::gl::BufferObj::setUsage ( GLenum  usage)
GLuint cinder::gl::BufferObj::getBindingConstantForTarget ( GLenum  target)
static

Returns the appropriate parameter to glGetIntegerv() for a specific target; ie GL_ARRAY_BUFFER -> GL_ARRAY_BUFFER_BINDING. Returns 0 on failure.

const std::string& cinder::gl::BufferObj::getLabel ( ) const

Returns the debugging label associated with the Buffer.

void cinder::gl::BufferObj::setLabel ( const std::string &  label)

Sets the debugging label associated with the Buffer. Calls glObjectLabel() when available.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const BufferObj rhs 
)
friend

Member Data Documentation

GLuint cinder::gl::BufferObj::mId
protected
size_t cinder::gl::BufferObj::mSize
protected
GLenum cinder::gl::BufferObj::mTarget
protected
GLenum cinder::gl::BufferObj::mUsage
protected
std::string cinder::gl::BufferObj::mLabel
protected

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