15 #include "textureCollection.h" 38 _textures(copy._textures)
47 void TextureCollection::
49 _textures = copy._textures;
64 if (_textures.get_ref_count() > 1) {
65 Textures old_textures = _textures;
66 _textures = Textures::empty_array(0);
67 _textures.v() = old_textures.v();
70 _textures.push_back(texture);
82 int texture_index = -1;
83 for (
int i = 0; texture_index == -1 && i < (int)_textures.size(); i++) {
84 if (_textures[i] == texture) {
89 if (texture_index == -1) {
99 if (_textures.get_ref_count() > 1) {
100 Textures old_textures = _textures;
101 _textures = Textures::empty_array(0);
102 _textures.v() = old_textures.v();
105 _textures.erase(_textures.begin() + texture_index);
120 for (
int i = 0; i < other_num_textures; i++) {
134 Textures new_textures;
136 for (
int i = 0; i < num_textures; i++) {
139 new_textures.push_back(texture);
142 _textures = new_textures;
155 Textures new_textures;
158 for (
int i = 0; i < num_textures; i++) {
160 bool duplicated =
false;
162 for (
int j = 0; j < i && !duplicated; j++) {
167 new_textures.push_back(texture);
171 _textures = new_textures;
209 _textures.reserve(num);
222 for (
int i = 0; i < num_textures; i++) {
224 if (texture->get_name() == name) {
238 return _textures.size();
248 nassertr(index >= 0 && index < (
int)_textures.size(), NULL);
250 return _textures[index];
262 nassertr(index >= 0 && index < (
int)_textures.size(), NULL);
264 return _textures[index];
275 return _textures.size();
300 write(ostream &out,
int indent_level)
const {
302 indent(out, indent_level) << *
get_texture(i) <<
"\n";
int size() const
Returns the number of textures in the collection.
Texture * find_texture(const string &name) const
Returns the texture in the collection with the indicated name, if any, or NULL if no texture has that...
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of NodePaths, if you know ahead of time how many you will be adding.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
void output(ostream &out) const
Writes a brief one-line description of the TextureCollection to the indicated output stream...
void add_texture(Texture *texture)
Adds a new Texture to the collection.
Texture * operator[](int index) const
Returns the nth Texture in the collection.
void write(ostream &out, int indent_level=0) const
Writes a complete multi-line description of the TextureCollection to the indicated output stream...
Manages a list of Texture objects, as returned by TexturePool::find_all_textures().
void clear()
Removes all Textures from the collection.
void add_textures_from(const TextureCollection &other)
Adds all the Textures indicated in the other collection to this texture.
int get_num_textures() const
Returns the number of Textures in the collection.
void remove_textures_from(const TextureCollection &other)
Removes from this collection all of the Textures listed in the other collection.
bool remove_texture(Texture *texture)
Removes the indicated Texture from the collection.
void remove_duplicate_textures()
Removes any duplicate entries of the same Textures on this collection.
Texture * get_texture(int index) const
Returns the nth Texture in the collection.
bool has_texture(Texture *texture) const
Returns true if the indicated Texture appears in this collection, false otherwise.