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

@@ -30,7 +30,8 @@
namespace osg {
// forward declare State & StateSet
// forward declare NodeVisitor, State & StateSet
class NodeVisitor;
class State;
class StateSet;
@@ -244,6 +245,39 @@ class OSG_EXPORT StateAttribute : public Object
// default to no GLMode's associated with use of the StateAttribute.
return false;
}
struct Callback : public virtual osg::Object
{
Callback() {}
Callback(const Callback&,const CopyOp&) {}
META_Object(osg,Callback);
/** do customized update code.*/
virtual void operator () (NodeVisitor*, StateAttribute*) {}
};
/** Set the UpdateCallback which allows users to attach customize the updating of an object during the update traversal.*/
void setUpdateCallback(Callback* uc) { _updateCallback = uc; }
/** Get the non const UpdateCallback.*/
Callback* getUpdateCallback() { return _updateCallback.get(); }
/** Get the const UpdateCallback.*/
const Callback* getUpdateCallback() const { return _updateCallback.get(); }
/** Set the EventCallback which allows users to attach customize the updating of an object during the Event traversal.*/
void setEventCallback(Callback* ec) { _eventCallback = ec; }
/** Get the non const EventCallback.*/
Callback* getEventCallback() { return _eventCallback.get(); }
/** Get the const EventCallback.*/
const Callback* getEventCallback() const { return _eventCallback.get(); }
/** apply the OpenGL state attributes.
* The global state for the current OpenGL context is passed
@@ -265,6 +299,8 @@ class OSG_EXPORT StateAttribute : public Object
virtual ~StateAttribute() {}
ref_ptr<Callback> _updateCallback;
ref_ptr<Callback> _eventCallback;
};
}