add BTM_unchanged

This commit is contained in:
David Rose 2003-02-20 01:18:27 +00:00
parent 182a528a18
commit 12e9117087
5 changed files with 36 additions and 14 deletions

View File

@ -31,8 +31,8 @@
#include "lens.h" #include "lens.h"
#include "texture.h" #include "texture.h"
#include <dconfig.h> #include "dconfig.h"
#include <string_utils.h> #include "string_utils.h"
Configure(config_gobj); Configure(config_gobj);
NotifyCategoryDef(gobj, ""); NotifyCategoryDef(gobj, "");
@ -125,15 +125,17 @@ const float default_far = config_gobj.GetFloat("default-far", 1000.0f);
static BamTextureMode static BamTextureMode
parse_texture_mode(const string &mode) { parse_texture_mode(const string &mode) {
if (mode == "fullpath") { if (cmp_nocase(mode, "unchanged") == 0) {
return BTM_unchanged;
} else if (cmp_nocase(mode, "fullpath") == 0) {
return BTM_fullpath; return BTM_fullpath;
} else if (mode == "relative") { } else if (cmp_nocase(mode, "relative") == 0) {
return BTM_relative; return BTM_relative;
} else if (mode == "basename") { } else if (cmp_nocase(mode, "basename") == 0) {
return BTM_basename; return BTM_basename;
} }
gobj_cat.error() << "Invalid bam-texture-mode: " << mode << "\n"; gobj_cat->error() << "Invalid bam-texture-mode: " << mode << "\n";
return BTM_relative; return BTM_relative;
} }

View File

@ -19,8 +19,8 @@
#ifndef CONFIG_GOBJ_H #ifndef CONFIG_GOBJ_H
#define CONFIG_GOBJ_H #define CONFIG_GOBJ_H
#include <pandabase.h> #include "pandabase.h"
#include <notifyCategoryProxy.h> #include "notifyCategoryProxy.h"
NotifyCategoryDecl(gobj, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(gobj, EXPCL_PANDA, EXPTP_PANDA);
@ -35,6 +35,7 @@ extern EXPCL_PANDA bool keep_geom_ram;
extern EXPCL_PANDA bool retained_mode; extern EXPCL_PANDA bool retained_mode;
enum BamTextureMode { enum BamTextureMode {
BTM_unchanged,
BTM_fullpath, BTM_fullpath,
BTM_relative, BTM_relative,
BTM_basename BTM_basename

View File

@ -47,6 +47,7 @@ write_datagram(BamWriter *, Datagram &me)
Filename alpha_filename = get_alpha_filename(); Filename alpha_filename = get_alpha_filename();
switch (bam_texture_mode) { switch (bam_texture_mode) {
case BTM_unchanged:
case BTM_fullpath: case BTM_fullpath:
break; break;

View File

@ -32,7 +32,9 @@ TexturePool *TexturePool::_global_ptr = (TexturePool *)NULL;
// Description: The nonstatic implementation of has_texture(). // Description: The nonstatic implementation of has_texture().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool TexturePool:: bool TexturePool::
ns_has_texture(Filename filename) { ns_has_texture(const 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;
} }
@ -63,7 +65,9 @@ ns_has_texture(Filename filename) {
// Description: The nonstatic implementation of load_texture(). // Description: The nonstatic implementation of load_texture().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
Texture *TexturePool:: Texture *TexturePool::
ns_load_texture(Filename filename) { ns_load_texture(const 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;
} }
@ -94,6 +98,10 @@ ns_load_texture(Filename filename) {
return NULL; return NULL;
} }
if (bam_texture_mode == BTM_unchanged) {
tex->set_filename(orig_filename);
}
_textures[filename] = tex; _textures[filename] = tex;
return tex; return tex;
} }
@ -104,7 +112,11 @@ ns_load_texture(Filename filename) {
// Description: The nonstatic implementation of load_texture(). // Description: The nonstatic implementation of load_texture().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
Texture *TexturePool:: Texture *TexturePool::
ns_load_texture(Filename filename, Filename grayfilename) { ns_load_texture(const Filename &orig_filename,
const Filename &orig_grayfilename) {
Filename filename(orig_filename);
Filename grayfilename(orig_grayfilename);
if (!fake_texture_image.empty()) { if (!fake_texture_image.empty()) {
return ns_load_texture(fake_texture_image); return ns_load_texture(fake_texture_image);
} }
@ -142,6 +154,11 @@ ns_load_texture(Filename filename, Filename grayfilename) {
return NULL; return NULL;
} }
if (bam_texture_mode == BTM_unchanged) {
tex->set_filename(orig_filename);
tex->set_alpha_filename(orig_grayfilename);
}
_textures[filename] = tex; _textures[filename] = tex;
return tex; return tex;
} }

View File

@ -56,9 +56,10 @@ PUBLISHED:
private: private:
INLINE TexturePool(); INLINE TexturePool();
bool ns_has_texture(Filename filename); bool ns_has_texture(const Filename &orig_filename);
Texture *ns_load_texture(Filename filename); Texture *ns_load_texture(const Filename &orig_filename);
Texture *ns_load_texture(Filename filename, Filename grayfilename); Texture *ns_load_texture(const Filename &orig_filename,
const Filename &orig_grayfilename);
void ns_add_texture(Texture *texture); void ns_add_texture(Texture *texture);
void ns_release_texture(Texture *texture); void ns_release_texture(Texture *texture);
void ns_release_all_textures(); void ns_release_all_textures();