Refactored the way that osg::Image/ImageSequence manages the update callback that needs to be attached to Textures to make it possible to use the Image::update() mechansim in other subclasses from osg::Image.
To enable the automatic attachment of the required update callback to call osg::Image::update(..) subclasses from osg::Image will need to implement the osg::Image::requestUpdateCall() and return true, and implement the osg::Image::update(NodeVisitor*) method to recieve the update call during the update traversal.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -320,9 +321,22 @@ class OSG_EXPORT Image : public BufferData
|
||||
|
||||
/** Get the const PixelBufferObject.*/
|
||||
const PixelBufferObject* getPixelBufferObject() const { return dynamic_cast<const PixelBufferObject*>(_bufferObject.get()); }
|
||||
|
||||
|
||||
/** return whether the update(NodeVisitor* nv) should be required on each frame to enable proper working of osg::Image.*/
|
||||
virtual bool requiresUpdateCall() const { return false; }
|
||||
|
||||
/** update method for osg::Image subclasses that update themselves during the update traversal.*/
|
||||
virtual void update(NodeVisitor* /*nv*/) {}
|
||||
|
||||
/** convience update callback class that can be attached to StateAttribute (such as Textures) to ensure
|
||||
* that the Image::update(NodeVisitor*) method is called during the update traversal. This callback
|
||||
* is automatically attached when Image::requiresUpdateCall() is true (it's false by default.)
|
||||
*/
|
||||
struct OSG_EXPORT UpdateCallback : public osg::StateAttributeCallback
|
||||
{
|
||||
virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
/** method for sending pointer events to images that are acting as front ends to interactive surfaces such as a vnc or browser window. Return true if handled. */
|
||||
virtual bool sendPointerEvent(int /*x*/, int /*y*/, int /*buttonMask*/) { return false; }
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <OpenThreads/Mutex>
|
||||
#include <osg/ImageStream>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
@@ -101,15 +100,13 @@ class OSG_EXPORT ImageSequence : public ImageStream
|
||||
|
||||
Images& getImages() { return _images; }
|
||||
const Images& getImages() const { return _images; }
|
||||
|
||||
|
||||
/** ImageSequence requires a call to update(NodeVisitor*) during the update traversal so return true.*/
|
||||
virtual bool requiresUpdateCall() const { return true; }
|
||||
|
||||
/** update method for osg::Image subclasses that update themselves during the update traversal.*/
|
||||
virtual void update(NodeVisitor* nv);
|
||||
|
||||
struct OSG_EXPORT UpdateCallback : public osg::StateAttributeCallback
|
||||
{
|
||||
virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~ImageSequence() {}
|
||||
|
||||
Reference in New Issue
Block a user