mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
add set_fake_texture_image
This commit is contained in:
parent
1dc36ab4d0
commit
1cbe39e68e
@ -16,9 +16,10 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::has_texture
|
// Function: TexturePool::has_texture
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Returns true if the texture has ever been loaded,
|
// Description: Returns true if the texture has ever been loaded,
|
||||||
// false otherwise.
|
// false otherwise.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -29,7 +30,7 @@ has_texture(const string &filename) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::verify_texture
|
// Function: TexturePool::verify_texture
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Loads the given filename up into a texture, if it has
|
// Description: Loads the given filename up into a texture, if it has
|
||||||
// not already been loaded, and returns true to indicate
|
// not already been loaded, and returns true to indicate
|
||||||
// success, or false to indicate failure. If this
|
// success, or false to indicate failure. If this
|
||||||
@ -44,7 +45,7 @@ verify_texture(const string &filename) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::load_texture
|
// Function: TexturePool::load_texture
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Loads the given filename up into a texture, if it has
|
// Description: Loads the given filename up into a texture, if it has
|
||||||
// not already been loaded, and returns the new texture.
|
// not already been loaded, and returns the new texture.
|
||||||
// If a texture with the same filename was previously
|
// If a texture with the same filename was previously
|
||||||
@ -58,7 +59,7 @@ load_texture(const string &filename, int primary_file_num_channels) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::load_texture
|
// Function: TexturePool::load_texture
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Loads the given filename up into a texture, if it has
|
// Description: Loads the given filename up into a texture, if it has
|
||||||
// not already been loaded, and returns the new texture.
|
// not already been loaded, and returns the new texture.
|
||||||
// If a texture with the same filename was previously
|
// If a texture with the same filename was previously
|
||||||
@ -75,7 +76,7 @@ load_texture(const string &filename, const string &alpha_filename,
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::add_texture
|
// Function: TexturePool::add_texture
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Adds the indicated already-loaded texture to the
|
// Description: Adds the indicated already-loaded texture to the
|
||||||
// pool. The texture must have a filename set for its
|
// pool. The texture must have a filename set for its
|
||||||
// name. The texture will always replace any
|
// name. The texture will always replace any
|
||||||
@ -89,7 +90,7 @@ add_texture(Texture *texture) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::release_texture
|
// Function: TexturePool::release_texture
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Removes the indicated texture from the pool,
|
// Description: Removes the indicated texture from the pool,
|
||||||
// indicating it will never be loaded again; the texture
|
// indicating it will never be loaded again; the texture
|
||||||
// may then be freed. If this function is never called,
|
// may then be freed. If this function is never called,
|
||||||
@ -107,7 +108,7 @@ release_texture(Texture *texture) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::release_all_textures
|
// Function: TexturePool::release_all_textures
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Releases all textures in the pool and restores the
|
// Description: Releases all textures in the pool and restores the
|
||||||
// pool to the empty state.
|
// pool to the empty state.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -118,7 +119,7 @@ release_all_textures() {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::garbage_collect
|
// Function: TexturePool::garbage_collect
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Releases only those textures in the pool that have a
|
// Description: Releases only those textures in the pool that have a
|
||||||
// reference count of exactly 1; i.e. only those
|
// reference count of exactly 1; i.e. only those
|
||||||
// textures that are not being used outside of the pool.
|
// textures that are not being used outside of the pool.
|
||||||
@ -131,7 +132,7 @@ garbage_collect() {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::list_contents
|
// Function: TexturePool::list_contents
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Lists the contents of the texture pool to the
|
// Description: Lists the contents of the texture pool to the
|
||||||
// indicated output stream.
|
// indicated output stream.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -140,6 +141,50 @@ list_contents(ostream &out) {
|
|||||||
get_ptr()->ns_list_contents(out);
|
get_ptr()->ns_list_contents(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePool::set_fake_texture_image
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Sets a bogus filename that will be loaded in lieu of
|
||||||
|
// any textures requested from this point on.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void TexturePool::
|
||||||
|
set_fake_texture_image(const string &filename) {
|
||||||
|
get_ptr()->_fake_texture_image = filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePool::clear_fake_texture_image
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Restores normal behavior of loading the textures
|
||||||
|
// actually requested.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void TexturePool::
|
||||||
|
clear_fake_texture_image() {
|
||||||
|
set_fake_texture_image(string());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePool::has_fake_texture_image
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Returns true if fake_texture_image mode has been
|
||||||
|
// enabled, false if we are in the normal mode.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool TexturePool::
|
||||||
|
has_fake_texture_image() {
|
||||||
|
return !get_fake_texture_image().empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TexturePool::get_fake_texture_image
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Returns the filename that was specified with a
|
||||||
|
// previous call to set_fake_texture_image().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE const string &TexturePool::
|
||||||
|
get_fake_texture_image() {
|
||||||
|
return get_ptr()->_fake_texture_image;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TexturePool::Constructor
|
// Function: TexturePool::Constructor
|
||||||
// Access: Private
|
// Access: Private
|
||||||
@ -149,4 +194,5 @@ list_contents(ostream &out) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE TexturePool::
|
INLINE TexturePool::
|
||||||
TexturePool() {
|
TexturePool() {
|
||||||
|
_fake_texture_image = fake_texture_image;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ bool TexturePool::
|
|||||||
ns_has_texture(const Filename &orig_filename) {
|
ns_has_texture(const Filename &orig_filename) {
|
||||||
Filename filename(orig_filename);
|
Filename filename(orig_filename);
|
||||||
|
|
||||||
if (!fake_texture_image.empty()) {
|
if (!_fake_texture_image.empty()) {
|
||||||
filename = fake_texture_image;
|
filename = _fake_texture_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_vfs) {
|
if (use_vfs) {
|
||||||
@ -68,8 +68,8 @@ Texture *TexturePool::
|
|||||||
ns_load_texture(const Filename &orig_filename, int primary_file_num_channels) {
|
ns_load_texture(const Filename &orig_filename, int primary_file_num_channels) {
|
||||||
Filename filename(orig_filename);
|
Filename filename(orig_filename);
|
||||||
|
|
||||||
if (!fake_texture_image.empty()) {
|
if (!_fake_texture_image.empty()) {
|
||||||
filename = fake_texture_image;
|
filename = _fake_texture_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_vfs) {
|
if (use_vfs) {
|
||||||
@ -119,8 +119,8 @@ ns_load_texture(const Filename &orig_filename,
|
|||||||
Filename filename(orig_filename);
|
Filename filename(orig_filename);
|
||||||
Filename alpha_filename(orig_alpha_filename);
|
Filename alpha_filename(orig_alpha_filename);
|
||||||
|
|
||||||
if (!fake_texture_image.empty()) {
|
if (!_fake_texture_image.empty()) {
|
||||||
return ns_load_texture(fake_texture_image, primary_file_num_channels);
|
return ns_load_texture(_fake_texture_image, primary_file_num_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_vfs) {
|
if (use_vfs) {
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "pandabase.h"
|
#include "pandabase.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "filename.h"
|
#include "filename.h"
|
||||||
|
#include "config_gobj.h"
|
||||||
|
|
||||||
#include "pmap.h"
|
#include "pmap.h"
|
||||||
|
|
||||||
@ -54,6 +55,11 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE static void list_contents(ostream &out);
|
INLINE static void list_contents(ostream &out);
|
||||||
|
|
||||||
|
INLINE static void set_fake_texture_image(const string &filename);
|
||||||
|
INLINE static void clear_fake_texture_image();
|
||||||
|
INLINE static bool has_fake_texture_image();
|
||||||
|
INLINE static const string &get_fake_texture_image();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
INLINE TexturePool();
|
INLINE TexturePool();
|
||||||
|
|
||||||
@ -74,6 +80,7 @@ private:
|
|||||||
static TexturePool *_global_ptr;
|
static TexturePool *_global_ptr;
|
||||||
typedef pmap<string, PT(Texture) > Textures;
|
typedef pmap<string, PT(Texture) > Textures;
|
||||||
Textures _textures;
|
Textures _textures;
|
||||||
|
string _fake_texture_image;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "texturePool.I"
|
#include "texturePool.I"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user