add textures-header-only

This commit is contained in:
David Rose
2005-11-02 18:57:30 +00:00
parent b8da3c6c32
commit 74a1ebca02
3 changed files with 68 additions and 13 deletions

View File

@@ -188,6 +188,14 @@ ConfigVariableEnum<AutoTextureScale> textures_square
"a square aspect ratio when they are loaded from disk. Set this "
"to 'none', 'down', or 'up'. See textures-power-2."));
extern EXPCL_PANDA ConfigVariableBool textures_header_only;
ConfigVariableBool textures_header_only
("textures-header-only", false,
PRC_DESC("If this is true, texture images will not actually be loaded from "
"disk, but the image header information will be consulted to verify "
"number of channels and so forth. The texture images themselves "
"will be generated in a default blue color."));
ConfigVariableInt geom_cache_size
("geom-cache-size", 5000,
PRC_DESC("Specifies the maximum number of entries in the cache "

View File

@@ -61,6 +61,7 @@ extern EXPCL_PANDA ConfigVariableBool connect_triangle_strips;
extern EXPCL_PANDA ConfigVariableEnum<BamTextureMode> bam_texture_mode;
extern EXPCL_PANDA ConfigVariableEnum<AutoTextureScale> textures_power_2;
extern EXPCL_PANDA ConfigVariableEnum<AutoTextureScale> textures_square;
extern EXPCL_PANDA ConfigVariableBool textures_header_only;
extern EXPCL_PANDA ConfigVariableInt geom_cache_size;
extern EXPCL_PANDA ConfigVariableInt geom_cache_min_frames;

View File

@@ -288,10 +288,25 @@ bool Texture::
read(const Filename &fullpath, int z, int primary_file_num_channels) {
PNMImage image;
if (!image.read(fullpath, NULL, false)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << fullpath << endl;
return false;
if (textures_header_only) {
if (!image.read_header(fullpath)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << fullpath << endl;
return false;
}
image = PNMImage(1, 1, image.get_num_channels(), image.get_maxval(),
image.get_type());
image.fill(0.2, 0.3, 1.0);
if (image.has_alpha()) {
image.alpha_fill(1.0);
}
} else {
if (!image.read(fullpath, NULL, false)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << fullpath << endl;
return false;
}
}
if (!has_name()) {
@@ -327,19 +342,50 @@ bool Texture::
read(const Filename &fullpath, const Filename &alpha_fullpath,
int z, int primary_file_num_channels, int alpha_file_channel) {
PNMImage image;
if (!image.read(fullpath, NULL, false)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << fullpath << endl;
return false;
if (textures_header_only) {
if (!image.read_header(fullpath)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << fullpath << endl;
return false;
}
image = PNMImage(1, 1, image.get_num_channels(), image.get_maxval(),
image.get_type());
image.fill(0.2, 0.3, 1.0);
if (image.has_alpha()) {
image.alpha_fill(1.0);
}
} else {
if (!image.read(fullpath, NULL, false)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << fullpath << endl;
return false;
}
}
PNMImage alpha_image;
if (!alpha_image.read(alpha_fullpath, NULL, true)) {
gobj_cat.error()
<< "Texture::read() - couldn't read (alpha): " << alpha_fullpath << endl;
return false;
}
if (textures_header_only) {
if (!alpha_image.read_header(alpha_fullpath)) {
gobj_cat.error()
<< "Texture::read() - couldn't read: " << alpha_fullpath << endl;
return false;
}
alpha_image = PNMImage(1, 1, alpha_image.get_num_channels(),
alpha_image.get_maxval(),
alpha_image.get_type());
alpha_image.fill(1.0);
if (alpha_image.has_alpha()) {
alpha_image.alpha_fill(1.0);
}
} else {
if (!alpha_image.read(alpha_fullpath, NULL, true)) {
gobj_cat.error()
<< "Texture::read() - couldn't read (alpha): " << alpha_fullpath << endl;
return false;
}
}
if (!has_name()) {
set_name(fullpath.get_basename_wo_extension());
}