]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/EffectGeode.cxx
Effects framework
[simgear.git] / simgear / scene / material / EffectGeode.cxx
1 // Copyright (C) 2008  Timothy Moore timoore@redhat.com
2 //
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.
7 //
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.
12 //
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.
16
17 #include "EffectGeode.hxx"
18 #include "Effect.hxx"
19 #include "Technique.hxx"
20
21 #include <osgUtil/CullVisitor>
22
23 namespace simgear
24 {
25
26 using namespace osg;
27 using namespace osgUtil;
28
29 void EffectGeode::traverse(NodeVisitor& nv)
30 {
31     CullVisitor* cv = dynamic_cast<CullVisitor*>(&nv);
32     if (!cv || !_effect.valid()) {
33         Geode::traverse(nv);
34         return;
35     }
36     Technique* technique = _effect->chooseTechnique(&cv->getRenderInfo());
37     if (!technique) {
38         Geode::traverse(nv);
39         return;
40     }
41     for (DrawablesIterator beginItr = _drawables.begin();
42          beginItr != _drawables.end();
43          beginItr = technique->processDrawables(beginItr, _drawables.end(), cv,
44                                                 isCullingActive()))
45         ;
46 }
47
48 void EffectGeode::resizeGLObjectBuffers(unsigned int maxSize)
49 {
50     if (_effect.valid())
51         _effect->resizeGLObjectBuffers(maxSize);
52     Geode::resizeGLObjectBuffers(maxSize);
53 }
54
55 void EffectGeode::releaseGLObjects(osg::State* state) const
56 {
57     if (_effect.valid())
58         _effect->releaseGLObjects(state);
59     Geode::releaseGLObjects(state);
60 }
61
62 }