GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
Glip::CoreGL::HdlPBO Class Reference

Object handle for OpenGL Pixel Buffer Objects. More...

#include <HdlPBO.hpp>

Inheritance diagram for Glip::CoreGL::HdlPBO:
Inheritance graph

Public Member Functions

 HdlPBO (int _w, int _h, int _c, int _cs, GLenum aim, GLenum freq, int size=-1)
 HdlPBO constructor. More...
 
 HdlPBO (const HdlAbstractTextureFormat &fmt, GLenum aim, GLenum freq)
 HdlPBO constructor. More...
 
int getWidth (void)
 
int getHeight (void)
 
int getChannelCount (void)
 
int getChannelSize (void)
 
void copyToTexture (HdlTexture &texture, int oX=0, int oY=0, int w=-1, int h=-1, GLenum mode=GL_NONE, GLenum depth=GL_NONE)
 
void bindAsPack (void)
 Bind PBO to GL_PIXEL_PACK_BUFFER, to gather data from a buffer or a texture.
 
void bindAsUnpack (void)
 Bind PBO to GL_PIXEL_UNPACK_BUFFER, to send data to a buffer or a texture.
 
- Public Member Functions inherited from Glip::CoreGL::HdlGeBO
 HdlGeBO (GLsizeiptr _size, GLenum infoTarget, GLenum infoUsage)
 HdlGeBO Construtor. More...
 
 HdlGeBO (GLuint id, GLsizeiptr _size, GLenum infoTarget, GLenum infoUsage)
 HdlGeBO Construtor. More...
 
GLsizeiptr getSize (void)
 Get the size of the Buffer Object. More...
 
GLuint getID (void)
 Get the ID of the Buffer Object. More...
 
GLenum getTarget (void)
 Get the target of the Buffer Object. More...
 
GLenum getUsage (void)
 Get the usage of the Buffer Object. More...
 
void bind (GLenum target=GL_NONE)
 Bind the Buffer Object to target. More...
 
void * map (GLenum access=GL_NONE, GLenum target=GL_NONE)
 Map the Buffer Object into the CPU memory. More...
 
void write (const void *data)
 Write data to a Buffer Object with classical glBufferData method. More...
 
void subWrite (const void *data, GLsizeiptr size, GLintptr offset)
 Write data to a Buffer Object with classical glBufferSubData method. More...
 

Static Public Member Functions

static void unbind (GLenum target=0)
 Unbind the PBO bound to target. More...
 
static void unmap (GLenum target=0)
 Unmap the PBO mapped from/to target. More...
 
- Static Public Member Functions inherited from Glip::CoreGL::HdlGeBO
static void unbind (GLenum target)
 Unbind any Buffer Object. More...
 
static void unmap (GLenum target)
 Unmap any Buffer Object. More...
 
static bool isBound (GLenum target)
 Test if the target is bound. More...
 
static bool isMapped (GLenum target)
 Test if the target is mapped. More...
 

Detailed Description

Object handle for OpenGL Pixel Buffer Objects.

How to use a PBO to upload data to a texture :

HdlTextureFormat fmt(...);
HdlTexture someTexture(fmt);
HdlPBO pbo(fmt, GL_PIXEL_UNPACK_BUFFER_ARB, GL_STREAM_DRAW_ARB);
unsigned char* ptr = reinterpret_cast<unsigned char*>(pbo.map());
memcpy(ptr, yourBuffer, fmt.getNumPixels()*fmt.getNumChannels());
HdlPBO::unmap(GL_PIXEL_UNPACK_BUFFER_ARB);
pbo.copyToTexture(someTexture);

For reading operations, use Glip::Modules::PBOTextureReader.

Constructor & Destructor Documentation

HdlPBO::HdlPBO ( int  _w,
int  _h,
int  _c,
int  _cs,
GLenum  aim,
GLenum  freq,
int  size = -1 
)

HdlPBO constructor.

Parameters
_wThe width of the buffer.
_hThe height of the buffer.
_cThe number of channels.
_csThe size of each channel (in bytes).
aimThe target (GL_PIXEL_UNPACK_BUFFER_ARB, GL_PIXEL_PACK_BUFFER_ARB).
freqThe frequency (GL_STATIC_DRAW_ARB, GL_STATIC_READ_ARB, GL_STATIC_COPY_ARB, GL_DYNAMIC_DRAW_ARB, GL_DYNAMIC_READ_ARB, GL_DYNAMIC_COPY_ARB, GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, GL_STREAM_COPY_ARB).
sizeThe size of the buffer, computed by default with previous parameters.
HdlPBO::HdlPBO ( const HdlAbstractTextureFormat fmt,
GLenum  aim,
GLenum  freq 
)

HdlPBO constructor.

Parameters
fmtThe format to copy, this must an uncompressed format.
aimThe target (GL_PIXEL_UNPACK_BUFFER_ARB, GL_PIXEL_PACK_BUFFER_ARB).
freqThe frequency (GL_STATIC_DRAW_ARB, GL_STATIC_READ_ARB, GL_STATIC_COPY_ARB, GL_DYNAMIC_DRAW_ARB, GL_DYNAMIC_READ_ARB, GL_DYNAMIC_COPY_ARB, GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, GL_STREAM_COPY_ARB).

Member Function Documentation

void HdlPBO::copyToTexture ( HdlTexture texture,
int  oX = 0,
int  oY = 0,
int  w = -1,
int  h = -1,
GLenum  mode = GL_NONE,
GLenum  depth = GL_NONE 
)
Parameters
textureThe target texture.
oXThe offset in X direction for the destination target, default is 0.
oYThe offset in Y direction for the destination target, default is 0.
wThe width to be copied, default is the width of texture.
hThe height to be copied, default is the height of texture.
modeThe channel layout of the input data, default is the mode of texture.
depthThe depth of the input data, default is the depth of texture.
int HdlPBO::getChannelCount ( void  )
Returns
The number of channels of the buffer.
int HdlPBO::getChannelSize ( void  )
Returns
The channel size (in bytes) of the buffer.
int HdlPBO::getHeight ( void  )
Returns
The height of the buffer.
int HdlPBO::getWidth ( void  )
Returns
The width of the buffer.
void HdlPBO::unbind ( GLenum  target = 0)
static

Unbind the PBO bound to target.

Parameters
targetThe target binding point.
void HdlPBO::unmap ( GLenum  target = 0)
static

Unmap the PBO mapped from/to target.

Parameters
targetThe target binding point.

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