Preliminary steps to adding update and event callbacks to StateSet, StateAttribute

and Uniform.
This commit is contained in:
Robert Osfield
2005-04-22 22:45:39 +00:00
parent c7fb7e8b5f
commit 819d2c6c56
7 changed files with 137 additions and 14 deletions

View File

@@ -33,6 +33,9 @@
namespace osg {
// forward declare for the purposes of the UpdateCallback.
class NodeVisitor;
/** Stores a set of modes and attributes which respresent a set of OpenGL state.
* Notice that a \c StateSet contains just a subset of the whole OpenGL state.
* <p>In OSG, each \c Drawable and each \c Node has a reference to a
@@ -354,6 +357,46 @@ class OSG_EXPORT StateSet : public Object
inline const std::string& getBinName() const { return _binName; }
struct Callback : public virtual osg::Object
{
Callback() {}
Callback(const Callback&,const CopyOp&) {}
META_Object(osg,Callback);
/** do customized callback code.*/
virtual void operator() (NodeVisitor*, StateSet*) {}
};
/** Set the Update Callback which allows users to attach customize the updating of an object during the update traversal.*/
void setUpdateCallback(Callback* ac);
/** Get the non const Update Callback.*/
Callback* getUpdateCallback() { return _updateCallback.get(); }
/** Get the const Update Callback.*/
const Callback* getUpdateCallback() const { return _updateCallback.get(); }
/** Get the number of Objects of this StateSet which require Update traversal,
* since they have an Update Callback attached to them or their children.*/
inline unsigned int getNumObjectsRequiringUpdateTraversal() const { return _numObjectsRequiringUpdateTraversal; }
/** Set the Event Callback which allows users to attach customize the updating of an object during the event traversal.*/
void setEventCallback(Callback* ac);
/** Get the non const Event Callback.*/
Callback* getEventCallback() { return _eventCallback.get(); }
/** Get the const Event Callback.*/
const Callback* getEventCallback() const { return _eventCallback.get(); }
/** Get the number of Objects of this StateSet which require Event traversal,
* since they have an Eevnt Callback attached to them or their children.*/
inline unsigned int getNumObjectsRequiringEventTraversal() const { return _numObjectsRequiringEventTraversal; }
/** call compile on all StateAttributes contained within this StateSet.*/
void compileGLObjects(State& state) const;
@@ -406,6 +449,12 @@ class OSG_EXPORT StateSet : public Object
RenderBinMode _binMode;
int _binNum;
std::string _binName;
ref_ptr<Callback> _updateCallback;
unsigned int _numObjectsRequiringUpdateTraversal;
ref_ptr<Callback> _eventCallback;
unsigned int _numObjectsRequiringEventTraversal;
};