mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add Texture::ensure_loader_type() to fix problem with reloading video textures from the model-cache directory.
This commit is contained in:
parent
fccd9965ee
commit
fee446f949
@ -2675,6 +2675,28 @@ adjust_size(int &x_size, int &y_size, const string &name,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Texture::ensure_loader_type
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: May be called prior to calling read_txo() or any
|
||||||
|
// bam-related Texture-creating callback, to ensure that
|
||||||
|
// the proper dynamic libraries for a Texture of the
|
||||||
|
// current class type, and the indicated filename, have
|
||||||
|
// been already loaded.
|
||||||
|
//
|
||||||
|
// This is a low-level function that should not normally
|
||||||
|
// need to be called directly by the user.
|
||||||
|
//
|
||||||
|
// Note that for best results you must first create a
|
||||||
|
// Texture object of the appropriate class type for your
|
||||||
|
// filename, for instance with
|
||||||
|
// TexturePool::make_texture().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void Texture::
|
||||||
|
ensure_loader_type(const Filename &filename) {
|
||||||
|
// For a plain Texture type, this doesn't need to do anything.
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Texture::reconsider_dirty
|
// Function: Texture::reconsider_dirty
|
||||||
// Access: Protected, Virtual
|
// Access: Protected, Virtual
|
||||||
|
@ -520,6 +520,8 @@ public:
|
|||||||
INLINE bool adjust_this_size(int &x_size, int &y_size, const string &name,
|
INLINE bool adjust_this_size(int &x_size, int &y_size, const string &name,
|
||||||
bool for_padding) const;
|
bool for_padding) const;
|
||||||
|
|
||||||
|
virtual void ensure_loader_type(const Filename &filename);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class CData;
|
class CData;
|
||||||
|
|
||||||
|
@ -1090,6 +1090,17 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename,
|
|||||||
// The texture was not supplied by a texture filter. See if it
|
// The texture was not supplied by a texture filter. See if it
|
||||||
// can be found in the on-disk cache, if it is active.
|
// can be found in the on-disk cache, if it is active.
|
||||||
if ((cache->get_cache_textures() || cache->get_cache_compressed_textures()) && !textures_header_only) {
|
if ((cache->get_cache_textures() || cache->get_cache_compressed_textures()) && !textures_header_only) {
|
||||||
|
|
||||||
|
// Call ns_make_texture() on the file extension and create a
|
||||||
|
// dummy texture object we can call ensure_loaded_type() on. We
|
||||||
|
// don't need to keep this object around after this call, since
|
||||||
|
// we'll be creating a new one below. I know this is a bit
|
||||||
|
// hacky.
|
||||||
|
string ext = downcase(filename.get_extension());
|
||||||
|
PT(Texture) dummy = ns_make_texture(ext);
|
||||||
|
dummy->ensure_loader_type(filename);
|
||||||
|
dummy.clear();
|
||||||
|
|
||||||
record = cache->lookup(filename, "txo");
|
record = cache->lookup(filename, "txo");
|
||||||
if (record != (BamCacheRecord *)NULL) {
|
if (record != (BamCacheRecord *)NULL) {
|
||||||
if (record->has_data()) {
|
if (record->has_data()) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "movieVideo.h"
|
#include "movieVideo.h"
|
||||||
#include "movieVideoCursor.h"
|
#include "movieVideoCursor.h"
|
||||||
|
#include "movieTypeRegistry.h"
|
||||||
#include "movieTexture.h"
|
#include "movieTexture.h"
|
||||||
#include "clockObject.h"
|
#include "clockObject.h"
|
||||||
#include "config_gobj.h"
|
#include "config_gobj.h"
|
||||||
@ -125,6 +126,32 @@ MovieTexture::
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MovieTexture::ensure_loader_type
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: May be called prior to calling read_txo() or any
|
||||||
|
// bam-related Texture-creating callback, to ensure that
|
||||||
|
// the proper dynamic libraries for a Texture of the
|
||||||
|
// current class type, and the indicated filename, have
|
||||||
|
// been already loaded.
|
||||||
|
//
|
||||||
|
// This is a low-level function that should not normally
|
||||||
|
// need to be called directly by the user.
|
||||||
|
//
|
||||||
|
// Note that for best results you must first create a
|
||||||
|
// Texture object of the appropriate class type for your
|
||||||
|
// filename, for instance with
|
||||||
|
// TexturePool::make_texture().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void MovieTexture::
|
||||||
|
ensure_loader_type(const Filename &filename) {
|
||||||
|
// Creating a MovieVideo of the appropriate type is a slightly hacky
|
||||||
|
// way to ensure the appropriate libraries are loaded. We can let
|
||||||
|
// the MovieVideo we create immediately destruct.
|
||||||
|
MovieTypeRegistry *reg = MovieTypeRegistry::get_global_ptr();
|
||||||
|
PT(MovieVideo) video = reg->make_video(filename);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MovieTexture::make_texture
|
// Function: MovieTexture::make_texture
|
||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
|
@ -64,6 +64,8 @@ PUBLISHED:
|
|||||||
void unsynchronize();
|
void unsynchronize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void ensure_loader_type(const Filename &filename);
|
||||||
|
|
||||||
static PT(Texture) make_texture();
|
static PT(Texture) make_texture();
|
||||||
virtual bool has_cull_callback() const;
|
virtual bool has_cull_callback() const;
|
||||||
virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const;
|
virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user