37class EXPCL_PANDA_GOBJ TexturePool {
42 int primary_file_num_channels = 0,
43 bool read_mipmaps =
false);
46 int primary_file_num_channels = 0,
47 int alpha_file_channel = 0,
48 bool read_mipmaps =
false);
50 int primary_file_num_channels = 0,
51 bool read_mipmaps =
false,
55 int primary_file_num_channels = 0,
56 int alpha_file_channel = 0,
57 bool read_mipmaps =
false,
60 bool read_mipmaps =
false,
63 bool read_mipmaps =
false,
66 bool read_mipmaps =
false,
75 INLINE
static void rehash();
89 INLINE
static PT(
Texture) make_texture(
const std::string &extension);
91 static void write(std::ostream &out);
94 typedef Texture::MakeTextureFunc MakeTextureFunc;
106 bool ns_has_texture(
const Filename &orig_filename);
108 int primary_file_num_channels = 0,
109 bool read_mipmaps =
false);
112 int primary_file_num_channels = 0,
113 int alpha_file_channel = 0,
114 bool read_mipmaps =
false);
116 int primary_file_num_channels,
120 const Filename &orig_alpha_filename,
121 int primary_file_num_channels,
122 int alpha_file_channel,
134 Texture *ns_get_normalization_cube_map(
int size);
135 Texture *ns_get_alpha_scale_map();
137 void ns_add_texture(
Texture *texture);
138 void ns_release_texture(
Texture *texture);
139 void ns_release_all_textures();
140 int ns_garbage_collect();
141 void ns_list_contents(std::ostream &out)
const;
142 Texture *ns_find_texture(
const std::string &name)
const;
144 PT(
Texture) ns_make_texture(
const std::string &extension)
const;
146 void resolve_filename(
Filename &new_filename,
const Filename &orig_filename,
151 bool &compressed_cache_record,
153 void report_texture_unreadable(
const Filename &filename)
const;
157 const Filename &orig_alpha_filename,
158 int primary_file_num_channels,
159 int alpha_file_channel,
165 static TexturePool *_global_ptr;
171 int _primary_file_num_channels = 0;
172 int _alpha_file_channel = 0;
173 Texture::TextureType _texture_type = Texture::TT_2d_texture;
175 INLINE
bool operator < (
const LookupKey &other)
const;
177 typedef pmap<LookupKey, PT(
Texture)> Textures;
179 typedef pmap<Filename, Filename> RelpathLookup;
180 RelpathLookup _relpath_lookup;
184 PT(
Texture) _normalization_cube_map;
187 typedef pmap<std::string, MakeTextureFunc *> TypeRegistry;
188 TypeRegistry _type_registry;
190 typedef pvector<TexturePoolFilter *> FilterRegistry;
191 FilterRegistry _filter_registry;
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This class maintains a cache of Bam and/or Txo objects generated from model files and texture images ...
The name of a file, such as a texture file or an Egg file.
Specifies parameters that may be passed to the loader.
A standard mutex, or mutual exclusion lock.
Manages a list of Texture objects, as returned by TexturePool::find_all_textures().
This is an abstract base class, a placeholder for any number of different classes that may wish to im...
static Texture * load_texture(const Filename &filename, int primary_file_num_channels=0, bool read_mipmaps=false, const LoaderOptions &options=LoaderOptions())
Loads the given filename up into a texture, if it has not already been loaded, and returns the new te...
static int garbage_collect()
Releases only those textures in the pool that have a reference count of exactly 1; i....
static void list_contents(std::ostream &out)
Lists the contents of the texture pool to the indicated output stream.
static void release_all_textures()
Releases all textures in the pool and restores the pool to the empty state.
static bool has_fake_texture_image()
Returns true if fake_texture_image mode has been enabled, false if we are in the normal mode.
static TexturePool * get_global_ptr()
Initializes and/or returns the global pointer to the one TexturePool object in the system.
static Texture * get_texture(const Filename &filename, int primary_file_num_channels=0, bool read_mipmaps=false)
Returns the texture that has already been previously loaded, or NULL otherwise.
static Texture * load_2d_texture_array(const Filename &filename_pattern, bool read_mipmaps=false, const LoaderOptions &options=LoaderOptions())
Loads a 2-D texture array that is specified with a series of n pages, all numbered in sequence,...
static bool has_texture(const Filename &filename)
Returns true if the texture has ever been loaded, false otherwise.
static void 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.
void register_texture_type(MakeTextureFunc *func, const std::string &extensions)
Records a factory function that makes a Texture object of the appropriate type for one or more partic...
static bool verify_texture(const Filename &filename)
Loads the given filename up into a texture, if it has not already been loaded, and returns true to in...
static void add_texture(Texture *texture)
Adds the indicated already-loaded texture to the pool.
void register_filter(TexturePoolFilter *filter)
Records a TexturePoolFilter object that may operate on texture images as they are loaded from disk.
static void clear_fake_texture_image()
Restores normal behavior of loading the textures actually requested.
static Texture * load_cube_map(const Filename &filename_pattern, bool read_mipmaps=false, const LoaderOptions &options=LoaderOptions())
Loads a cube map texture that is specified with a series of 6 pages, numbered 0 through 5.
static Texture * get_normalization_cube_map(int size)
Returns a standard Texture object that has been created with Texture::generate_normalization_cube_map...
static const Filename & get_fake_texture_image()
Returns the filename that was specified with a previous call to set_fake_texture_image().
void write_texture_types(std::ostream &out, int indent_level) const
Outputs a list of the available texture types to the indicated output stream.
static Texture * get_alpha_scale_map()
Returns a standard Texture object that has been created with Texture::generate_alpha_scale_map().
static void rehash()
Should be called when the model-path changes, to blow away the cache of texture pathnames found along...
static Texture * find_texture(const std::string &name)
Returns the first texture found in the pool that matches the indicated name (which may contain wildca...
static static PT(Texture) make_texture(const std void write(std::ostream &out)
Lists the contents of the texture pool to the indicated output stream.
static TextureCollection find_all_textures(const std::string &name="*")
Returns the set of all textures found in the pool that match the indicated name (which may contain wi...
static void release_texture(Texture *texture)
Removes the indicated texture from the pool, indicating it will never be loaded again; the texture ma...
static Texture * load_3d_texture(const Filename &filename_pattern, bool read_mipmaps=false, const LoaderOptions &options=LoaderOptions())
Loads a 3-D texture that is specified with a series of n pages, all numbered in sequence,...
MakeTextureFunc * get_texture_type(const std::string &extension) const
Returns the factory function to construct a new texture of the type appropriate for the indicated fil...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.