more fixes for preload-textures + model-cache-dir

This commit is contained in:
David Rose
2007-06-04 13:42:25 +00:00
parent 36dfcf2437
commit 8196d44822
5 changed files with 21 additions and 11 deletions
+2 -1
View File
@@ -18,9 +18,10 @@
#include "dcast.h"
GeomMunger *CLP(GeomMunger)::_deleted_chain = NULL;
TypeHandle CLP(GeomMunger)::_type_handle;
ALLOC_DELETED_CHAIN_DEF(CLP(GeomMunger));
////////////////////////////////////////////////////////////////////
// Function: CLP(GeomMunger)::Constructor
// Access: Public
+1 -3
View File
@@ -37,7 +37,7 @@ class EXPCL_GL CLP(GeomMunger) : public StandardMunger, public WeakPointerCallba
public:
CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state);
virtual ~CLP(GeomMunger)();
ALLOC_DELETED_CHAIN(CLP(GeomMunger));
ALLOC_DELETED_CHAIN_DECL(CLP(GeomMunger));
virtual void wp_callback(void *);
@@ -62,8 +62,6 @@ private:
};
int _flags;
static GeomMunger *_deleted_chain;
public:
static TypeHandle get_class_type() {
return _type_handle;
@@ -6610,7 +6610,6 @@ apply_texture(TextureContext *tc) {
gtc->mark_loaded();
}
report_my_gl_errors();
}
@@ -6626,6 +6625,7 @@ apply_texture(TextureContext *tc) {
bool CLP(GraphicsStateGuardian)::
upload_texture(CLP(TextureContext) *gtc) {
Texture *tex = gtc->get_texture();
CPTA_uchar image = tex->get_ram_image();
Texture::CompressionMode image_compression;
@@ -6912,6 +6912,9 @@ upload_texture_image(CLP(TextureContext) *gtc,
// We need to reload a new image.
if (num_ram_mipmap_levels == 0) {
GLCAT.info()
<< "Synthesizing blank image for " << tex->get_name()
<< "\n";
int *blank_image = new int[width * height];
int color = 0xFF808080;
switch (z) {
@@ -6930,14 +6933,15 @@ upload_texture_image(CLP(TextureContext) *gtc,
}
for (int n = mipmap_bias; n < num_ram_mipmap_levels; ++n) {
const unsigned char *image_ptr = tex->get_ram_mipmap_image(n);
if (image_ptr == (const unsigned char *)NULL) {
CPTA_uchar ptimage = tex->get_ram_mipmap_image(n);
if (ptimage == (const unsigned char *)NULL) {
GLCAT.warning()
<< "No mipmap level " << n << " defined for " << tex->get_name()
<< "\n";
// No mipmap level n; stop here.
break;
}
const unsigned char *image_ptr = ptimage;
size_t image_size = tex->get_ram_mipmap_image_size(n);
if (one_page_only) {
@@ -7220,7 +7224,7 @@ check_nonresident_texture(BufferContextChain &chain) {
}
nassertv(ti == num_textures);
GLboolean *results = (GLboolean *)alloca(num_textures * sizeof(GLboolean));
bool all_resident = (glAreTexturesResident(num_textures, texture_list, results) != 0);
bool all_resident = (GLP(AreTexturesResident)(num_textures, texture_list, results) != 0);
report_my_gl_errors();
+9 -3
View File
@@ -2392,9 +2392,15 @@ reload_ram_image() {
gobj_cat.info()
<< "Texture " << get_name() << " reloaded from disk cache.\n";
PT(Texture) tex = DCAST(Texture, record->extract_data());
bool keep_ram_image = _keep_ram_image;
(*this) = (*tex);
_keep_ram_image = keep_ram_image;
// We don't want to replace all the texture parameters--for
// instance, we don't want to change the filter type or the
// border color or anything--we just want to get the image and
// necessary associated parameters.
reconsider_image_properties(tex->get_x_size(), tex->get_y_size(),
tex->get_num_components(),
tex->get_component_type(), 0);
set_compression(tex->get_compression());
_ram_images = tex->_ram_images;
return;
}
}
+1
View File
@@ -332,6 +332,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels,
if (store_record) {
// Store the on-disk cache record for next time.
nassertr(tex->has_ram_image(), tex);
record->set_data(tex, false);
cache->store(record);