3 * Copyright (C) 2006 Mathias Froehlich
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 # include <simgear_config.h>
26 #include "SGTextureStateAttributeVisitor.hxx"
28 SGTextureStateAttributeVisitor::SGTextureStateAttributeVisitor() :
29 osg::NodeVisitor(osg::NodeVisitor::NODE_VISITOR,
30 osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
35 SGTextureStateAttributeVisitor::apply(int textureUnit, osg::StateSet::RefAttributePair& refAttr)
40 SGTextureStateAttributeVisitor::apply(int textureUnit, osg::StateSet::AttributeList& attrList)
42 osg::StateSet::AttributeList::iterator i;
44 while (i != attrList.end()) {
45 apply(textureUnit, i->second);
51 SGTextureStateAttributeVisitor::apply(osg::StateSet::TextureAttributeList& attrList)
53 for (unsigned i = 0; i < attrList.size(); ++i)
54 apply(i, attrList[i]);
58 SGTextureStateAttributeVisitor::apply(osg::StateSet* stateSet)
62 apply(stateSet->getTextureAttributeList());
66 SGTextureStateAttributeVisitor::apply(osg::Node& node)
68 apply(node.getStateSet());
73 SGTextureStateAttributeVisitor::apply(osg::Geode& node)
75 unsigned nDrawables = node.getNumDrawables();
76 for (unsigned i = 0; i < nDrawables; ++i)
77 apply(node.getDrawable(i)->getStateSet());
78 apply(node.getStateSet());