mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
automatically reload texture when changing compression mode
This commit is contained in:
parent
b9f19d6663
commit
3f42a08968
@ -306,6 +306,22 @@ store(PNMImage &pnmimage, int z, int n) const {
|
||||
return do_store_one(pnmimage, z, n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::reload
|
||||
// Access: Published
|
||||
// Description: Re-reads the Texture from its disk file. Useful when
|
||||
// you know the image on disk has recently changed, and
|
||||
// you want to update the Texture image.
|
||||
//
|
||||
// Returns true on success, false on failure (in which
|
||||
// case, the Texture may or may not still be valid).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Texture::
|
||||
reload() {
|
||||
MutexHolder holder(_lock);
|
||||
return do_reload();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::has_filename
|
||||
// Access: Published
|
||||
|
@ -720,34 +720,6 @@ read_dds(istream &in, const string &filename, bool header_only) {
|
||||
return do_read_dds(in, filename, header_only);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::reload
|
||||
// Access: Published
|
||||
// Description: Re-reads the Texture from its disk file. Useful when
|
||||
// you know the image on disk has recently changed, and
|
||||
// you want to update the Texture image.
|
||||
//
|
||||
// Returns true on success, false on failure (in which
|
||||
// case, the Texture may or may not still be valid).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Texture::
|
||||
reload() {
|
||||
MutexHolder holder(_lock);
|
||||
if (_loaded_from_image && !_fullpath.empty()) {
|
||||
do_clear_ram_image();
|
||||
do_unlock_and_reload_ram_image(true);
|
||||
if (do_has_ram_image()) {
|
||||
// An explicit call to reload() should increment image_modified.
|
||||
++_image_modified;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't have a filename to load from.
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::load_related
|
||||
// Access: Published
|
||||
@ -4034,6 +4006,9 @@ do_set_compression(Texture::CompressionMode compression) {
|
||||
if (_compression != compression) {
|
||||
++_properties_modified;
|
||||
_compression = compression;
|
||||
if (do_has_ram_image()) {
|
||||
do_reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4550,6 +4525,28 @@ do_set_pad_size(int x, int y, int z) {
|
||||
_pad_z_size = z;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::do_reload
|
||||
// Access: Protected
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Texture::
|
||||
do_reload() {
|
||||
if (_loaded_from_image && !_fullpath.empty()) {
|
||||
do_clear_ram_image();
|
||||
do_unlock_and_reload_ram_image(true);
|
||||
if (do_has_ram_image()) {
|
||||
// An explicit call to reload() should increment image_modified.
|
||||
++_image_modified;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't have a filename to load from.
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::convert_from_pnmimage
|
||||
// Access: Private, Static
|
||||
|
@ -247,7 +247,7 @@ PUBLISHED:
|
||||
INLINE bool store(PNMImage &pnmimage) const;
|
||||
INLINE bool store(PNMImage &pnmimage, int z, int n) const;
|
||||
|
||||
bool reload();
|
||||
INLINE bool reload();
|
||||
Texture *load_related(const InternalName *suffix) const;
|
||||
|
||||
INLINE bool has_filename() const;
|
||||
@ -551,6 +551,7 @@ protected:
|
||||
void do_clear_ram_mipmap_images();
|
||||
void do_generate_ram_mipmap_images();
|
||||
void do_set_pad_size(int x, int y, int z);
|
||||
bool do_reload();
|
||||
|
||||
// This nested class declaration is used below.
|
||||
class RamImage {
|
||||
|
Loading…
x
Reference in New Issue
Block a user