OpenSceneGraph 3.6.5
Technique
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13//osgFX - Copyright (C) 2003 Marco Jez
14
15#ifndef OSGFX_TECHNIQUE_
16#define OSGFX_TECHNIQUE_
17
18#include <osgFX/Export>
19
20#include <osg/Referenced>
21#include <osg/State>
22#include <osg/Group>
23#include <osg/NodeVisitor>
24
25#include <vector>
26#include <string>
27
32#define META_Technique(name, description) \
33 inline virtual const char *techniqueName() { return name; } \
34 inline virtual const char *techniqueDescription() { return description; }
35
36
37namespace osgFX
38{
39
40 class Effect;
41
58 public:
60
62 virtual const char *techniqueName() { return "Default"; }
63
65 virtual const char *techniqueDescription() { return "This is the default technique"; }
66
72 virtual void getRequiredExtensions(std::vector<std::string>& /*extensions*/) const {};
73
79 virtual bool validate(osg::State& ) const;
80
82 inline int getNumPasses() const;
83
85 inline osg::StateSet* getPassStateSet(int i);
86
88 inline const osg::StateSet* getPassStateSet(int i) const;
89
96 inline virtual void traverse(osg::NodeVisitor& nv, Effect* fx);
97
98 protected:
99 Technique(const Technique &): osg::Referenced() {} // copying is nonsense ;)
100 virtual ~Technique() {}
101 Technique &operator=(const Technique &) { return *this; }
102
104 inline void dirtyPasses();
105
107 void addPass(osg::StateSet* ss = 0);
108
110 inline virtual osg::Node* getOverrideChild(int) { return 0; }
111
116 virtual void define_passes() = 0;
117
123
124 private:
125 typedef std::vector<osg::ref_ptr<osg::StateSet> > Pass_list;
126 OpenThreads::Mutex _mutex;
127 OpenThreads::Atomic _passesDefined;
128 Pass_list _passes;
129 };
130
131 // INLINE METHODS
132
133 inline int Technique::getNumPasses() const
134 {
135 return _passesDefined!=0 ? static_cast<int>(_passes.size()) : 0;
136 }
137
139 {
140 return _passesDefined!=0 ? _passes[i].get() : 0;
141 }
142
143 inline const osg::StateSet* Technique::getPassStateSet(int i) const
144 {
145 return _passesDefined!=0 ? _passes[i].get() : 0;
146 }
147
149 {
150 OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _mutex);
151 _passesDefined.exchange(0);
152 _passes.clear();
153 }
154
156 {
158 }
159
160}
161
162#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgFX library is a NodeKit that extends the core scene graph to provide a special effects framewo...
Definition AnisotropicLighting:25
Base class for all internal nodes in the scene graph.
Definition Node:72
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
The base class for special effects.
Definition Effect:66
Technique & operator=(const Technique &)
Definition Technique:101
virtual const char * techniqueName()
get the name of this Technique
Definition Technique:62
int getNumPasses() const
get the number of rendering passes defined in this Technique
Definition Technique:133
virtual void define_passes()=0
define the rendering passes that make up this technique.
virtual void getRequiredExtensions(std::vector< std::string > &) const
collect the GL extension strings which are required for this technique to work properly.
Definition Technique:72
void traverse_implementation(osg::NodeVisitor &nv, Effect *fx)
traverse children with multipass if necessary.
virtual bool validate(osg::State &) const
tests whether this technique is valid for the current rendering context.
Technique(const Technique &)
Definition Technique:99
virtual void traverse(osg::NodeVisitor &nv, Effect *fx)
traverse children with multipass if necessary.
Definition Technique:155
virtual osg::Node * getOverrideChild(int)
optional: return a node that overrides the child node on a specified pass
Definition Technique:110
osg::StateSet * getPassStateSet(int i)
get the StateSet object associated to the i-th pass
Definition Technique:138
virtual ~Technique()
Definition Technique:100
virtual const char * techniqueDescription()
get a brief description of this Technique
Definition Technique:65
void addPass(osg::StateSet *ss=0)
create a new pass node, add it to the technique and associate a StateSet
void dirtyPasses()
force rebuilding of pass nodes on next traversal
Definition Technique:148
#define OSGFX_EXPORT
Definition Export:27

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.