2005-04-15 05:41:28 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-10-04 23:12:57 +08:00
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
#ifndef OSGUTIL_RENDERTOTEXTURESTAGE
|
|
|
|
#define OSGUTIL_RENDERTOTEXTURESTAGE 1
|
|
|
|
|
2002-08-25 03:39:39 +08:00
|
|
|
#include <osg/Texture2D>
|
2005-06-16 22:01:38 +08:00
|
|
|
#include <osg/FrameBufferObject>
|
2001-09-20 05:19:47 +08:00
|
|
|
|
|
|
|
#include <osgUtil/RenderStage>
|
|
|
|
|
|
|
|
namespace osgUtil {
|
|
|
|
|
|
|
|
/**
|
2002-07-10 19:22:24 +08:00
|
|
|
* RenderStage which copies the final image to an attached texture or image.
|
|
|
|
* Generally used as a pre-rendering stage.
|
2001-09-20 05:19:47 +08:00
|
|
|
*/
|
|
|
|
class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
RenderToTextureStage();
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual osg::Object* cloneType() const { return new RenderToTextureStage(); }
|
|
|
|
virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderToTextureStage(); } // note only implements a clone of type.
|
2001-09-20 05:19:47 +08:00
|
|
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
|
2002-06-06 21:25:36 +08:00
|
|
|
virtual const char* libraryName() const { return "osgUtil"; }
|
2001-09-20 05:19:47 +08:00
|
|
|
virtual const char* className() const { return "RenderToTextureStage"; }
|
|
|
|
|
|
|
|
virtual void reset();
|
|
|
|
|
2002-08-25 03:39:39 +08:00
|
|
|
void setTexture(osg::Texture2D* texture) { _texture = texture; }
|
|
|
|
osg::Texture2D* getTexture() { return _texture.get(); }
|
2001-09-20 05:19:47 +08:00
|
|
|
|
2002-07-10 19:22:24 +08:00
|
|
|
void setImage(osg::Image* image) { _image = image; }
|
|
|
|
osg::Image* getImage() { return _image.get(); }
|
2005-01-10 03:30:56 +08:00
|
|
|
|
|
|
|
void setImageReadPixelFormat(GLenum format) { _imageReadPixelFormat = format; }
|
|
|
|
GLenum getImageReadPixelFormat() const { return _imageReadPixelFormat; }
|
|
|
|
|
|
|
|
void setImageReadPixelDataType(GLenum type) { _imageReadPixelDataType = type; }
|
|
|
|
GLenum getImageReadPixelDataType() const { return _imageReadPixelDataType; }
|
2005-06-16 22:01:38 +08:00
|
|
|
|
|
|
|
void setFrameBufferObject(osg::FrameBufferObject* fbo) { _fbo = fbo; }
|
|
|
|
osg::FrameBufferObject* getFrameBufferObject() { return _fbo.get(); }
|
|
|
|
const osg::FrameBufferObject* getFrameBufferObject() const { return _fbo.get(); }
|
2002-07-10 19:22:24 +08:00
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
virtual void draw(osg::State& state,RenderLeaf*& previous);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~RenderToTextureStage();
|
|
|
|
|
2005-06-16 22:01:38 +08:00
|
|
|
osg::ref_ptr<osg::Texture2D> _texture;
|
|
|
|
osg::ref_ptr<osg::Image> _image;
|
|
|
|
GLenum _imageReadPixelFormat;
|
|
|
|
GLenum _imageReadPixelDataType;
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::FrameBufferObject> _fbo;
|
2001-09-20 05:19:47 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-09-20 05:19:47 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|