#include <texturePool.h>
Static Public Member Functions | |
bool | has_texture (const string &filename) |
Returns true if the texture has ever been loaded, false otherwise. | |
bool | verify_texture (const string &filename) |
Loads the given filename up into a texture, if it has not already been loaded, and returns true to indicate success, or false to indicate failure. | |
Texture * | load_texture (const string &filename, int primary_file_num_channels=0) |
Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture. | |
Texture * | load_texture (const string &filename, const string &alpha_filename, int primary_file_num_channels=0, int alpha_file_channel=0) |
Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture. | |
void | add_texture (Texture *texture) |
Adds the indicated already-loaded texture to the pool. | |
void | release_texture (Texture *texture) |
Removes the indicated texture from the pool, indicating it will never be loaded again; the texture may then be freed. | |
void | release_all_textures () |
Releases all textures in the pool and restores the pool to the empty state. | |
int | garbage_collect () |
Releases only those textures in the pool that have a reference count of exactly 1; i.e. | |
void | list_contents (ostream &out) |
Lists the contents of the texture pool to the indicated output stream. | |
Private Types | |
typedef pmap< string, PointerTo< Texture > > | Textures |
Private Member Functions | |
TexturePool () | |
The constructor is not intended to be called directly; there's only supposed to be one TexturePool in the universe and it constructs itself. | |
bool | ns_has_texture (const Filename &orig_filename) |
The nonstatic implementation of has_texture(). | |
Texture * | ns_load_texture (const Filename &orig_filename, int primary_file_num_channels) |
The nonstatic implementation of load_texture(). | |
Texture * | ns_load_texture (const Filename &orig_filename, const Filename &orig_alpha_filename, int primary_file_num_channels, int alpha_file_channel) |
The nonstatic implementation of load_texture(). | |
void | ns_add_texture (Texture *texture) |
The nonstatic implementation of add_texture(). | |
void | ns_release_texture (Texture *texture) |
The nonstatic implementation of release_texture(). | |
void | ns_release_all_textures () |
The nonstatic implementation of release_all_textures(). | |
int | ns_garbage_collect () |
The nonstatic implementation of garbage_collect(). | |
void | ns_list_contents (ostream &out) |
The nonstatic implementation of list_contents(). | |
Static Private Member Functions | |
TexturePool * | get_ptr () |
Initializes and/or returns the global pointer to the one TexturePool object in the system. | |
Private Attributes | |
Textures | _textures |
Static Private Attributes | |
TexturePool * | _global_ptr = (TexturePool *)NULL |
It unifies all references to the same filename, so that multiple models that reference the same textures don't waste texture memory unnecessarily.
Definition at line 46 of file texturePool.h.
|
Definition at line 85 of file texturePool.h. |
|
The constructor is not intended to be called directly; there's only supposed to be one TexturePool in the universe and it constructs itself.
Definition at line 217 of file texturePool.I. |
|
Adds the indicated already-loaded texture to the pool. The texture must have a filename set for its name. The texture will always replace any previously-loaded texture in the pool that had the same filename. Definition at line 122 of file texturePool.I. References get_ptr(), INLINE, and ns_garbage_collect(). |
|
Releases only those textures in the pool that have a reference count of exactly 1; i.e. only those textures that are not being used outside of the pool. Returns the number of textures released. Definition at line 185 of file texturePool.I. |
|
Initializes and/or returns the global pointer to the one TexturePool object in the system.
Definition at line 292 of file texturePool.cxx. Referenced by add_texture(), and load_texture(). |
|
Returns true if the texture has ever been loaded, false otherwise.
Definition at line 33 of file texturePool.I. References INLINE, load_texture(), and NULL. |
|
Lists the contents of the texture pool to the indicated output stream.
Definition at line 200 of file texturePool.I. |
|
Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture. If a texture with the same filename was previously loaded, returns that one instead. If the texture file cannot be found, returns NULL. Definition at line 98 of file texturePool.I. References get_ptr(), INLINE, and ns_release_texture(). |
|
Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture. If a texture with the same filename was previously loaded, returns that one instead. If the texture file cannot be found, returns NULL. Definition at line 77 of file texturePool.I. References get_ptr(), INLINE, and ns_add_texture(). Referenced by demo_keys(), event_L(), and has_texture(). |
|
The nonstatic implementation of add_texture().
Definition at line 189 of file texturePool.cxx. References _textures, PointerToArray< PointerTo< Texture > >::end(), PointerToArray< PointerTo< Texture > >::erase(), ImageBuffer::get_filename(), and tex. Referenced by load_texture(). |
|
The nonstatic implementation of garbage_collect().
Definition at line 239 of file texturePool.cxx. References Texture::_pbuffer, _textures, PointerToArray< PointerTo< Texture > >::begin(), PointerToArray< PointerTo< Texture > >::end(), ReferenceCount::get_ref_count(), and PointerToArray< PointerTo< Texture > >::size(). Referenced by add_texture(). |
|
The nonstatic implementation of has_texture().
Definition at line 41 of file texturePool.cxx. References VirtualFileSystem::get_global_ptr(), get_model_path(), get_texture_path(), and VirtualFileSystem::resolve_filename(). |
|
The nonstatic implementation of list_contents().
Definition at line 270 of file texturePool.cxx. |
|
The nonstatic implementation of load_texture().
Definition at line 127 of file texturePool.cxx. |
|
The nonstatic implementation of load_texture().
Definition at line 77 of file texturePool.cxx. |
|
The nonstatic implementation of release_all_textures().
Definition at line 226 of file texturePool.cxx. |
|
The nonstatic implementation of release_texture().
Definition at line 208 of file texturePool.cxx. References _textures, PointerToArray< PointerTo< Texture > >::begin(), PointerToArray< PointerTo< Texture > >::end(), ReferenceCount::get_ref_count(), and tex. Referenced by load_texture(). |
|
Releases all textures in the pool and restores the pool to the empty state.
Definition at line 166 of file texturePool.I. |
|
Removes the indicated texture from the pool, indicating it will never be loaded again; the texture may then be freed. If this function is never called, a reference count will be maintained on every texture every loaded, and textures will never be freed. The texture's name should not have been changed during its lifetime, or this function may fail to locate it in the pool. Definition at line 151 of file texturePool.I. |
|
Loads the given filename up into a texture, if it has not already been loaded, and returns true to indicate success, or false to indicate failure. If this returns true, it is guaranteed that a subsequent call to load_texture() with the same texture name will return a valid Texture pointer. Definition at line 56 of file texturePool.I. |
|
Definition at line 29 of file texturePool.cxx. |
|
Definition at line 86 of file texturePool.h. Referenced by ns_add_texture(), ns_garbage_collect(), and ns_release_texture(). |