# TexturePool

from pandac.PandaModules import TexturePool

Class : TexturePool
Description : This is the preferred interface for loading textures from image files. It unifies all references to the same filename, so that multiple models that reference the same textures don't waste texture memory unnecessarily.

## Inheritance:

TexturePool:

## Methods of TexturePool:

addTexture
clearFakeTextureImage
garbageCollect
getAlphaScaleMap
getFakeTextureImage
getNormalizationCubeMap
hasFakeTextureImage
hasTexture
listContents
load3dTexture
loadCubeMap
loadTexture
releaseAllTextures
releaseTexture
setFakeTextureImage
verifyTexture
write

addTexture static void TexturePool::add_texture(Texture *texture); Description: 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.

clearFakeTextureImage static void TexturePool::clear_fake_texture_image(void); Description: Restores normal behavior of loading the textures actually requested.

garbageCollect static int TexturePool::garbage_collect(void); Description: 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.

getAlphaScaleMap static Texture *TexturePool::get_alpha_scale_map(void); Description: Returns a standard Texture object that has been created with Texture::generate_alpha_scale_map(). This Texture object is used internally by Panda to apply an alpha scale to an object (instead of munging its vertices) when gsg->get_alpha_scale_via_texture() returns true.

getFakeTextureImage static string const &TexturePool::get_fake_texture_image(void); Description: Returns the filename that was specified with a previous call to set_fake_texture_image().

getNormalizationCubeMap static Texture *TexturePool::get_normalization_cube_map(int size); Description: Returns a standard Texture object that has been created with Texture::generate_normalization_cube_map(). This Texture may be shared by any application code requiring a normalization cube map. It will be at least as large as the specified size, though it may be larger.

hasFakeTextureImage static bool TexturePool::has_fake_texture_image(void); Description: Returns true if fake_texture_image mode has been enabled, false if we are in the normal mode.

hasTexture static bool TexturePool::has_texture(string const &filename); These functions take string parameters instead of Filenames because that's somewhat more convenient to the scripting language. Filename: texturePool.I Created by: drose (26Apr00) PANDA 3D SOFTWARE Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved All use of this software is subject to the terms of the Panda 3d Software license. You should have received a copy of this license along with this source code; you will also find a current copy of the license at http://etc.cmu.edu/panda3d/docs/license/ . To contact the maintainers of this program write to panda3d-general@lists.sourceforge.net . Description: Returns true if the texture has ever been loaded, false otherwise.

listContents static void TexturePool::list_contents(ostream &out); Description: Lists the contents of the texture pool to the indicated output stream. Description: Lists the contents of the texture pool to cout

load3dTexture static Texture *TexturePool::load_3d_texture(string const &filename_pattern, bool read_mipmaps = (0)); Description: Loads a 3-D texture that is specified with a series of n pages, all numbered in sequence, and beginning with index 0. The filename should include a sequence of one or more hash characters ("#") which will be filled in with the index number of each level. If read_mipmaps is true, the filename should contain an additional hash mark. The first hash mark will be filled in with the mipmap level number, and the second with the index number of each 3-d level.

loadCubeMap static Texture *TexturePool::load_cube_map(string const &filename_pattern, bool read_mipmaps = (0)); Description: Loads a cube map texture that is specified with a series of 6 pages, numbered 0 through 5. The filename should include a sequence of one or more hash characters ("#") which will be filled in with the index number of each pagee. If read_mipmaps is true, the filename should contain an additional hash mark. The first hash mark will be filled in with the mipmap level number, and the second with the face number, 0 through 5.

loadTexture static Texture *TexturePool::load_texture(string const &filename, int primary_file_num_channels = (0), bool read_mipmaps = (0)); Description: 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. If read_mipmaps is true, the filename should contain a hash mark ('#'), which will be filled in with the mipmap level number; and the texture will be defined with a series of images, one for each mipmap level. If read_mipmaps is true, both filenames should contain a hash mark ('#'), which will be filled in with the mipmap level number; and the texture will be defined with a series of images, two for each mipmap level.

releaseAllTextures static void TexturePool::release_all_textures(void); Description: Releases all textures in the pool and restores the pool to the empty state.

releaseTexture static void TexturePool::release_texture(Texture *texture); Description: 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.

setFakeTextureImage static void TexturePool::set_fake_texture_image(string const &filename); Description: Sets a bogus filename that will be loaded in lieu of any textures requested from this point on.

verifyTexture static bool TexturePool::verify_texture(string const &filename); These functions take string parameters instead of Filenames because that's somewhat more convenient to the scripting language. Description: 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.

write static void TexturePool::write(ostream &out); Description: Lists the contents of the texture pool to the indicated output stream. For debugging.