Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::TextureManager Class Reference

Singleton class that manages texture unit allocation. More...

#include <texturemanager.hpp>

Public Member Functions

void bindTexture (GLenum texType, GLuint texID, int texture_unit)
 Binds a texture to a unit given by the user. More...
 
int bindTexture (GLenum texType, GLuint texID)
 Binds a texture to the first free texture unit and returns the allocated unit. More...
 
int getAvailableUnit (void)
 Returns the first available texture unit. More...
 
void setUnavailableUnit (int unit)
 Sets one unit as unavaiable. in case something besides the texture manager has bound a texture to it. More...
 
void unbindTexture (GLenum texType, int texture_unit)
 Unbinds the texture from the specific texture unit. More...
 
void unbindTextureID (GLenum texType, GLuint texID)
 Unbinds a texture with given ID Searches texture unit vector for the texture and frees unit. More...
 
 ~TextureManager ()
 

Static Public Member Functions

static TextureManagerInstance (void)
 Returns the unique instance. If no instace exists, it will create one (only once). More...
 

Private Member Functions

 TextureManager ()
 Default Constructor. More...
 
 TextureManager (TextureManager const &)
 Copy Constructor. More...
 
TextureManageroperator= (TextureManager const &)
 Assignment Operation. More...
 

Private Attributes

int max_texture_units
 Maximum number of texture units. More...
 
std::vector< int > used_units
 Texture units in use. each slot holds the texture id or -1 if free. More...
 

Static Private Attributes

static TextureManagerpInstance
 Pointer to the instance of the Texture Manager object. More...
 

Detailed Description

Singleton class that manages texture unit allocation.

When a texture is binded, this singleton will search for the first free slot to allocate it. This removes the burden of managing texture units inside the program.

Constructor & Destructor Documentation

Tucano::TextureManager::~TextureManager ( )
inline
Tucano::TextureManager::TextureManager ( )
inlineprivate

Default Constructor.

Tucano::TextureManager::TextureManager ( TextureManager const &  )
inlineprivate

Copy Constructor.

Member Function Documentation

void Tucano::TextureManager::bindTexture ( GLenum  texType,
GLuint  texID,
int  texture_unit 
)
inline

Binds a texture to a unit given by the user.

int Tucano::TextureManager::bindTexture ( GLenum  texType,
GLuint  texID 
)
inline

Binds a texture to the first free texture unit and returns the allocated unit.

Returns
Allocated unit, or -1 if no free unit is available.
int Tucano::TextureManager::getAvailableUnit ( void  )
inline

Returns the first available texture unit.

static TextureManager& Tucano::TextureManager::Instance ( void  )
inlinestatic

Returns the unique instance. If no instace exists, it will create one (only once).

TextureManager& Tucano::TextureManager::operator= ( TextureManager const &  )
private

Assignment Operation.

void Tucano::TextureManager::setUnavailableUnit ( int  unit)

Sets one unit as unavaiable. in case something besides the texture manager has bound a texture to it.

void Tucano::TextureManager::unbindTexture ( GLenum  texType,
int  texture_unit 
)
inline

Unbinds the texture from the specific texture unit.

void Tucano::TextureManager::unbindTextureID ( GLenum  texType,
GLuint  texID 
)
inline

Unbinds a texture with given ID Searches texture unit vector for the texture and frees unit.

Parameters
texTypeTexture type
texIDThe ID handler to given texture

Member Data Documentation

int Tucano::TextureManager::max_texture_units
private

Maximum number of texture units.

TextureManager* Tucano::TextureManager::pInstance
staticprivate

Pointer to the instance of the Texture Manager object.

std::vector<int> Tucano::TextureManager::used_units
private

Texture units in use. each slot holds the texture id or -1 if free.


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