TexturePool

from panda3d.core import TexturePool
class TexturePool

Bases: DTOOL_SUPER_BASE

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 diagram

Inheritance diagram of TexturePool

__init__(*args, **kwargs)
addTexture()

C++ Interface: add_texture(Texture texture)

/**
  • 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.

*/

add_texture()

C++ Interface: add_texture(Texture texture)

/**
  • 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()

C++ Interface: clear_fake_texture_image()

/**
  • Restores normal behavior of loading the textures actually requested.

*/

clearFilters()

C++ Interface: clear_filters()

/**
  • Stops all TexturePoolFilter objects from operating on this pool.

*/

clear_fake_texture_image()

C++ Interface: clear_fake_texture_image()

/**
  • Restores normal behavior of loading the textures actually requested.

*/

clear_filters()

C++ Interface: clear_filters()

/**
  • Stops all TexturePoolFilter objects from operating on this pool.

*/

filters
findAllTextures()

C++ Interface: find_all_textures(str name)

/**
  • Returns the set of all textures found in the pool that match the indicated

  • name (which may contain wildcards).

*/

findTexture()

C++ Interface: find_texture(str name)

/**
  • 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.

*/

find_all_textures()

C++ Interface: find_all_textures(str name)

/**
  • Returns the set of all textures found in the pool that match the indicated

  • name (which may contain wildcards).

*/

find_texture()

C++ Interface: find_texture(str name)

/**
  • 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.

*/

garbageCollect()

C++ Interface: 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.

*/

garbage_collect()

C++ Interface: 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.

*/

getAlphaScaleMap()

C++ Interface: get_alpha_scale_map()

/**
  • 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()

C++ Interface: get_fake_texture_image()

/**
  • Returns the filename that was specified with a previous call to

  • set_fake_texture_image().

*/

getFilter()

C++ Interface: get_filter(TexturePool self, int i)

/**
  • Returns the nth texture pool filter registered.

*/

getGlobalPtr()

C++ Interface: get_global_ptr()

/**
  • Initializes and/or returns the global pointer to the one TexturePool object

  • in the system.

*/

getNormalizationCubeMap()

C++ Interface: get_normalization_cube_map(int size)

/**
  • 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.

*/

getNumFilters()

C++ Interface: get_num_filters(TexturePool self)

/**
  • Returns the total number of registered texture pool filters.

*/

getTexture()

C++ Interface: get_texture(const Filename filename) get_texture(const Filename filename, const Filename alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps) get_texture(const Filename filename, int primary_file_num_channels, bool read_mipmaps)

/**
  • Returns the texture that has already been previously loaded, or NULL

  • otherwise.

*/

/**
  • Returns the texture that has already been previously loaded, or NULL

  • otherwise.

*/

get_alpha_scale_map()

C++ Interface: get_alpha_scale_map()

/**
  • 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.

*/

get_fake_texture_image()

C++ Interface: get_fake_texture_image()

/**
  • Returns the filename that was specified with a previous call to

  • set_fake_texture_image().

*/

get_filter()

C++ Interface: get_filter(TexturePool self, int i)

/**
  • Returns the nth texture pool filter registered.

*/

get_global_ptr()

C++ Interface: get_global_ptr()

/**
  • Initializes and/or returns the global pointer to the one TexturePool object

  • in the system.

*/

get_normalization_cube_map()

C++ Interface: get_normalization_cube_map(int size)

/**
  • 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.

*/

get_num_filters()

C++ Interface: get_num_filters(TexturePool self)

/**
  • Returns the total number of registered texture pool filters.

*/

get_texture()

C++ Interface: get_texture(const Filename filename) get_texture(const Filename filename, const Filename alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps) get_texture(const Filename filename, int primary_file_num_channels, bool read_mipmaps)

/**
  • Returns the texture that has already been previously loaded, or NULL

  • otherwise.

*/

/**
  • Returns the texture that has already been previously loaded, or NULL

  • otherwise.

*/

hasFakeTextureImage()

C++ Interface: has_fake_texture_image()

/**
  • Returns true if fake_texture_image mode has been enabled, false if we are

  • in the normal mode.

*/

hasTexture()

C++ Interface: has_texture(const Filename filename)

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

*/

has_fake_texture_image()

C++ Interface: has_fake_texture_image()

/**
  • Returns true if fake_texture_image mode has been enabled, false if we are

  • in the normal mode.

*/

has_texture()

C++ Interface: has_texture(const Filename filename)

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

*/

isFilterRegistered()

C++ Interface: is_filter_registered(const TexturePool self, object tex_filter) is_filter_registered(TexturePoolFilter tex_filter)

/**
  • Checks whether the given TexturePoolFilter object is

  • currently registered in the texture pool or not.

*/

is_filter_registered()

C++ Interface: is_filter_registered(const TexturePool self, object tex_filter) is_filter_registered(TexturePoolFilter tex_filter)

/**
  • Checks whether the given TexturePoolFilter object is

  • currently registered in the texture pool or not.

*/

listContents()

C++ Interface: list_contents() list_contents(ostream out)

/**
  • Lists the contents of the texture pool to the indicated output stream.

*/

/**
  • Lists the contents of the texture pool to cout

*/

list_contents()

C++ Interface: list_contents() list_contents(ostream out)

/**
  • Lists the contents of the texture pool to the indicated output stream.

*/

/**
  • Lists the contents of the texture pool to cout

*/

load2dTextureArray()

C++ Interface: load_2d_texture_array(const Filename filename_pattern, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • Loads a 2-D texture array 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 2-d level.

*/

load3dTexture()

C++ Interface: load_3d_texture(const Filename filename_pattern, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • 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()

C++ Interface: load_cube_map(const Filename filename_pattern, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • 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()

C++ Interface: load_texture(const Filename filename) load_texture(const Filename filename, const Filename alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler) load_texture(const Filename filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • 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.

*/

/**
  • 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.

*/

load_2d_texture_array()

C++ Interface: load_2d_texture_array(const Filename filename_pattern, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • Loads a 2-D texture array 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 2-d level.

*/

load_3d_texture()

C++ Interface: load_3d_texture(const Filename filename_pattern, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • 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.

*/

load_cube_map()

C++ Interface: load_cube_map(const Filename filename_pattern, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • 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.

*/

load_texture()

C++ Interface: load_texture(const Filename filename) load_texture(const Filename filename, const Filename alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler) load_texture(const Filename filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions options, const SamplerState sampler)

/**
  • 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.

*/

/**
  • 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.

*/

makeTexture()

C++ Interface: make_texture(str extension)

/**
  • Creates a new Texture object of the appropriate type for the indicated

  • filename extension, according to the types that have been registered via

  • register_texture_type().

*/

make_texture()

C++ Interface: make_texture(str extension)

/**
  • Creates a new Texture object of the appropriate type for the indicated

  • filename extension, according to the types that have been registered via

  • register_texture_type().

*/

registerFilter()

C++ Interface: register_filter(const TexturePool self, object tex_filter) register_filter(TexturePoolFilter tex_filter)

/**
  • Records a TexturePoolFilter object that may operate on texture images as

  • they are loaded from disk.

*/

register_filter()

C++ Interface: register_filter(const TexturePool self, object tex_filter) register_filter(TexturePoolFilter tex_filter)

/**
  • Records a TexturePoolFilter object that may operate on texture images as

  • they are loaded from disk.

*/

rehash()

C++ Interface: rehash()

/**
  • Should be called when the model-path changes, to blow away the cache of

  • texture pathnames found along the model-path.

*/

releaseAllTextures()

C++ Interface: release_all_textures()

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

*/

releaseTexture()

C++ Interface: release_texture(Texture texture)

/**
  • 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.

*/

release_all_textures()

C++ Interface: release_all_textures()

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

*/

release_texture()

C++ Interface: release_texture(Texture texture)

/**
  • 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()

C++ Interface: set_fake_texture_image(const Filename filename)

/**
  • Sets a bogus filename that will be loaded in lieu of any textures requested

  • from this point on.

*/

set_fake_texture_image()

C++ Interface: set_fake_texture_image(const Filename filename)

/**
  • Sets a bogus filename that will be loaded in lieu of any textures requested

  • from this point on.

*/

unregisterFilter()

C++ Interface: unregister_filter(const TexturePool self, object tex_filter) unregister_filter(TexturePoolFilter tex_filter)

/**
  • Stops a TexturePoolFilter object from operating on this pool.

*/

unregister_filter()

C++ Interface: unregister_filter(const TexturePool self, object tex_filter) unregister_filter(TexturePoolFilter tex_filter)

/**
  • Stops a TexturePoolFilter object from operating on this pool.

*/

verifyTexture()

C++ Interface: verify_texture(const Filename 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.

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

*/

verify_texture()

C++ Interface: verify_texture(const Filename 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.

  • 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()

C++ Interface: write(ostream out)

/**
  • Lists the contents of the texture pool to the indicated output stream. For

  • debugging.

*/