Added post draw callback to osg::CameraNode/osgUtil::RenderToTextureStage.
Added support for Texture1D, 2D, 3D and TextureRectangle into osgUtil::RenderToTextureStage.
This commit is contained in:
@@ -279,8 +279,30 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
/** Get the const Rendering object that is used to implement rendering of the subgraph.*/
|
||||
const osg::Object* getRenderingCache() const { return _renderingCache.get(); }
|
||||
|
||||
public:
|
||||
|
||||
/** Draw callback for custom operations.*/
|
||||
struct DrawCallback : public Object
|
||||
{
|
||||
DrawCallback() {}
|
||||
|
||||
DrawCallback(const DrawCallback&,const CopyOp&) {}
|
||||
|
||||
META_Object(osg,DrawCallback)
|
||||
|
||||
virtual void operator () (const osg::CameraNode& camera) const {}
|
||||
};
|
||||
|
||||
/** Set the post draw callback for custom operations to do done after the drawing of the camera's subgraph has been completed.*/
|
||||
void setPostDrawCallback(DrawCallback* cb) { _postDrawCallback = cb; }
|
||||
|
||||
/** Get the post draw callback.*/
|
||||
DrawCallback* getPostDrawCallback() { return _postDrawCallback.get(); }
|
||||
|
||||
/** Get the const post draw callback.*/
|
||||
const DrawCallback* getPostDrawCallback() const { return _postDrawCallback.get(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
|
||||
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
|
||||
@@ -311,6 +333,8 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
|
||||
ref_ptr<GraphicsContext> _graphicsContext;
|
||||
ref_ptr<Object> _renderingCache;
|
||||
|
||||
ref_ptr<DrawCallback> _postDrawCallback;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#ifndef OSGUTIL_RENDERTOTEXTURESTAGE
|
||||
#define OSGUTIL_RENDERTOTEXTURESTAGE 1
|
||||
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Texture>
|
||||
#include <osg/FrameBufferObject>
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osg/CameraNode>
|
||||
|
||||
#include <osgUtil/RenderStage>
|
||||
|
||||
@@ -41,9 +41,12 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
|
||||
virtual const char* className() const { return "RenderToTextureStage"; }
|
||||
|
||||
virtual void reset();
|
||||
|
||||
void setCameraNode(const osg::CameraNode* camera) { _camera = camera; }
|
||||
const osg::CameraNode* getCameraNode() const { return _camera; }
|
||||
|
||||
void setTexture(osg::Texture2D* texture) { _texture = texture; }
|
||||
osg::Texture2D* getTexture() { return _texture.get(); }
|
||||
void setTexture(osg::Texture* texture, unsigned int level = 0, unsigned int face=0) { _texture = texture; _level = level; _face = face; }
|
||||
osg::Texture* getTexture() { return _texture.get(); }
|
||||
|
||||
void setImage(osg::Image* image) { _image = image; }
|
||||
osg::Image* getImage() { return _image.get(); }
|
||||
@@ -53,6 +56,7 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
|
||||
|
||||
void setImageReadPixelDataType(GLenum type) { _imageReadPixelDataType = type; }
|
||||
GLenum getImageReadPixelDataType() const { return _imageReadPixelDataType; }
|
||||
|
||||
|
||||
void setFrameBufferObject(osg::FrameBufferObject* fbo) { _fbo = fbo; }
|
||||
osg::FrameBufferObject* getFrameBufferObject() { return _fbo.get(); }
|
||||
@@ -70,8 +74,13 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
|
||||
protected:
|
||||
|
||||
virtual ~RenderToTextureStage();
|
||||
|
||||
const osg::CameraNode* _camera;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> _texture;
|
||||
osg::ref_ptr<osg::Texture> _texture;
|
||||
unsigned int _level;
|
||||
unsigned int _face;
|
||||
|
||||
osg::ref_ptr<osg::Image> _image;
|
||||
GLenum _imageReadPixelFormat;
|
||||
GLenum _imageReadPixelDataType;
|
||||
|
||||
Reference in New Issue
Block a user