RenderLeaf
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_RENDERLEAF
#define OSGUTIL_RENDERLEAF 1
#include <osg/ref_ptr>
#include <osg/Matrix>
#include <osg/Drawable>
#include <osg/State>
#include <osgUtil/Export>
namespace osgUtil {
#define OSGUTIL_RENDERBACKEND_USE_REF_PTR
// Forward declare StateGraph
class StateGraph;
class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
{
public:
inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalOrderNumber=0):
osg::Referenced(false),
_parent(0),
_drawable(drawable),
_projection(projection),
_modelview(modelview),
_depth(depth),
_traversalOrderNumber(traversalOrderNumber)
{
_dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
}
inline void set(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalOrderNumber=0)
{
_parent = 0;
_drawable = drawable;
_projection = projection;
_modelview = modelview;
_depth = depth;
_dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
_traversalOrderNumber = traversalOrderNumber;
}
inline void reset()
{
_parent = 0;
_drawable = 0;
_projection = 0;
_modelview = 0;
_depth = 0.0f;
_dynamic = false;
_traversalOrderNumber = 0;
}
virtual void render(osg::RenderInfo& renderInfo,RenderLeaf* previous);
virtual void resizeGLObjectBuffers(unsigned int maxSize)
{
if (_drawable) _drawable->resizeGLObjectBuffers(maxSize);
}
virtual void releaseGLObjects(osg::State* state=0) const
{
if (_drawable) _drawable->releaseGLObjects(state);
}
friend class osgUtil::StateGraph;
public:
StateGraph* _parent;
#ifdef OSGUTIL_RENDERBACKEND_USE_REF_PTR
osg::ref_ptr<osg::Drawable> _drawable;
const osg::Drawable* getDrawable() const { return _drawable.get(); }
#else
osg::Drawable* _drawable;
const osg::Drawable* getDrawable() const { return _drawable; }
#endif
osg::ref_ptr<osg::RefMatrix> _projection;
osg::ref_ptr<osg::RefMatrix> _modelview;
float _depth;
bool _dynamic;
unsigned int _traversalOrderNumber;
private:
RenderLeaf():
osg::Referenced(false),
_parent(0),
_drawable(0),
_projection(0),
_modelview(0),
_depth(0.0f),
_traversalOrderNumber(0) {}
RenderLeaf(const RenderLeaf&):osg::Referenced(false) {}
RenderLeaf& operator = (const RenderLeaf&) { return *this; }
};
}
#endif
Drawable
Matrix
State
osgUtil::RenderLeaf
Definition RenderLeaf:34
osgUtil::RenderLeaf::releaseGLObjects
virtual void releaseGLObjects(osg::State *state=0) const
Definition RenderLeaf:80
osgUtil::RenderLeaf::reset
void reset()
Definition RenderLeaf:62
osgUtil::RenderLeaf::_parent
StateGraph * _parent
Definition RenderLeaf:92
osgUtil::RenderLeaf::_drawable
osg::ref_ptr< osg::Drawable > _drawable
Definition RenderLeaf:95
osgUtil::RenderLeaf::_projection
osg::ref_ptr< osg::RefMatrix > _projection
Definition RenderLeaf:101
osgUtil::RenderLeaf::_traversalOrderNumber
unsigned int _traversalOrderNumber
Definition RenderLeaf:105
osgUtil::RenderLeaf::StateGraph
friend class osgUtil::StateGraph
Allow StateGraph to change the RenderLeaf's _parent.
Definition RenderLeaf:86
osgUtil::RenderLeaf::RenderLeaf
RenderLeaf(osg::Drawable *drawable, osg::RefMatrix *projection, osg::RefMatrix *modelview, float depth=0.0f, unsigned int traversalOrderNumber=0)
Definition RenderLeaf:38
osgUtil::RenderLeaf::render
virtual void render(osg::RenderInfo &renderInfo, RenderLeaf *previous)
osgUtil::RenderLeaf::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Definition RenderLeaf:75
osgUtil::RenderLeaf::set
void set(osg::Drawable *drawable, osg::RefMatrix *projection, osg::RefMatrix *modelview, float depth=0.0f, unsigned int traversalOrderNumber=0)
Definition RenderLeaf:51
osgUtil::RenderLeaf::_depth
float _depth
Definition RenderLeaf:103
osgUtil::RenderLeaf::_modelview
osg::ref_ptr< osg::RefMatrix > _modelview
Definition RenderLeaf:102
osgUtil::RenderLeaf::_dynamic
bool _dynamic
Definition RenderLeaf:104
osgUtil::RenderLeaf::getDrawable
const osg::Drawable * getDrawable() const
Definition RenderLeaf:96
osgUtil::StateGraph
Definition StateGraph:42
osg::Drawable
Definition Drawable:89
osg::Object::DYNAMIC
@ DYNAMIC
Definition Object:218
osg::Object::getDataVariance
DataVariance getDataVariance() const
Definition Object:231
osg::Referenced
Definition Referenced:44
osg::Referenced::Referenced
Referenced()
osg::RenderInfo
Definition RenderInfo:28
osg::State
Definition State:80
osg::ref_ptr
Definition ref_ptr:32
osgUtil
Definition NodeVisitor:25
osg
Definition AlphaFunc:19
osg::RefMatrix
RefMatrixd RefMatrix
Definition Matrix:28
Export
OSGUTIL_EXPORT
#define OSGUTIL_EXPORT
Definition osgUtil/Export:40
ref_ptr