1 // Copyright (C) 2008 Timothy Moore timoore@redhat.com
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // 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_TECHNIQUE_HXX
18 #define SIMGEAR_TECHNIQUE_HXX 1
20 #include "EffectGeode.hxx"
22 #include <simgear/structure/SGAtomic.hxx>
28 #include <OpenThreads/Mutex>
29 #include <osg/buffered_value>
32 #include <osg/GraphicsThread>
51 class Technique : public osg::Object
54 META_Object(simgear,Technique);
56 Technique(const Technique& rhs,
57 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
66 /** Returns the validity of a technique in a state. If we don't
67 * know, a query will be launched.
69 virtual Status valid(osg::RenderInfo* renderInfo);
70 /** Returns the validity of the technique without launching a
73 Status getValidStatus(const osg::RenderInfo* renderInfo) const;
74 /** Tests and sets the validity of the Technique. Must be run in a
77 virtual void validateInContext(osg::GraphicsContext* gc);
79 virtual EffectGeode::DrawablesIterator
80 processDrawables(const EffectGeode::DrawablesIterator& begin,
81 const EffectGeode::DrawablesIterator& end,
82 osgUtil::CullVisitor* cv,
83 bool isCullingActive);
84 std::vector<osg::ref_ptr<Pass> > passes;
85 osg::StateSet* getShadowingStateSet() { return _shadowingStateSet.get(); }
86 void setShadowingStateSet(osg::StateSet* ss) { _shadowingStateSet = ss; }
87 virtual void resizeGLObjectBuffers(unsigned int maxSize);
88 virtual void releaseGLObjects(osg::State* state = 0) const;
89 // Initial validity testing. Either the minimum OpenGL version
90 // must be supported, or the list of extensions must be supported.
91 float getGLVersion() { return _glVersion; }
92 void setGLVersion(float glVersion) { _glVersion = glVersion; }
93 std::vector<std::string> glExtensions;
95 // Validity of technique in a graphics context.
96 struct ContextInfo : public osg::Referenced
98 ContextInfo() : valid(UNKNOWN) {}
99 ContextInfo(const ContextInfo& rhs) : valid(rhs.valid()) {}
100 ContextInfo& operator=(const ContextInfo& rhs)
104 Swappable<Status> valid;
106 typedef osg::buffered_object<ContextInfo> ContextMap;
107 mutable ContextMap _contextMap;
108 osg::ref_ptr<osg::StateSet> _shadowingStateSet;