Host-side image buffer. More...
#include <ImageBuffer.hpp>
Public Member Functions | |
ImageBuffer (const HdlAbstractTextureFormat &format, int _alignment=1) | |
ImageBuffer constructor. More... | |
ImageBuffer (void *buffer, const HdlAbstractTextureFormat &format, int _alignment=1) | |
ImageBuffer proxy constructor. More... | |
ImageBuffer (HdlTexture &texture, int _alignment=1) | |
ImageBuffer constructor. More... | |
ImageBuffer (const ImageBuffer &image) | |
ImageBuffer copy constructor. More... | |
const HdlTextureFormatDescriptor & | getDescriptor (void) const |
Get the descriptor of the GL mode. More... | |
void * | getPtr (void) |
Get access to the buffer. More... | |
const void * | getPtr (void) const |
Get access to the buffer. More... | |
HdlDynamicTable & | getTable (void) |
Access the underlying table. More... | |
const HdlDynamicTable & | getTable (void) const |
Access the underlying table. More... | |
void | setMinFilter (GLenum mf) |
Sets the texture's minification parameter. More... | |
void | setMagFilter (GLenum mf) |
Sets the texture's magnification parameter. More... | |
void | setSWrapping (GLenum m) |
Sets the texture's S wrapping parameter. More... | |
void | setTWrapping (GLenum m) |
Sets the texture's T wrapping parameter. More... | |
const ImageBuffer & | operator<< (HdlTexture &texture) |
Copy a texture to this buffer and the following properties : minification and magnification filters, S and T wrapping modes. More... | |
const ImageBuffer & | operator<< (const ImageBuffer &image) |
Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes. More... | |
const ImageBuffer & | operator<< (const void *bytes) |
Copy an array. More... | |
const ImageBuffer & | operator>> (HdlTexture &texture) const |
Write buffer to a texture and the following properties : minification and magnification filters, S and T wrapping modes. More... | |
const ImageBuffer & | operator>> (ImageBuffer &image) const |
Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes. More... | |
const ImageBuffer & | operator>> (void *bytes) const |
Copy an array. More... | |
long long | get (const int &x, const int &y, const GLenum &channel) const |
Get an element from the array. The output type is much larger than any possible type and the value from buffer is not stretched except if the buffer is in single or double floating point precision. More... | |
void | set (const long long &value, const int &x, const int &y, const GLenum &channel) |
Set an element in the array. The value is clamped to fit the precision of the buffer or normalized if the buffer is in single or double floating point precision. More... | |
float | getNormalized (const int &x, const int &y, const GLenum &channel) const |
Get an element from the array. The output is between 0.0f and 1.0f. More... | |
void | setNormalized (const float &value, const int &x, const int &y, const GLenum &channel) |
Set an element in the array. The value is clamped to the range [0.0f, 1.0f] and stretched to the buffer precision. More... | |
void | write (const std::string &filename, const std::string &comment="") const |
Write an image buffer to a RAW file. The raw file contain all image information, plus texture setting and an optional comment. Raise an exception if any error occurs. More... | |
Public Member Functions inherited from Glip::CoreGL::HdlAbstractTextureFormat | |
int | getWidth (void) const |
int | getHeight (void) const |
int | getNumPixels (void) const |
int | getNumChannels (void) const |
int | getNumElements (void) const |
int | getAlignment (void) const |
int | getPixelSize (void) const |
virtual size_t | getRowSize (void) const |
virtual size_t | getSize (void) const |
int | getChannelDepth (void) const |
GLenum | getGLMode (void) const |
GLenum | getGLDepth (void) const |
GLenum | getMinFilter (void) const |
GLenum | getMagFilter (void) const |
int | getBaseLevel (void) const |
int | getMaxLevel (void) const |
GLenum | getSWrapping (void) const |
GLenum | getTWrapping (void) const |
bool | isCompressed (void) const |
bool | isFloatingPoint (void) const |
const HdlTextureFormatDescriptor & | getFormatDescriptor (void) const |
bool | operator== (const HdlAbstractTextureFormat &) const |
bool | operator!= (const HdlAbstractTextureFormat &) const |
bool | isCompatibleWith (const HdlAbstractTextureFormat &) const |
Check if the two formats share the same memory characteristics (sizes, number of channels, byte per pixel, internal GL mode, same mipmap levels). More... | |
HdlAbstractTextureFormat | getCompressedFormat (void) const |
Get the equivalent, but compressed, format. More... | |
HdlAbstractTextureFormat | getUncompressedFormat (void) const |
Get the equivalent, but uncompressed, format. More... | |
bool | isCorrespondingCompressedFormat (const HdlAbstractTextureFormat &) const |
Check if this and f share the same memory parameters except that the mode for f is the corresponding compressed mode of this. More... | |
virtual unsigned int | getSetting (GLenum param) const |
Obtain a setting value based on its GL name. More... | |
Static Public Member Functions | |
static ImageBuffer * | load (const std::string &filename, std::string *comment=NULL) |
Load an image buffer from a RAW file. The raw file contain all image information, plus texture setting and an optional comment. More... | |
Static Public Member Functions inherited from Glip::CoreGL::HdlAbstractTextureFormat | |
static int | getMaxSize (void) |
Returns the maximum size for a texture. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Glip::CoreGL::HdlAbstractTextureFormat | |
HdlAbstractTextureFormat (int _width, int _height, GLenum _mode, GLenum _depth, GLenum _minFilter=GL_NEAREST, GLenum _magFilter=GL_NEAREST, GLenum _wraps=GL_CLAMP, GLenum _wrapt=GL_CLAMP, int _baseLevel=0, int _maxLevel=0) | |
HdlAbstractTextureFormat Construtor. More... | |
HdlAbstractTextureFormat (const HdlAbstractTextureFormat ©) | |
HdlAbstractTextureFormat Construtor. More... | |
void | setAlignment (int _alignment) |
Set the alignment for this format. More... | |
Host-side image buffer.
ImageBuffer::ImageBuffer | ( | const HdlAbstractTextureFormat & | format, |
int | _alignment = 1 |
||
) |
ImageBuffer constructor.
format | The format of this buffer (or the equivalent uncompressed format). |
_alignment | Force the memory alignment to either 1, 4 or 8 bytes. |
ImageBuffer::ImageBuffer | ( | void * | buffer, |
const HdlAbstractTextureFormat & | format, | ||
int | _alignment = 1 |
||
) |
ImageBuffer proxy constructor.
buffer | The buffer to point to, this memory table will NOT be deleted when this object is destroyed. |
format | The format of this buffer (or the equivalent uncompressed format). |
_alignment | Force the memory alignment to either 1, 4 or 8 bytes. |
ImageBuffer::ImageBuffer | ( | HdlTexture & | texture, |
int | _alignment = 1 |
||
) |
ImageBuffer constructor.
texture | Copy the format and data of the this texture. |
_alignment | Force the memory alignment to either 1, 4 or 8 bytes. |
ImageBuffer::ImageBuffer | ( | const ImageBuffer & | image | ) |
ImageBuffer copy constructor.
image | Image buffer to copy. |
long long ImageBuffer::get | ( | const int & | x, |
const int & | y, | ||
const GLenum & | channel | ||
) | const |
Get an element from the array. The output type is much larger than any possible type and the value from buffer is not stretched except if the buffer is in single or double floating point precision.
x | X-axis coordinate (along the width). |
y | Y-axis coordinate (along the height). |
channel | The channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE). |
const HdlTextureFormatDescriptor & ImageBuffer::getDescriptor | ( | void | ) | const |
Get the descriptor of the GL mode.
float ImageBuffer::getNormalized | ( | const int & | x, |
const int & | y, | ||
const GLenum & | channel | ||
) | const |
Get an element from the array. The output is between 0.0f and 1.0f.
x | X-axis coordinate (along the width). |
y | Y-axis coordinate (along the height). |
channel | The channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE). |
void * ImageBuffer::getPtr | ( | void | ) |
Get access to the buffer.
const void * ImageBuffer::getPtr | ( | void | ) | const |
Get access to the buffer.
HdlDynamicTable & ImageBuffer::getTable | ( | void | ) |
Access the underlying table.
const HdlDynamicTable & ImageBuffer::getTable | ( | void | ) | const |
Access the underlying table.
|
static |
Load an image buffer from a RAW file. The raw file contain all image information, plus texture setting and an optional comment.
filename | The file name (and path). |
comment | If the pointer is non-null and if there is a comment in the file, the comment will be written in the tarted string. |
const ImageBuffer & ImageBuffer::operator<< | ( | HdlTexture & | texture | ) |
Copy a texture to this buffer and the following properties : minification and magnification filters, S and T wrapping modes.
texture | The texture to copy. |
const ImageBuffer & ImageBuffer::operator<< | ( | const ImageBuffer & | image | ) |
Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes.
image | The buffer to copy. |
const ImageBuffer & ImageBuffer::operator<< | ( | const void * | bytes | ) |
Copy an array.
bytes | The buffer to copy (assumed to be of size HdlAbstractTextureFormat::getSize()). |
const ImageBuffer & ImageBuffer::operator>> | ( | HdlTexture & | texture | ) | const |
Write buffer to a texture and the following properties : minification and magnification filters, S and T wrapping modes.
texture | The texture to be written. |
const ImageBuffer & ImageBuffer::operator>> | ( | ImageBuffer & | image | ) | const |
Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes.
image | The buffer to be written. |
const ImageBuffer & ImageBuffer::operator>> | ( | void * | bytes | ) | const |
Copy an array.
bytes | The buffer to copy (assumed to be of size HdlAbstractTextureFormat::getSize()). |
void ImageBuffer::set | ( | const long long & | value, |
const int & | x, | ||
const int & | y, | ||
const GLenum & | channel | ||
) |
Set an element in the array. The value is clamped to fit the precision of the buffer or normalized if the buffer is in single or double floating point precision.
value | The input value. |
x | X-axis coordinate (along the width). |
y | Y-axis coordinate (along the height). |
channel | The channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE). |
void ImageBuffer::setMagFilter | ( | GLenum | mf | ) |
Sets the texture's magnification parameter.
mf | The new magnification filter (e.g. GL_NEAREST or GL_LINEAR, only these two options are accepted). |
void ImageBuffer::setMinFilter | ( | GLenum | mf | ) |
Sets the texture's minification parameter.
mf | The new minification filter (e.g. GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR). |
void ImageBuffer::setNormalized | ( | const float & | value, |
const int & | x, | ||
const int & | y, | ||
const GLenum & | channel | ||
) |
Set an element in the array. The value is clamped to the range [0.0f, 1.0f] and stretched to the buffer precision.
value | The input value. |
x | X-axis coordinate (along the width). |
y | Y-axis coordinate (along the height). |
channel | The channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE). |
void ImageBuffer::setSWrapping | ( | GLenum | m | ) |
Sets the texture's S wrapping parameter.
m | The new S wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT) |
void ImageBuffer::setTWrapping | ( | GLenum | m | ) |
Sets the texture's T wrapping parameter.
m | The new T wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT) |
void ImageBuffer::write | ( | const std::string & | filename, |
const std::string & | comment = "" |
||
) | const |
Write an image buffer to a RAW file. The raw file contain all image information, plus texture setting and an optional comment. Raise an exception if any error occurs.
filename | The file name (and path). |
comment | Save this comment to the file (the current limit is a 1MB string). |