diff options
author | Stijn Buys <ingar@osirion.org> | 2009-01-28 21:02:48 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-01-28 21:02:48 +0000 |
commit | 757a712813a0815fc570784ca15676b90a36326a (patch) | |
tree | 7366760796da3f332dea614c3276d04c76ecdfeb /src/render/textures.cc | |
parent | f681fc3c38348a0af49e09022948a6b87c801ab0 (diff) |
cleanups
Diffstat (limited to 'src/render/textures.cc')
-rw-r--r-- | src/render/textures.cc | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/render/textures.cc b/src/render/textures.cc index 60c82c2..a340814 100644 --- a/src/render/textures.cc +++ b/src/render/textures.cc @@ -74,7 +74,7 @@ void Textures::clear() memset(textures,0, sizeof(textures)); } -void Textures::unload(std::string name) +void Textures::unload(const std::string &name) { iterator it = registry.find(name); if (it != registry.end()) { @@ -82,13 +82,13 @@ void Textures::unload(std::string name) size_t id = (*it).second; if (textures[id]) { glDeleteTextures(1, &textures[id]); + textures[id] = 0; } registry.erase(it); - } } -void Textures::unload(size_t id) +void Textures::unload(const size_t id) { // find in map for (iterator it = registry.begin(); it != registry.end(); it++) { @@ -97,6 +97,7 @@ void Textures::unload(size_t id) size_t id = (*it).second; if (textures[id]) { glDeleteTextures(1, &textures[id]); + textures[id] = 0; } registry.erase(it); break; @@ -104,7 +105,15 @@ void Textures::unload(size_t id) } } -size_t Textures::load(std::string name, bool filter) +size_t Textures::load(const char *name, const bool filter) +{ + if (name) + return load(std::string(name), filter); + else + return 0; +} + +size_t Textures::load(const std::string &name, const bool filter) { // check if it is already loaded iterator it = registry.find(name); @@ -176,7 +185,7 @@ size_t Textures::load(std::string name, bool filter) return id; } -size_t Textures::find(std::string name) +size_t Textures::find(const std::string &name) { size_t id = 0; iterator it = registry.find(name); @@ -185,7 +194,15 @@ size_t Textures::find(std::string name) return id; } -size_t Textures::bind(std::string name, bool filter) +size_t Textures::bind(const char *name, const bool filter) +{ + if (name) + return bind(std::string(name), filter); + else + return 0; +} + +size_t Textures::bind(const std::string &name, const bool filter) { size_t id = 0; iterator it = registry.find(name); @@ -199,7 +216,7 @@ size_t Textures::bind(std::string name, bool filter) return id; } -size_t Textures::bind(size_t texture, bool filter) +size_t Textures::bind(const size_t texture, const bool filter) { size_t id = texture; if (!textures[id]) @@ -210,7 +227,7 @@ size_t Textures::bind(size_t texture, bool filter) return id; } -void Textures::set_filter(bool filter) +void Textures::set_filter(const bool filter) { if (filter) { glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); |