1 // Copyright (C) 2008 Timothy Moore timoore@redhat.com
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #ifndef SIMGEAR_EFFECT_GEODE_HXX
18 #define SIMGEAR_EFFECT_GEODE_HXX 1
21 #include <osg/Version>
23 #include <boost/iterator/iterator_adaptor.hpp>
29 class EffectGeode : public osg::Geode
33 #if OSG_VERSION_LESS_THAN(3,3,2)
34 typedef DrawableList::iterator DrawablesIterator;
36 class DrawablesIterator:
37 public boost::iterator_adaptor<
39 osg::NodeList::iterator,
40 osg::ref_ptr<osg::Drawable>,
42 osg::ref_ptr<osg::Drawable> // No reference as Reference type.
43 // The child list does not contain Drawable
44 // ref_ptr so we can not return any
45 // references to them.
53 explicit DrawablesIterator(osg::NodeList::iterator const& node_it):
54 DrawablesIterator::iterator_adaptor_(node_it)
58 friend class boost::iterator_core_access;
59 osg::ref_ptr<osg::Drawable> dereference() const
61 return base_reference()->get()->asDrawable();
67 EffectGeode(const EffectGeode& rhs,
68 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
69 META_Node(simgear,EffectGeode);
70 Effect* getEffect() const { return _effect.get(); }
71 void setEffect(Effect* effect);
72 virtual void resizeGLObjectBuffers(unsigned int maxSize);
73 virtual void releaseGLObjects(osg::State* = 0) const;
75 #if OSG_VERSION_LESS_THAN(3,3,2)
76 DrawablesIterator drawablesBegin() { return _drawables.begin(); }
77 DrawablesIterator drawablesEnd() { return _drawables.end(); }
79 DrawablesIterator drawablesBegin() { return DrawablesIterator(_children.begin()); }
80 DrawablesIterator drawablesEnd() { return DrawablesIterator(_children.end()); }
83 void runGenerators(osg::Geometry *geometry);
85 osg::ref_ptr<Effect> _effect;