]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/Effect.cxx
646a0096de84684bbc10be9410b12641469ae2b5
[simgear.git] / simgear / scene / material / Effect.cxx
1 #include "Effect.hxx"
2 #include "Technique.hxx"
3
4 #include <algorithm>
5 #include <functional>
6 #include <iterator>
7
8 #include <boost/bind.hpp>
9 #include <boost/foreach.hpp>
10
11 #include <osg/Drawable>
12 #include <osg/RenderInfo>
13 #include <osg/StateSet>
14
15 #include <osgUtil/CullVisitor>
16
17 #include <simgear/structure/OSGUtils.hxx>
18
19
20
21 namespace simgear
22 {
23 using namespace osg;
24 using namespace osgUtil;
25
26 Effect::Effect(const Effect& rhs, const CopyOp& copyop)
27 {
28     using namespace std;
29     using namespace boost;
30     transform(rhs.techniques.begin(), rhs.techniques.end(),
31               backRefInsertIterator(techniques),
32               bind(simgear::clone_ref<Technique>, _1, copyop));
33 }
34 // There should always be a valid technique in an effect.
35
36 Technique* Effect::chooseTechnique(RenderInfo* info)
37 {
38     BOOST_FOREACH(ref_ptr<Technique>& technique, techniques)
39     {
40         if (technique->valid(info) == Technique::VALID)
41             return technique.get();
42     }
43     return 0;
44 }
45
46 void Effect::resizeGLObjectBuffers(unsigned int maxSize)
47 {
48     BOOST_FOREACH(const ref_ptr<Technique>& technique, techniques)
49     {
50         technique->resizeGLObjectBuffers(maxSize);
51     }
52 }
53
54 void Effect::releaseGLObjects(osg::State* state) const
55 {
56     BOOST_FOREACH(const ref_ptr<Technique>& technique, techniques)
57     {
58         technique->releaseGLObjects(state);
59     }
60 }
61 }