Panda3D
Static Public Member Functions

TexturePool Class Reference

This is the preferred interface for loading textures from image files. More...

List of all members.

Static Public Member Functions

static addTexture (Texture texture)
 Adds the indicated already-loaded texture to the pool.
static clearFakeTextureImage ()
 Restores normal behavior of loading the textures actually requested.
static TextureCollection findAllTextures (string name)
 Returns the set of all textures found in the pool that match the indicated name (which may contain wildcards).
static TextureCollection findAllTextures ()
 Returns the set of all textures found in the pool that match the indicated name (which may contain wildcards).
static Texture findTexture (string name)
 Returns the first texture found in the pool that matches the indicated name (which may contain wildcards).
static int garbageCollect ()
 Releases only those textures in the pool that have a reference count of exactly 1; i.e.
static Texture getAlphaScaleMap ()
 Returns a standard Texture object that has been created with Texture.generate_alpha_scale_map().
static Filename const getFakeTextureImage ()
 Returns the filename that was specified with a previous call to set_fake_texture_image().
static Texture getNormalizationCubeMap (int size)
 Returns a standard Texture object that has been created with Texture.generate_normalization_cube_map().
static bool hasFakeTextureImage ()
 Returns true if fake_texture_image mode has been enabled, false if we are in the normal mode.
static bool hasTexture (Filename const filename)
 Returns true if the texture has ever been loaded, false otherwise.
static listContents ()
 Lists the contents of the texture pool to cout.
static listContents (ostream out)
 Lists the contents of the texture pool to the indicated output stream.
static Texture load3dTexture (Filename const filename_pattern, bool read_mipmaps)
 Loads a 3-D texture that is specified with a series of n pages, all numbered in sequence, and beginning with index 0.
static Texture load3dTexture (Filename const filename_pattern, bool read_mipmaps, LoaderOptions const options)
 Loads a 3-D texture that is specified with a series of n pages, all numbered in sequence, and beginning with index 0.
static Texture load3dTexture (Filename const filename_pattern)
 Loads a 3-D texture that is specified with a series of n pages, all numbered in sequence, and beginning with index 0.
static Texture loadCubeMap (Filename const filename_pattern, bool read_mipmaps)
 Loads a cube map texture that is specified with a series of 6 pages, numbered 0 through 5.
static Texture loadCubeMap (Filename const filename_pattern)
 Loads a cube map texture that is specified with a series of 6 pages, numbered 0 through 5.
static Texture loadCubeMap (Filename const filename_pattern, bool read_mipmaps, LoaderOptions const options)
 Loads a cube map texture that is specified with a series of 6 pages, numbered 0 through 5.
static Texture loadTexture (Filename const filename, Filename const alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, int primary_file_num_channels, bool read_mipmaps, LoaderOptions const options)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, int primary_file_num_channels, bool read_mipmaps)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, Filename const alpha_filename, int primary_file_num_channels, int alpha_file_channel)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, int primary_file_num_channels)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, Filename const alpha_filename, int primary_file_num_channels)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, Filename const alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps, LoaderOptions const options)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static Texture loadTexture (Filename const filename, Filename const alpha_filename)
 Loads the given filename up into a texture, if it has not already been loaded, and returns the new texture.
static rehash ()
 Should be called when the model-path changes, to blow away the cache of texture pathnames found along the model-path.
static releaseAllTextures ()
 Releases all textures in the pool and restores the pool to the empty state.
static releaseTexture (Texture texture)
 Removes the indicated texture from the pool, indicating it will never be loaded again; the texture may then be freed.
static setFakeTextureImage (Filename const filename)
 Sets a bogus filename that will be loaded in lieu of any textures requested from this point on.
static bool verifyTexture (Filename const 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.
static write (ostream out)
 Lists the contents of the texture pool to the indicated output stream.

Detailed 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.


Member Function Documentation

static addTexture ( Texture  texture) [static]

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.

static clearFakeTextureImage ( ) [static]

Restores normal behavior of loading the textures actually requested.

static TextureCollection findAllTextures ( string  name) [static]

Returns the set of all textures found in the pool that match the indicated name (which may contain wildcards).

static TextureCollection findAllTextures ( ) [static]

Returns the set of all textures found in the pool that match the indicated name (which may contain wildcards).

static Texture findTexture ( string  name) [static]

Returns the first texture found in the pool that matches the indicated name (which may contain wildcards).

Returns the texture if it is found, or NULL if it is not.

static int garbageCollect ( ) [static]

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.

static Texture getAlphaScaleMap ( ) [static]

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.

static Filename const getFakeTextureImage ( ) [static]

Returns the filename that was specified with a previous call to set_fake_texture_image().

static Texture getNormalizationCubeMap ( int  size) [static]

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.

static bool hasFakeTextureImage ( ) [static]

Returns true if fake_texture_image mode has been enabled, false if we are in the normal mode.

static bool hasTexture ( Filename const  filename) [static]

Returns true if the texture has ever been loaded, false otherwise.

static listContents ( ) [static]

Lists the contents of the texture pool to cout.

static listContents ( ostream  out) [static]

Lists the contents of the texture pool to the indicated output stream.

static Texture load3dTexture ( Filename const  filename_pattern,
bool  read_mipmaps 
) [static]

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.

static Texture load3dTexture ( Filename const  filename_pattern,
bool  read_mipmaps,
LoaderOptions const  options 
) [static]

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.

static Texture load3dTexture ( Filename const  filename_pattern) [static]

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.

static Texture loadCubeMap ( Filename const  filename_pattern,
bool  read_mipmaps 
) [static]

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.

static Texture loadCubeMap ( Filename const  filename_pattern) [static]

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.

static Texture loadCubeMap ( Filename const  filename_pattern,
bool  read_mipmaps,
LoaderOptions const  options 
) [static]

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.

static Texture loadTexture ( Filename const  filename,
Filename const  alpha_filename,
int  primary_file_num_channels,
int  alpha_file_channel,
bool  read_mipmaps 
) [static]

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, 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.

static Texture loadTexture ( Filename const  filename,
int  primary_file_num_channels,
bool  read_mipmaps,
LoaderOptions const  options 
) [static]

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.

static Texture loadTexture ( Filename const  filename,
int  primary_file_num_channels,
bool  read_mipmaps 
) [static]

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.

static Texture loadTexture ( Filename const  filename,
Filename const  alpha_filename,
int  primary_file_num_channels,
int  alpha_file_channel 
) [static]

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, 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.

static Texture loadTexture ( Filename const  filename,
int  primary_file_num_channels 
) [static]

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.

static Texture loadTexture ( Filename const  filename) [static]

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.

static Texture loadTexture ( Filename const  filename,
Filename const  alpha_filename,
int  primary_file_num_channels 
) [static]

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, 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.

static Texture loadTexture ( Filename const  filename,
Filename const  alpha_filename,
int  primary_file_num_channels,
int  alpha_file_channel,
bool  read_mipmaps,
LoaderOptions const  options 
) [static]

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, 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.

static Texture loadTexture ( Filename const  filename,
Filename const  alpha_filename 
) [static]

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, 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.

static rehash ( ) [static]

Should be called when the model-path changes, to blow away the cache of texture pathnames found along the model-path.

static releaseAllTextures ( ) [static]

Releases all textures in the pool and restores the pool to the empty state.

static releaseTexture ( Texture  texture) [static]

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.

static setFakeTextureImage ( Filename const  filename) [static]

Sets a bogus filename that will be loaded in lieu of any textures requested from this point on.

static bool verifyTexture ( Filename const  filename) [static]

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.

static write ( ostream  out) [static]

Lists the contents of the texture pool to the indicated output stream.

For debugging.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties