32 get_global_ptr()->ns_list_contents(out);
43 (
"texture-stage-pool-mode", M_none,
44 PRC_DESC(
"Defines the initial value of TextureStagePool::set_mode(). " 45 "Set this to 'none' to disable the use of the TextureStagePool, " 46 "to 'name' to group TextureStages by name only, or 'unique' " 47 "to group together only identical TextureStages."));
48 _mode = texture_stage_pool_mode.get_value();
64 StagesByName::iterator ni = _stages_by_name.find(temp->
get_name());
65 if (ni == _stages_by_name.end()) {
66 ni = _stages_by_name.insert(StagesByName::value_type(temp->
get_name(), temp)).first;
68 if ((*ni).first != (*ni).second->get_name()) {
79 StagesByProperties::iterator si = _stages_by_properties.find(cpttemp);
80 if (si == _stages_by_properties.end()) {
81 si = _stages_by_properties.insert(StagesByProperties::value_type(
new TextureStage(*temp), temp)).first;
83 if (*(*si).first != *(*si).second) {
99 void TextureStagePool::
108 _stages_by_name.erase(temp->
get_name());
114 _stages_by_properties.erase(cpttemp);
123 void TextureStagePool::
124 ns_release_all_stages() {
127 _stages_by_name.clear();
128 _stages_by_properties.clear();
134 void TextureStagePool::
135 ns_set_mode(TextureStagePool::Mode mode) {
139 _stages_by_name.clear();
140 _stages_by_properties.clear();
148 TextureStagePool::Mode TextureStagePool::
158 int TextureStagePool::
159 ns_garbage_collect() {
168 int num_released = 0;
169 StagesByName new_set;
171 StagesByName::iterator ni;
172 for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) {
173 const string &name = (*ni).first;
176 if (gobj_cat.is_debug()) {
178 <<
"Releasing " << name <<
"\n";
182 new_set.insert(new_set.end(), *ni);
186 _stages_by_name.swap(new_set);
192 int num_released = 0;
193 StagesByProperties new_set;
195 StagesByProperties::iterator si;
196 for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) {
200 if (gobj_cat.is_debug()) {
202 <<
"Releasing " << *ts1 <<
"\n";
206 new_set.insert(new_set.end(), *si);
210 _stages_by_properties.swap(new_set);
221 void TextureStagePool::
222 ns_list_contents(ostream &out)
const {
225 out <<
"TextureStagePool in mode " << _mode <<
"\n";
233 out << _stages_by_name.size() <<
" TextureStages:\n";
234 StagesByName::const_iterator ni;
235 for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) {
236 const string &name = (*ni).first;
246 out << _stages_by_properties.size() <<
" TextureStages:\n";
247 StagesByProperties::const_iterator si;
248 for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) {
265 if (_global_ptr ==
nullptr) {
275 operator << (ostream &out, TextureStagePool::Mode mode) {
277 case TextureStagePool::M_none:
278 return out <<
"none";
280 case TextureStagePool::M_name:
281 return out <<
"name";
283 case TextureStagePool::M_unique:
284 return out <<
"unique";
287 return out <<
"**invalid mode (" << (int)mode <<
")**";
294 operator >> (istream &in, TextureStagePool::Mode &mode) {
298 if (cmp_nocase(word,
"none") == 0) {
299 mode = TextureStagePool::M_none;
300 }
else if (cmp_nocase(word,
"name") == 0) {
301 mode = TextureStagePool::M_name;
302 }
else if (cmp_nocase(word,
"unique") == 0) {
303 mode = TextureStagePool::M_unique;
306 gobj_cat->error() <<
"Invalid TextureStagePool mode value: " << word <<
"\n";
307 mode = TextureStagePool::M_none;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_ref_count
Returns the current reference count.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_name
Returns the name of this texture stage.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The TextureStagePool (there is only one in the universe) serves to unify different pointers to the sa...
This class specializes ConfigVariable as an enumerated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void write(std::ostream &out)
Lists the contents of the TextureStage pool to the indicated output stream.
Defines the properties of a named stage of the multitexture pipeline.