Permalink
Switch branches/tags
OpenSceneGraph-3.6.2 OpenSceneGraph-3.6.1 OpenSceneGraph-3.6.0 OpenSceneGraph-3.5.10 OpenSceneGraph-3.5.9 OpenSceneGraph-3.5.8 OpenSceneGraph-3.5.7 OpenSceneGraph-3.5.6 OpenSceneGraph-3.5.5 OpenSceneGraph-3.5.4 OpenSceneGraph-3.5.3 OpenSceneGraph-3.5.2 OpenSceneGraph-3.5.1 OpenSceneGraph-3.5.0 OpenSceneGraph-3.4.1 OpenSceneGraph-3.4.0 OpenSceneGraph-3.3.9 OpenSceneGraph-3.3.8 OpenSceneGraph-3.3.7 OpenSceneGraph-3.3.6 OpenSceneGraph-3.3.5 OpenSceneGraph-3.3.4 OpenSceneGraph-3.3.3 OpenSceneGraph-3.3.2 OpenSceneGraph-3.3.1 OpenSceneGraph-3.3.0 OpenSceneGraph-3.2.3 OpenSceneGraph-3.2.2 OpenSceneGraph-3.2.1 OpenSceneGraph-3.2.0 OpenSceneGraph-3.1.10 OpenSceneGraph-3.1.9 OpenSceneGraph-3.1.8 OpenSceneGraph-3.1.7 OpenSceneGraph-3.1.6 OpenSceneGraph-3.1.5 OpenSceneGraph-3.1.4 OpenSceneGraph-3.1.2 OpenSceneGraph-3.1.1 OpenSceneGraph-3.1.0 OpenSceneGraph-3.0.1 OpenSceneGraph-3.0.0 OpenSceneGraph-2.9.16 OpenSceneGraph-2.9.15 OpenSceneGraph-2.9.14 OpenSceneGraph-2.9.13 OpenSceneGraph-2.9.12 OpenSceneGraph-2.9.11 OpenSceneGraph-2.9.10 OpenSceneGraph-2.9.9 OpenSceneGraph-2.9.8 OpenSceneGraph-2.9.7 OpenSceneGraph-2.9.6 OpenSceneGraph-2.9.5 OpenSceneGraph-2.9.4 OpenSceneGraph-2.9.3 OpenSceneGraph-2.9.2 OpenSceneGraph-2.9.1 OpenSceneGraph-2.9.0 OpenSceneGraph-2.8.5 OpenSceneGraph-2.8.4 OpenSceneGraph-2.8.3 OpenSceneGraph-2.8.2 OpenSceneGraph-2.8.2b OpenSceneGraph-2.8.1 OpenSceneGraph-2.8.0 OpenSceneGraph-2.7.9 OpenSceneGraph-2.7.8 OpenSceneGraph-2.7.7 OpenSceneGraph-2.7.6 OpenSceneGraph-2.7.5 OpenSceneGraph-2.7.4 OpenSceneGraph-2.7.3 OpenSceneGraph-2.7.2 OpenSceneGraph-2.7.1 OpenSceneGraph-2.7.0 OpenSceneGraph-2.6.1 OpenSceneGraph-2.6.0 OpenSceneGraph-2.5.5 OpenSceneGraph-2.5.4 OpenSceneGraph-2.5.3 OpenSceneGraph-2.5.2 OpenSceneGraph-2.5.1 OpenSceneGraph-2.5.0 OpenSceneGraph-2.4.0 OpenSceneGraph-2.3.11 OpenSceneGraph-2.3.10 OpenSceneGraph-2.3.9 OpenSceneGraph-2.3.8 OpenSceneGraph-2.3.7 OpenSceneGraph-2.3.6 OpenSceneGraph-2.3.5 OpenSceneGraph-2.3.4 OpenSceneGraph-2.3.3 OpenSceneGraph-2.3.2 OpenSceneGraph-2.3.1 OpenSceneGraph-2.3.0 OpenSceneGraph-2.2.0 OpenSceneGraph-2.1.15 OpenSceneGraph-2.1.14
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (65 sloc) 1.85 KB
#include <osgFX/Technique>
#include <osgFX/Effect>
#include <osg/GLExtensions>
#include <osgUtil/CullVisitor>
using namespace osgFX;
Technique::Technique()
: osg::Referenced(),
_passesDefined(0)
{
}
void Technique::addPass(osg::StateSet* ss)
{
if (ss) {
_passes.push_back(ss);
ss->setRenderBinDetails(static_cast<int>(_passes.size()), "RenderBin");
}
}
bool Technique::validate(osg::State& state) const
{
typedef std::vector<std::string> String_list;
String_list extensions;
getRequiredExtensions(extensions);
for (String_list::const_iterator i=extensions.begin(); i!=extensions.end(); ++i) {
if (!osg::isGLExtensionSupported(state.getContextID(),i->c_str())) return false;
}
return true;
}
void Technique::traverse_implementation(osg::NodeVisitor& nv, Effect* fx)
{
// define passes if necessary
if (_passesDefined==0)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _mutex);
if (_passesDefined==0)
{
define_passes();
_passesDefined.exchange(1);
}
}
// special actions must be taken if the node visitor is actually a CullVisitor
osgUtil::CullVisitor* cv = nv.asCullVisitor();
if (cv)
{
// traverse all passes
for (size_t i=0; i<_passes.size(); ++i)
{
// push the i-th pass' StateSet
cv->pushStateSet(_passes[i].get());
// traverse the override node if defined, otherwise
// traverse children as a Group would do
osg::Node *override = getOverrideChild(i);
if (override) {
override->accept(nv);
} else {
fx->inherited_traverse(nv);
}
// pop the StateSet
cv->popStateSet();
}
}
else
{
fx->inherited_traverse(nv);
}
}