Object handle for OpenGL textures. More...
#include <HdlTexture.hpp>
Public Member Functions | |
HdlTexture (const HdlAbstractTextureFormat &fmt) | |
HdlTexture constructor. More... | |
HdlTexture (GLuint proxyTexID) | |
Create a texture object as a proxy for another texture. More... | |
GLuint | getID (void) const |
Get the ID of the texture. More... | |
bool | isProxy (void) const |
Test if this texture object is a proxy. More... | |
int | getSizeOnGPU (int m=0) |
Returns the size of the texture in bytes for mipmap m, this function returns the same value as HdlAbstractTextureFormat::getSize() for standard textures but gives the true size on the GPU for compressed textures. As this function requires a GL API call plus binding, this may be slow. More... | |
void | bind (GLenum unit=GL_TEXTURE0_ARB) |
Bind the texture to a unit. More... | |
void | bind (int unit) |
Bind the texture to a unit. More... | |
void | write (GLvoid *texData, GLenum pixelFormat=GL_ZERO, GLenum pixelDepth=GL_ZERO, int alignment=-1) |
Write data to a texture using classical glTexImage method. In the case that the texture is compressed and the input data is not of the compressed format, you MUST specify pixelFormat and pixelDepth. WARNING : this function does not perform error checking. More... | |
void | writeCompressed (GLvoid *texData, int size, GLenum pixelFormat=GL_ZERO, GLenum pixelDepth=GL_ZERO, int alignment=-1) |
Write compressed data to a texture using glCompressedTexImage2D method. More... | |
void | fill (char dataByte) |
Fill a texture will a gray level. More... | |
void | read (GLvoid *data, GLenum pixelFormat=GL_ZERO, GLenum pixelDepth=GL_ZERO, int alignment=-1) |
Read data from a classical texture using classical glGetTexImage method. WARNING : this function does not perform error checking. More... | |
GLenum | getInternalMode (void) |
Get the internal format of the texture. For an uncompressed texture the result is the same as getGLMode() but for a compressed texture it returns the real compression mode used. More... | |
void | setMinFilter (GLenum mf) |
Sets the texture's minification parameter. WARNING : no error checking is performed within this function. More... | |
void | setMagFilter (GLenum mf) |
Sets the texture's magnification parameter. WARNING : no error checking is performed within this function. More... | |
void | setSWrapping (GLenum m) |
Sets the texture's S wrapping parameter. WARNING : no error checking is performed within this function. More... | |
void | setTWrapping (GLenum m) |
Sets the texture's T wrapping parameter. WARNING : no error checking is performed within this function. More... | |
void | setSetting (GLenum param, unsigned int value) |
Set parameter, this function will raise an Exception if any errors occur. More... | |
const HdlAbstractTextureFormat & | format (void) const |
Explicitly return a constant reference to a HdlAbstractTextureFormat object describing the format of this texture. 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 void | unbind (GLenum unit=GL_TEXTURE0_ARB) |
Unbind a unit from any texture. More... | |
static void | unbind (int unit) |
Unbind a unit from any texture. More... | |
static int | getMaxImageUnits (void) |
Get the maximum number of texture that can be bound at the same time (ie. the maximum number of input port of a filter). 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... | |
Object handle for OpenGL textures.
HdlTexture::HdlTexture | ( | const HdlAbstractTextureFormat & | fmt | ) |
HdlTexture constructor.
fmt | The format to use. |
HdlTexture::HdlTexture | ( | GLuint | proxyTexID | ) |
Create a texture object as a proxy for another texture.
The user is responsible for maintening the texture in memory while this object exists and to clear the texture when needed.
proxyTexID | The ID of the targeted texture. |
void HdlTexture::bind | ( | GLenum | unit = GL_TEXTURE0_ARB | ) |
Bind the texture to a unit.
unit | The target unit. |
void HdlTexture::bind | ( | int | unit | ) |
Bind the texture to a unit.
unit | The target unit. |
void HdlTexture::fill | ( | char | dataByte | ) |
Fill a texture will a gray level.
dataByte | The gray level to apply. |
const HdlAbstractTextureFormat & HdlTexture::format | ( | void | ) | const |
Explicitly return a constant reference to a HdlAbstractTextureFormat object describing the format of this texture.
GLuint HdlTexture::getID | ( | void | ) | const |
Get the ID of the texture.
GLenum HdlTexture::getInternalMode | ( | void | ) |
Get the internal format of the texture. For an uncompressed texture the result is the same as getGLMode() but for a compressed texture it returns the real compression mode used.
|
static |
Get the maximum number of texture that can be bound at the same time (ie. the maximum number of input port of a filter).
int HdlTexture::getSizeOnGPU | ( | int | m = 0 | ) |
Returns the size of the texture in bytes for mipmap m, this function returns the same value as HdlAbstractTextureFormat::getSize() for standard textures but gives the true size on the GPU for compressed textures. As this function requires a GL API call plus binding, this may be slow.
m | The target mipmap level. |
bool HdlTexture::isProxy | ( | void | ) | const |
Test if this texture object is a proxy.
void HdlTexture::read | ( | GLvoid * | data, |
GLenum | pixelFormat = GL_ZERO , |
||
GLenum | pixelDepth = GL_ZERO , |
||
int | _alignment = -1 |
||
) |
Read data from a classical texture using classical glGetTexImage method. WARNING : this function does not perform error checking.
data | The pointer to the data. |
pixelFormat | The pixel format of the input data (considered the same as the texture layout if not provided). |
pixelDepth | The depth of the input data (considered the same as the texture layout if not provided). |
_alignment | Byte alignment of the input data. |
void HdlTexture::setMagFilter | ( | GLenum | mf | ) |
Sets the texture's magnification parameter. WARNING : no error checking is performed within this function.
mf | The new magnification filter (e.g. GL_NEAREST or GL_LINEAR, only these two options are accepted). |
void HdlTexture::setMinFilter | ( | GLenum | mf | ) |
Sets the texture's minification parameter. WARNING : no error checking is performed within this function.
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 HdlTexture::setSetting | ( | GLenum | param, |
unsigned int | value | ||
) |
Set parameter, this function will raise an Exception if any errors occur.
param | The GL name of the paramater to set. |
value | The value to assign to the parameter. |
Available paramaters :
Parameter | Description |
---|---|
GL_TEXTURE_MIN_FILTER | Set the minification parameter (same as HdlTexture::setMinFilter()). |
GL_TEXTURE_MAG_FILTER | Set the magnification parameter (same as HdlTexture::setMagFilter()). |
GL_TEXTURE_WRAP_S | Set the S wrapping parameter (same as HdlTexture::setSWrapping()). |
GL_TEXTURE_WRAP_T | Set the T wrapping parameter (same as HdlTexture::setTWrapping()). |
void HdlTexture::setSWrapping | ( | GLenum | m | ) |
Sets the texture's S wrapping parameter. WARNING : no error checking is performed within this function.
m | The new S wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT) |
void HdlTexture::setTWrapping | ( | GLenum | m | ) |
Sets the texture's T wrapping parameter. WARNING : no error checking is performed within this function.
m | The new T wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT) |
|
static |
Unbind a unit from any texture.
unit | The target unit. |
|
static |
Unbind a unit from any texture.
unit | The target unit. |
void HdlTexture::write | ( | GLvoid * | texData, |
GLenum | pixelFormat = GL_ZERO , |
||
GLenum | pixelDepth = GL_ZERO , |
||
int | _alignment = -1 |
||
) |
Write data to a texture using classical glTexImage method. In the case that the texture is compressed and the input data is not of the compressed format, you MUST specify pixelFormat and pixelDepth. WARNING : this function does not perform error checking.
texData | The pointer to the data. |
pixelFormat | The pixel format of the input data (considered the same as the texture layout if not provided). |
pixelDepth | The depth of the input data (considered the same as the texture layout if not provided). |
_alignment | Byte alignment of the input data. |
void HdlTexture::writeCompressed | ( | GLvoid * | texData, |
int | size, | ||
GLenum | pixelFormat = GL_ZERO , |
||
GLenum | pixelDepth = GL_ZERO , |
||
int | _alignment = -1 |
||
) |
Write compressed data to a texture using glCompressedTexImage2D method.
texData | The pointer to the data. |
size | The size in bytes of the data. |
pixelFormat | The pixel format of the input data (considered the same as the texture layout if not provided). |
pixelDepth | The depth of the input data (considered the same as the texture layout if not provided). |
_alignment | Byte alignment of the input data. |