#include <texturemanager.h>
Inherits UniversalManager< Texture, TextureManager >.
Inheritance diagram for TextureManager:


Public Member Functions | |
| TRef | add (SurfaceFactory *psf, GLint internalFormat=GL_RGBA, GLint level=0) |
| Registers the texture using arbitrary SurfaceFactory. | |
| TRef | add (std::string fileName, GLint internalFormat=GL_RGBA, GLint level=0) |
| Registers the texture using default factory with the file name only. | |
| bool | getNPOT (void) |
| Non-power-of-two textures extension presence. | |
Protected Member Functions | |
| TextureManager () | |
| ~TextureManager () | |
Private Attributes | |
| bool | mNPOT |
| true for NPOT textures extension presence, false otherwise | |
Friends | |
| class | Singleton< TextureManager > |
| due to singleton DP | |
This is a singleton. It provides several add(...) methods to the user. You describe texture source in arguments of add() and you will get the reference TRef, with that you can access the Texture class. If there is not any texture managed matching given description, it will be created and uploaded to OpenGL. Otherwise only the reference to managed item found, is returned.
Example:
// Loads the file "image.png" with an external alpha channel describet as red channel od "image_alpha.png" // (i.e. some grayscale image), builds 2D mipmaps and returns texture reference to it: TextureRef tr1 = TextureManager::getInstance()->add( &SurfExternalAlpha("image.png", "image_alpha.png"), GL_RGBA, Texture::BUILD_MIPMAPS); // Finds the texture in the registry and returns only a reference to it // (GL_RGBA and BUILD_MIPMAPS is ignored when image found in registry): TextureRef tr2 = TextureManager::getInstance()->add( &SurfExternalAlpha("image.png", "image_alpha.png"), GL_RGBA, Texture::BUILD_MIPMAPS); // Increments the reference count only.. TextureRef tr3 = tr1; // Now, tr1, tr2, tr3 refers to only one texture. // ... // binds the texture to current texture unit t2->bind(); // Loads image2.png with an explicit color key (0x00, 0x00, 0x00): tr1 = TextureManager::getInstance()->add( &SurfColorKey("image2.png", 0x00, 0x00, 0x00)); // SDL_Surface * customSurfacePtr = getSomeSurface(); // Loads the texture from custom surface with explicit color key and prefix its name with "surface1" tr2 = TextureManager::getInstance()->add( &SurfColorKey(customSurfacePtr, 0x00, 0x00, 0x00).pref("surface1")); // release last reference to the first texture "image.png" tr3 = 0; // the first texture is now released...
OpenGL has to be initialized before registering any texture!
Definition at line 163 of file texturemanager.h.
|
|
Definition at line 23 of file texturemanager.cpp. References GFX::checkExtension(), getAppClient(), ApplicationClient::getGFX(), and mNPOT. Here is the call graph for this function: ![]() |
|
|
Definition at line 168 of file texturemanager.h. |
|
||||||||||||||||
|
Registers the texture using default factory with the file name only.
Definition at line 44 of file texturemanager.cpp. References add(). Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Registers the texture using arbitrary SurfaceFactory.
If this texture (described by
Definition at line 28 of file texturemanager.cpp. References UniversalManager< Texture, TextureManager >::createAndRegister(), UniversalManager< Texture, TextureManager >::find(), SurfaceFactory::getHashString(), and Texture::upload(). Referenced by add(). Here is the call graph for this function: ![]() |
|
|
Non-power-of-two textures extension presence.
Definition at line 196 of file texturemanager.h. References mNPOT. |
|
|
due to singleton DP
Definition at line 165 of file texturemanager.h. |
|
|
true for NPOT textures extension presence, false otherwise
Definition at line 199 of file texturemanager.h. Referenced by getNPOT(), and TextureManager(). |
1.4.5