OpenSceneGraph/include/osgUtil/RenderToTextureStage

75 lines
2.5 KiB
Plaintext
Raw Normal View History

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
*
* 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-09-20 05:19:47 +08:00
#ifndef OSGUTIL_RENDERTOTEXTURESTAGE
#define OSGUTIL_RENDERTOTEXTURESTAGE 1
#include <osg/Texture2D>
2001-09-20 05:19:47 +08:00
#include <osgUtil/RenderStage>
namespace osgUtil {
/**
* 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();
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; }
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();
void setTexture(osg::Texture2D* texture) { _texture = texture; }
osg::Texture2D* getTexture() { return _texture.get(); }
2001-09-20 05:19:47 +08:00
void setImage(osg::Image* image) { _image = image; }
osg::Image* getImage() { return _image.get(); }
void setImageReadPixelFormat(GLenum format) { _imageReadPixelFormat = format; }
GLenum getImageReadPixelFormat() const { return _imageReadPixelFormat; }
void setImageReadPixelDataType(GLenum type) { _imageReadPixelDataType = type; }
GLenum getImageReadPixelDataType() const { return _imageReadPixelDataType; }
2001-09-20 05:19:47 +08:00
virtual void draw(osg::State& state,RenderLeaf*& previous);
public:
protected:
virtual ~RenderToTextureStage();
osg::ref_ptr<osg::Texture2D> _texture;
osg::ref_ptr<osg::Image> _image;
GLenum _imageReadPixelFormat;
GLenum _imageReadPixelDataType;
2001-09-20 05:19:47 +08:00
};
}
2001-09-20 05:19:47 +08:00
#endif