GLObjectsVisitor
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.
*/
#ifndef OSGUTIL_GLOBJECTSVISITOR
#define OSGUTIL_GLOBJECTSVISITOR 1
#include <OpenThreads/Mutex>
#include <osg/NodeVisitor>
#include <osg/Geode>
#include <osg/State>
#include <osgUtil/Export>
namespace osgUtil {
class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
{
public:
enum ModeValues
{
SWITCH_ON_DISPLAY_LISTS = 0x1,
SWITCH_OFF_DISPLAY_LISTS = 0x2,
COMPILE_DISPLAY_LISTS = 0x4,
COMPILE_STATE_ATTRIBUTES = 0x8,
RELEASE_DISPLAY_LISTS = 0x10,
RELEASE_STATE_ATTRIBUTES = 0x20,
SWITCH_ON_VERTEX_BUFFER_OBJECTS = 0x40,
SWITCH_OFF_VERTEX_BUFFER_OBJECTS = 0x80,
CHECK_BLACK_LISTED_MODES = 0x100
};
typedef unsigned int Mode;
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES);
META_NodeVisitor(osgUtil, GLObjectsVisitor)
virtual void reset()
{
_drawablesAppliedSet.clear();
_stateSetAppliedSet.clear();
}
void setMode(Mode mode) { _mode = mode; }
Mode getMode() const { return _mode; }
void setState(osg::State* state)
{
_renderInfo.setState(state);
}
osg::State* getState()
{
return _renderInfo.getState();
}
void setRenderInfo(osg::RenderInfo& renderInfo)
{
_renderInfo = renderInfo;
}
osg::RenderInfo& getRenderInfo()
{
return _renderInfo;
}
void setCheckForGLErrors(osg::State::CheckForGLErrors check) { _checkGLErrors = check; }
osg::State::CheckForGLErrors getCheckForGLErrors() const { return _checkGLErrors; }
virtual void apply(osg::Node& node);
void apply(osg::Drawable& drawable);
void apply(osg::StateSet& stateset);
void compile(osg::Node& node);
protected:
typedef std::set<osg::Drawable*> DrawableAppliedSet;
typedef std::set<osg::StateSet*> StatesSetAppliedSet;
Mode _mode;
osg::RenderInfo _renderInfo;
osg::State::CheckForGLErrors _checkGLErrors;
DrawableAppliedSet _drawablesAppliedSet;
StatesSetAppliedSet _stateSetAppliedSet;
osg::ref_ptr<osg::Program> _lastCompiledProgram;
};
class OSGUTIL_EXPORT GLObjectsOperation : public osg::GraphicsOperation
{
public:
GLObjectsOperation(GLObjectsVisitor::Mode mode = GLObjectsVisitor::COMPILE_DISPLAY_LISTS|GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|GLObjectsVisitor::CHECK_BLACK_LISTED_MODES);
GLObjectsOperation(osg::Node* subgraph, GLObjectsVisitor::Mode mode = GLObjectsVisitor::COMPILE_DISPLAY_LISTS|GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|GLObjectsVisitor::CHECK_BLACK_LISTED_MODES);
virtual void operator () (osg::GraphicsContext* context);
protected:
osg::ref_ptr<osg::Node> _subgraph;
GLObjectsVisitor::Mode _mode;
};
}
#endif
Geode
Mutex
NodeVisitor
State
osgUtil::GLObjectsOperation::GLObjectsOperation
GLObjectsOperation(GLObjectsVisitor::Mode mode=GLObjectsVisitor::COMPILE_DISPLAY_LISTS|GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|GLObjectsVisitor::CHECK_BLACK_LISTED_MODES)
osgUtil::GLObjectsOperation::GLObjectsOperation
GLObjectsOperation(osg::Node *subgraph, GLObjectsVisitor::Mode mode=GLObjectsVisitor::COMPILE_DISPLAY_LISTS|GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|GLObjectsVisitor::CHECK_BLACK_LISTED_MODES)
osgUtil::GLObjectsOperation::_mode
GLObjectsVisitor::Mode _mode
Definition GLObjectsVisitor:137
osgUtil::GLObjectsOperation::_subgraph
osg::ref_ptr< osg::Node > _subgraph
Definition GLObjectsVisitor:136
osgUtil::GLObjectsVisitor::setState
void setState(osg::State *state)
Definition GLObjectsVisitor:74
osgUtil::GLObjectsVisitor::getMode
Mode getMode() const
Definition GLObjectsVisitor:70
osgUtil::GLObjectsVisitor::_renderInfo
osg::RenderInfo _renderInfo
Definition GLObjectsVisitor:115
osgUtil::GLObjectsVisitor::getRenderInfo
osg::RenderInfo & getRenderInfo()
Definition GLObjectsVisitor:89
osgUtil::GLObjectsVisitor::setCheckForGLErrors
void setCheckForGLErrors(osg::State::CheckForGLErrors check)
Definition GLObjectsVisitor:95
osgUtil::GLObjectsVisitor::apply
void apply(osg::StateSet &stateset)
osgUtil::GLObjectsVisitor::_lastCompiledProgram
osg::ref_ptr< osg::Program > _lastCompiledProgram
Definition GLObjectsVisitor:120
osgUtil::GLObjectsVisitor::ModeValues
ModeValues
Definition GLObjectsVisitor:36
osgUtil::GLObjectsVisitor::SWITCH_OFF_DISPLAY_LISTS
@ SWITCH_OFF_DISPLAY_LISTS
Definition GLObjectsVisitor:38
osgUtil::GLObjectsVisitor::SWITCH_ON_VERTEX_BUFFER_OBJECTS
@ SWITCH_ON_VERTEX_BUFFER_OBJECTS
Definition GLObjectsVisitor:43
osgUtil::GLObjectsVisitor::SWITCH_ON_DISPLAY_LISTS
@ SWITCH_ON_DISPLAY_LISTS
Definition GLObjectsVisitor:37
osgUtil::GLObjectsVisitor::CHECK_BLACK_LISTED_MODES
@ CHECK_BLACK_LISTED_MODES
Definition GLObjectsVisitor:45
osgUtil::GLObjectsVisitor::SWITCH_OFF_VERTEX_BUFFER_OBJECTS
@ SWITCH_OFF_VERTEX_BUFFER_OBJECTS
Definition GLObjectsVisitor:44
osgUtil::GLObjectsVisitor::RELEASE_DISPLAY_LISTS
@ RELEASE_DISPLAY_LISTS
Definition GLObjectsVisitor:41
osgUtil::GLObjectsVisitor::RELEASE_STATE_ATTRIBUTES
@ RELEASE_STATE_ATTRIBUTES
Definition GLObjectsVisitor:42
osgUtil::GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES
@ COMPILE_STATE_ATTRIBUTES
Definition GLObjectsVisitor:40
osgUtil::GLObjectsVisitor::COMPILE_DISPLAY_LISTS
@ COMPILE_DISPLAY_LISTS
Definition GLObjectsVisitor:39
osgUtil::GLObjectsVisitor::getCheckForGLErrors
osg::State::CheckForGLErrors getCheckForGLErrors() const
Definition GLObjectsVisitor:98
osgUtil::GLObjectsVisitor::_stateSetAppliedSet
StatesSetAppliedSet _stateSetAppliedSet
Definition GLObjectsVisitor:119
osgUtil::GLObjectsVisitor::apply
virtual void apply(osg::Node &node)
osgUtil::GLObjectsVisitor::compile
void compile(osg::Node &node)
osgUtil::GLObjectsVisitor::setMode
void setMode(Mode mode)
Definition GLObjectsVisitor:67
osgUtil::GLObjectsVisitor::getState
osg::State * getState()
Definition GLObjectsVisitor:79
osgUtil::GLObjectsVisitor::_mode
Mode _mode
Definition GLObjectsVisitor:114
osgUtil::GLObjectsVisitor::apply
void apply(osg::Drawable &drawable)
osgUtil::GLObjectsVisitor::Mode
unsigned int Mode
Definition GLObjectsVisitor:48
osgUtil::GLObjectsVisitor::StatesSetAppliedSet
std::set< osg::StateSet * > StatesSetAppliedSet
Definition GLObjectsVisitor:112
osgUtil::GLObjectsVisitor::META_NodeVisitor
META_NodeVisitor(osgUtil, GLObjectsVisitor) virtual void reset()
Definition GLObjectsVisitor:57
osgUtil::GLObjectsVisitor::setRenderInfo
void setRenderInfo(osg::RenderInfo &renderInfo)
Definition GLObjectsVisitor:84
osgUtil::GLObjectsVisitor::_drawablesAppliedSet
DrawableAppliedSet _drawablesAppliedSet
Definition GLObjectsVisitor:118
osgUtil::GLObjectsVisitor::_checkGLErrors
osg::State::CheckForGLErrors _checkGLErrors
Definition GLObjectsVisitor:116
osgUtil::GLObjectsVisitor::GLObjectsVisitor
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES)
osgUtil::GLObjectsVisitor::DrawableAppliedSet
std::set< osg::Drawable * > DrawableAppliedSet
Definition GLObjectsVisitor:111
osg::Drawable
Definition Drawable:89
osg::GraphicsContext
Definition GraphicsContext:30
osg::NodeVisitor
Definition NodeVisitor:82
osg::NodeVisitor::reset
virtual void reset()
Definition NodeVisitor:167
osg::Node
Definition Node:72
osg::RenderInfo
Definition RenderInfo:28
osg::StateSet
Definition StateSet:46
osg::State
Definition State:80
osg::State::CheckForGLErrors
CheckForGLErrors
Definition State:905
osg::ref_ptr
Definition ref_ptr:32
osgUtil
Definition NodeVisitor:25
Export
OSGUTIL_EXPORT
#define OSGUTIL_EXPORT
Definition osgUtil/Export:40
osg::GraphicsOperation
Definition GraphicsThread:36