mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
make_texture() is a useful function to publish
This commit is contained in:
parent
3414a4ff1c
commit
4ebdf7b6fa
@ -338,3 +338,16 @@ INLINE const Filename &TexturePool::
|
|||||||
get_fake_texture_image() {
|
get_fake_texture_image() {
|
||||||
return get_global_ptr()->_fake_texture_image;
|
return get_global_ptr()->_fake_texture_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePool::make_texture
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: 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().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(Texture) TexturePool::
|
||||||
|
make_texture(const string &extension) {
|
||||||
|
return get_global_ptr()->ns_make_texture(extension);
|
||||||
|
}
|
||||||
|
@ -110,26 +110,6 @@ get_texture_type(const string &extension) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: TexturePool::make_texture
|
|
||||||
// Access: Public
|
|
||||||
// Description: 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().
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
PT(Texture) TexturePool::
|
|
||||||
make_texture(const string &extension) const {
|
|
||||||
MakeTextureFunc *func = get_texture_type(extension);
|
|
||||||
if (func != NULL) {
|
|
||||||
return func();
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't know what kind of file type this is; return an ordinary
|
|
||||||
// Texture in case it's an image file with no extension.
|
|
||||||
return new Texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::write_texture_types
|
// Function: TexturePool::write_texture_types
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -299,7 +279,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Read it the conventional way.
|
// Read it the conventional way.
|
||||||
tex = make_texture(ext);
|
tex = ns_make_texture(ext);
|
||||||
if (!tex->read(filename, Filename(), primary_file_num_channels, 0,
|
if (!tex->read(filename, Filename(), primary_file_num_channels, 0,
|
||||||
0, 0, false, read_mipmaps, record, options)) {
|
0, 0, false, read_mipmaps, record, options)) {
|
||||||
// This texture was not found or could not be read.
|
// This texture was not found or could not be read.
|
||||||
@ -430,7 +410,7 @@ ns_load_texture(const Filename &orig_filename,
|
|||||||
gobj_cat.info()
|
gobj_cat.info()
|
||||||
<< "Loading texture " << filename << " and alpha component "
|
<< "Loading texture " << filename << " and alpha component "
|
||||||
<< alpha_filename << endl;
|
<< alpha_filename << endl;
|
||||||
tex = make_texture(filename.get_extension());
|
tex = ns_make_texture(filename.get_extension());
|
||||||
if (!tex->read(filename, alpha_filename, primary_file_num_channels,
|
if (!tex->read(filename, alpha_filename, primary_file_num_channels,
|
||||||
alpha_file_channel, 0, 0, false, read_mipmaps, NULL,
|
alpha_file_channel, 0, 0, false, read_mipmaps, NULL,
|
||||||
options)) {
|
options)) {
|
||||||
@ -550,7 +530,7 @@ ns_load_3d_texture(const Filename &filename_pattern,
|
|||||||
// cache; it needs to be loaded from its source image(s).
|
// cache; it needs to be loaded from its source image(s).
|
||||||
gobj_cat.info()
|
gobj_cat.info()
|
||||||
<< "Loading 3-d texture " << filename << "\n";
|
<< "Loading 3-d texture " << filename << "\n";
|
||||||
tex = make_texture(filename.get_extension());
|
tex = ns_make_texture(filename.get_extension());
|
||||||
tex->setup_3d_texture();
|
tex->setup_3d_texture();
|
||||||
if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) {
|
if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) {
|
||||||
// This texture was not found or could not be read.
|
// This texture was not found or could not be read.
|
||||||
@ -656,7 +636,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern,
|
|||||||
// cache; it needs to be loaded from its source image(s).
|
// cache; it needs to be loaded from its source image(s).
|
||||||
gobj_cat.info()
|
gobj_cat.info()
|
||||||
<< "Loading 2-d texture array " << filename << "\n";
|
<< "Loading 2-d texture array " << filename << "\n";
|
||||||
tex = make_texture(filename.get_extension());
|
tex = ns_make_texture(filename.get_extension());
|
||||||
tex->setup_2d_texture_array();
|
tex->setup_2d_texture_array();
|
||||||
if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) {
|
if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) {
|
||||||
// This texture was not found or could not be read.
|
// This texture was not found or could not be read.
|
||||||
@ -757,7 +737,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps,
|
|||||||
// cache; it needs to be loaded from its source image(s).
|
// cache; it needs to be loaded from its source image(s).
|
||||||
gobj_cat.info()
|
gobj_cat.info()
|
||||||
<< "Loading cube map texture " << filename << "\n";
|
<< "Loading cube map texture " << filename << "\n";
|
||||||
tex = make_texture(filename.get_extension());
|
tex = ns_make_texture(filename.get_extension());
|
||||||
tex->setup_cube_map();
|
tex->setup_cube_map();
|
||||||
if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) {
|
if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) {
|
||||||
// This texture was not found or could not be read.
|
// This texture was not found or could not be read.
|
||||||
@ -1044,6 +1024,26 @@ ns_find_all_textures(const string &name) const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePool::ns_make_texture
|
||||||
|
// Access: Public
|
||||||
|
// Description: 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().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(Texture) TexturePool::
|
||||||
|
ns_make_texture(const string &extension) const {
|
||||||
|
MakeTextureFunc *func = get_texture_type(extension);
|
||||||
|
if (func != NULL) {
|
||||||
|
return func();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't know what kind of file type this is; return an ordinary
|
||||||
|
// Texture in case it's an image file with no extension.
|
||||||
|
return new Texture;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::resolve_filename
|
// Function: TexturePool::resolve_filename
|
||||||
// Access: Private
|
// Access: Private
|
||||||
|
@ -81,6 +81,7 @@ PUBLISHED:
|
|||||||
INLINE static void clear_fake_texture_image();
|
INLINE static void clear_fake_texture_image();
|
||||||
INLINE static bool has_fake_texture_image();
|
INLINE static bool has_fake_texture_image();
|
||||||
INLINE static const Filename &get_fake_texture_image();
|
INLINE static const Filename &get_fake_texture_image();
|
||||||
|
INLINE static PT(Texture) make_texture(const string &extension);
|
||||||
|
|
||||||
static void write(ostream &out);
|
static void write(ostream &out);
|
||||||
|
|
||||||
@ -90,7 +91,6 @@ public:
|
|||||||
void register_filter(TexturePoolFilter *filter);
|
void register_filter(TexturePoolFilter *filter);
|
||||||
|
|
||||||
MakeTextureFunc *get_texture_type(const string &extension) const;
|
MakeTextureFunc *get_texture_type(const string &extension) const;
|
||||||
PT(Texture) make_texture(const string &extension) const;
|
|
||||||
void write_texture_types(ostream &out, int indent_level) const;
|
void write_texture_types(ostream &out, int indent_level) const;
|
||||||
|
|
||||||
static TexturePool *get_global_ptr();
|
static TexturePool *get_global_ptr();
|
||||||
@ -128,6 +128,7 @@ private:
|
|||||||
void ns_list_contents(ostream &out) const;
|
void ns_list_contents(ostream &out) const;
|
||||||
Texture *ns_find_texture(const string &name) const;
|
Texture *ns_find_texture(const string &name) const;
|
||||||
TextureCollection ns_find_all_textures(const string &name) const;
|
TextureCollection ns_find_all_textures(const string &name) const;
|
||||||
|
PT(Texture) ns_make_texture(const string &extension) const;
|
||||||
|
|
||||||
void resolve_filename(Filename &new_filename, const Filename &orig_filename);
|
void resolve_filename(Filename &new_filename, const Filename &orig_filename);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user