Preliminary steps to adding update and event callbacks to StateSet, StateAttribute
and Uniform.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user