1 // Copyright (C) 2008 - 2009 Tim Moore timoore@redhat.com
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
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 GNU
11 // Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #ifndef SIMGEAR_EFFECT_HXX
18 #define SIMGEAR_EFFECT_HXX 1
24 #include <osgDB/ReaderWriter>
26 #include <simgear/props/props.hxx>
44 class Effect : public osg::Object
47 META_Object(simgear,Effect)
49 Effect(const Effect& rhs,
50 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
51 osg::StateSet* getDefaultStateSet();
52 std::vector<osg::ref_ptr<Technique> > techniques;
53 SGPropertyNode_ptr root;
54 // Pointer to the parameters node, if it exists
55 SGPropertyNode_ptr parametersProp;
56 Technique* chooseTechnique(osg::RenderInfo* renderInfo);
57 virtual void resizeGLObjectBuffers(unsigned int maxSize);
58 virtual void releaseGLObjects(osg::State* state = 0) const;
60 * Build the techniques from the effect properties.
62 bool realizeTechniques(const osgDB::ReaderWriter::Options* options = 0);
67 Effect* makeEffect(const std::string& name,
68 bool realizeTechniques,
69 const osgDB::ReaderWriter::Options* options = 0);
71 Effect* makeEffect(SGPropertyNode* prop,
72 bool realizeTechniques,
73 const osgDB::ReaderWriter::Options* options = 0);
75 bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
76 const osg::StateSet* ss);
81 * The function that implements effect property tree inheritance.
83 void mergePropertyTrees(SGPropertyNode* resultNode,
84 const SGPropertyNode* left,
85 const SGPropertyNode* right);