BambooIsland: TextureManager Class Reference

BambooIsland Abgabe 2

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# TextureManager Class Reference

A class for loading textures and manage the use of the texture units. More...

`#include <TextureManager.h>`

List of all members.

## Public Member Functions

| ~TextureManager ()
| Destructor.
bool | loadTexture (std::string sTextureName, std::string sFilename, bool bAlreadyGammaCorrected)
| Method for loading a texture from file.
GLuint | useTexture (std::string sTextureName)
| Method to use an already loaded texture.
void | unuseTexture (std::string sTextureName)
| Method to unuse a texture.
GLuint | getFreeUnit ()
| Returns the ID of a free unit and marks it as used.
void | releaseUnit (GLuint nUnit)
| Marks a given texture unit as free.
void | registerManualTexture (std::string sTextureName, GLuint nTextureID)
| Registers an initialized opengl-texture in TextureManager to use it with TextureManager::useTexture()

## Static Public Member Functions

static TextureManager * | instance ()
| Returns the singelton instance.

## Detailed Description

A class for loading textures and manage the use of the texture units.

This class provides methods for loading textures from image files, and for binding/unbinding textures to a free texture unit, where the caller must not think about the use of the texture units.

Definition at line 28 of file TextureManager.h.

## Member Function Documentation

GLuint TextureManager::getFreeUnit | ( |  | ) |

Returns the ID of a free unit and marks it as used.

This method returns the ID of the first free unit and marks it as used.

Normally, this method is used internally by useTexture()

If you use this method on your own, you must release the unit as soon as possible with TextureManager::releaseUnit().

Returns:
  The ID of a free texture unit.

See also:
  TextureManager::releaseUnit(), TextureManager::useTexture()

Definition at line 185 of file TextureManager.cpp.

bool TextureManager::loadTexture | ( | std::string | sTextureName,
|  | std::string | sFilename,
|  | bool | bAlreadyGammaCorrected
| ) |  |

Method for loading a texture from file.

This method loads a texture from a file, creates a new opengl-texture and makes it accessable over the given name

Parameters:

  sTextureName | The wanted name to make the texture accessable, must be unique
  sFilename | The filename (relative to workdir) of the file which should be load
  bAlreadyGammaCorrected | Specify if the image which should be loaded is already gamma-corrected or not

See also:
  TextureManager::useTexture(), TextureManager::unuseTexture()

Definition at line 20 of file TextureManager.cpp.

void TextureManager::registerManualTexture | ( | std::string | sTextureName,
|  | GLuint | nTextureID
| ) |  |

Registers an initialized opengl-texture in TextureManager to use it with TextureManager::useTexture()

This method registers an initialized (and ready for use) opengl-texture in the internal structures of the TextureManager-class, to make it available through TextureManager::useTexture(...) calls

This method can be used if you create your textures on your own instead of using TextureManager::loadTexture()

Parameters:

  sTextureName | The wanted name to make the texture accessable, must be unique
  nTextureID | The opengl name of the texture (=the texture ID)

See also:
  TextureManager::useTexture(), TextureManager::loadTexture()

Definition at line 202 of file TextureManager.cpp.

void TextureManager::releaseUnit | ( | GLuint | nUnit | ) |

Marks a given texture unit as free.

This method marks the given texture unit as free

Normally, this method is used internally by unuseTexture()

Parameters:

  nUnit | The id of the texture unit

See also:
  TextureManager::getFreeUnit(), TextureManager::unuseTexture()

Definition at line 197 of file TextureManager.cpp.

void TextureManager::unuseTexture | ( | std::string | sTextureName | ) |

Method to unuse a texture.

This method marks the texture unit which is currently used for this texture as free. The texture unit is not cleared, but each call of useTexture(...) may allocate the unit again and bind another texture to this unit. Therefore, to use a texture again, you have to call TextureManager::useTexture() again.

In case that the given texture is not bound to any unit and you call unuseTexture(...), the method will print an error message.

Parameters:

  sTextureName | The name of the texture

See also:
  TextureManager::loadTexture(), TextureManager::useTexture()

Definition at line 165 of file TextureManager.cpp.

GLuint TextureManager::useTexture | ( | std::string | sTextureName | ) |

Method to use an already loaded texture.

This method binds an already loaded texture to a free texture unit, marks the unit as used and returns the ID of the unit. In case that there is no free texture unit, the method sends a fatal-message to the logger which forces the program to quit.

To ensure that there are always enough free texture units, you must call TextureManager::unuseTexture(...) as soon as possible for you.

Parameters:

  sTextureName | The name of the texture

Returns:
  The ID of the used texture unit

See also:
  TextureManager::loadTexture(), TextureManager::unuseTexture()

Definition at line 109 of file TextureManager.cpp.

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

- C:/Users/easterbunny/Desktop/Echtzeitgraphik-LU/trunk/src/TextureManager.h
- C:/Users/easterbunny/Desktop/Echtzeitgraphik-LU/trunk/src/TextureManager.cpp

All Classes Functions Variables Enumerations Enumerator