Technique
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//osgFX - Copyright (C) 2003 Marco Jez
#ifndef OSGFX_TECHNIQUE_
#define OSGFX_TECHNIQUE_
#include <osgFX/Export>
#include <osg/Referenced>
#include <osg/State>
#include <osg/Group>
#include <osg/NodeVisitor>
#include <vector>
#include <string>
#define META_Technique(name, description) \
inline virtual const char *techniqueName() { return name; } \
inline virtual const char *techniqueDescription() { return description; }
namespace osgFX
{
class Effect;
class OSGFX_EXPORT Technique: public osg::Referenced {
public:
Technique();
virtual const char *techniqueName() { return "Default"; }
virtual const char *techniqueDescription() { return "This is the default technique"; }
virtual void getRequiredExtensions(std::vector<std::string>& /*extensions*/) const {};
virtual bool validate(osg::State& ) const;
inline int getNumPasses() const;
inline osg::StateSet* getPassStateSet(int i);
inline const osg::StateSet* getPassStateSet(int i) const;
inline virtual void traverse(osg::NodeVisitor& nv, Effect* fx);
protected:
Technique(const Technique &): osg::Referenced() {} // copying is nonsense ;)
virtual ~Technique() {}
Technique &operator=(const Technique &) { return *this; }
inline void dirtyPasses();
void addPass(osg::StateSet* ss = 0);
inline virtual osg::Node* getOverrideChild(int) { return 0; }
virtual void define_passes() = 0;
void traverse_implementation(osg::NodeVisitor& nv, Effect* fx);
private:
typedef std::vector<osg::ref_ptr<osg::StateSet> > Pass_list;
OpenThreads::Mutex _mutex;
OpenThreads::Atomic _passesDefined;
Pass_list _passes;
};
// INLINE METHODS
inline int Technique::getNumPasses() const
{
return _passesDefined!=0 ? static_cast<int>(_passes.size()) : 0;
}
inline osg::StateSet* Technique::getPassStateSet(int i)
{
return _passesDefined!=0 ? _passes[i].get() : 0;
}
inline const osg::StateSet* Technique::getPassStateSet(int i) const
{
return _passesDefined!=0 ? _passes[i].get() : 0;
}
inline void Technique::dirtyPasses()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _mutex);
_passesDefined.exchange(0);
_passes.clear();
}
inline void Technique::traverse(osg::NodeVisitor& nv, Effect* fx)
{
traverse_implementation(nv, fx);
}
}
#endif
Group
NodeVisitor
Referenced
State
OpenThreads::Atomic
This class provides an atomic increment and decrement operation.
Definition Atomic:48
OpenThreads::Mutex
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
OpenThreads::ScopedLock
Definition ScopedLock:25
osgFX::Effect
Definition Effect:66
osgFX::Technique::operator=
Technique & operator=(const Technique &)
Definition Technique:101
osgFX::Technique::techniqueName
virtual const char * techniqueName()
Definition Technique:62
osgFX::Technique::getNumPasses
int getNumPasses() const
Definition Technique:133
osgFX::Technique::define_passes
virtual void define_passes()=0
osgFX::Technique::getRequiredExtensions
virtual void getRequiredExtensions(std::vector< std::string > &) const
Definition Technique:72
osgFX::Technique::Technique
Technique()
osgFX::Technique::traverse_implementation
void traverse_implementation(osg::NodeVisitor &nv, Effect *fx)
osgFX::Technique::validate
virtual bool validate(osg::State &) const
osgFX::Technique::Technique
Technique(const Technique &)
Definition Technique:99
osgFX::Technique::traverse
virtual void traverse(osg::NodeVisitor &nv, Effect *fx)
Definition Technique:155
osgFX::Technique::getOverrideChild
virtual osg::Node * getOverrideChild(int)
Definition Technique:110
osgFX::Technique::getPassStateSet
osg::StateSet * getPassStateSet(int i)
Definition Technique:138
osgFX::Technique::~Technique
virtual ~Technique()
Definition Technique:100
osgFX::Technique::techniqueDescription
virtual const char * techniqueDescription()
Definition Technique:65
osgFX::Technique::addPass
void addPass(osg::StateSet *ss=0)
osgFX::Technique::dirtyPasses
void dirtyPasses()
Definition Technique:148
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node
Definition Node:72
osg::Referenced
Definition Referenced:44
osg::Referenced::Referenced
Referenced()
osg::StateSet
Definition StateSet:46
osg::State
Definition State:80
osgFX
Definition AnisotropicLighting:25
osg
Definition AlphaFunc:19
Export
OSGFX_EXPORT
#define OSGFX_EXPORT
Definition osgFX/Export:27