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::HdlTexture Class Reference

Object handle for OpenGL textures. More...

#include <HdlTexture.hpp>

Inheritance diagram for Glip::CoreGL::HdlTexture:
Inheritance graph

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 HdlAbstractTextureFormatformat (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 HdlTextureFormatDescriptorgetFormatDescriptor (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 &copy)
 HdlAbstractTextureFormat Construtor. More...
 
void setAlignment (int _alignment)
 Set the alignment for this format. More...
 

Detailed Description

Object handle for OpenGL textures.

Constructor & Destructor Documentation

HdlTexture::HdlTexture ( const HdlAbstractTextureFormat fmt)

HdlTexture constructor.

Parameters
fmtThe 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.

Parameters
proxyTexIDThe ID of the targeted texture.

Member Function Documentation

void HdlTexture::bind ( GLenum  unit = GL_TEXTURE0_ARB)

Bind the texture to a unit.

Parameters
unitThe target unit.
void HdlTexture::bind ( int  unit)

Bind the texture to a unit.

Parameters
unitThe target unit.
void HdlTexture::fill ( char  dataByte)

Fill a texture will a gray level.

Parameters
dataByteThe 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.

Returns
A constant reference to a HdlAbstractTextureFormat object.
GLuint HdlTexture::getID ( void  ) const

Get the ID of the texture.

Returns
The ID of the OpenGL texture handled by the driver.
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.

Returns
The internal format of the texture.
int HdlTexture::getMaxImageUnits ( void  )
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).

Returns
The maximum number of texture that can be bound at the same time.
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.

Parameters
mThe target mipmap level.
Returns
Returns the size of the texture in bytes.
bool HdlTexture::isProxy ( void  ) const

Test if this texture object is a proxy.

Returns
True if the current 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.

Parameters
dataThe pointer to the data.
pixelFormatThe pixel format of the input data (considered the same as the texture layout if not provided).
pixelDepthThe depth of the input data (considered the same as the texture layout if not provided).
_alignmentByte 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.

Parameters
mfThe 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.

Parameters
mfThe 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.

Parameters
paramThe GL name of the paramater to set.
valueThe 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.

Parameters
mThe 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.

Parameters
mThe new T wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT)
void HdlTexture::unbind ( GLenum  unit = GL_TEXTURE0_ARB)
static

Unbind a unit from any texture.

Parameters
unitThe target unit.
void HdlTexture::unbind ( int  unit)
static

Unbind a unit from any texture.

Parameters
unitThe 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.

Parameters
texDataThe pointer to the data.
pixelFormatThe pixel format of the input data (considered the same as the texture layout if not provided).
pixelDepthThe depth of the input data (considered the same as the texture layout if not provided).
_alignmentByte 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.

Parameters
texDataThe pointer to the data.
sizeThe size in bytes of the data.
pixelFormatThe pixel format of the input data (considered the same as the texture layout if not provided).
pixelDepthThe depth of the input data (considered the same as the texture layout if not provided).
_alignmentByte alignment of the input data.

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