root/OpenSceneGraph/trunk/src/osgFX/Technique.cpp @ 13041

Revision 13041, 1.6 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <osgFX/Technique>
2#include <osgFX/Effect>
3
4#include <osg/GLExtensions>
5
6#include <osgUtil/CullVisitor>
7
8using namespace osgFX;
9
10Technique::Technique()
11:    osg::Referenced()
12{
13}
14
15void Technique::addPass(osg::StateSet* ss)
16{
17    if (ss) {
18        _passes.push_back(ss);
19        ss->setRenderBinDetails(static_cast<int>(_passes.size()), "RenderBin");
20    }
21}
22
23bool Technique::validate(osg::State& state) const
24{
25    typedef std::vector<std::string> String_list;
26    String_list extensions;
27
28    getRequiredExtensions(extensions);
29
30    for (String_list::const_iterator i=extensions.begin(); i!=extensions.end(); ++i) {
31        if (!osg::isGLExtensionSupported(state.getContextID(),i->c_str())) return false;
32    }
33
34    return true;
35}
36
37void Technique::traverse_implementation(osg::NodeVisitor& nv, Effect* fx)
38{
39    // define passes if necessary
40    if (_passes.empty()) {
41        define_passes();
42    }
43
44    // special actions must be taken if the node visitor is actually a CullVisitor
45    osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
46
47    // traverse all passes
48    for (int i=0; i<getNumPasses(); ++i) {
49
50        // push the i-th pass' StateSet if necessary
51        if (cv) {
52            cv->pushStateSet(_passes[i].get());
53        }
54
55        // traverse the override node if defined, otherwise
56        // traverse children as a Group would do
57        osg::Node *override = getOverrideChild(i);
58        if (override) {
59            override->accept(nv);
60        } else {
61            fx->inherited_traverse(nv);
62        }
63
64        // pop the StateSet if necessary
65        if (cv) {
66            cv->popStateSet();
67        }
68    }
69}
Note: See TracBrowser for help on using the browser.