ee8f7bb756
Added support for Texture1D, 2D, 3D and TextureRectangle into osgUtil::RenderToTextureStage.
97 lines
3.7 KiB
C++
97 lines
3.7 KiB
C++
/* -*-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.
|
|
*/
|
|
|
|
#ifndef OSGUTIL_RENDERTOTEXTURESTAGE
|
|
#define OSGUTIL_RENDERTOTEXTURESTAGE 1
|
|
|
|
#include <osg/Texture>
|
|
#include <osg/FrameBufferObject>
|
|
#include <osg/CameraNode>
|
|
|
|
#include <osgUtil/RenderStage>
|
|
|
|
namespace osgUtil {
|
|
|
|
/**
|
|
* RenderStage which copies the final image to an attached texture or image.
|
|
* Generally used as a pre-rendering stage.
|
|
*/
|
|
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.
|
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
|
|
virtual const char* libraryName() const { return "osgUtil"; }
|
|
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::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(); }
|
|
|
|
void setImageReadPixelFormat(GLenum format) { _imageReadPixelFormat = format; }
|
|
GLenum getImageReadPixelFormat() const { return _imageReadPixelFormat; }
|
|
|
|
void setImageReadPixelDataType(GLenum type) { _imageReadPixelDataType = type; }
|
|
GLenum getImageReadPixelDataType() const { return _imageReadPixelDataType; }
|
|
|
|
|
|
void setFrameBufferObject(osg::FrameBufferObject* fbo) { _fbo = fbo; }
|
|
osg::FrameBufferObject* getFrameBufferObject() { return _fbo.get(); }
|
|
const osg::FrameBufferObject* getFrameBufferObject() const { return _fbo.get(); }
|
|
|
|
void setGraphicsContext(osg::GraphicsContext* context) { _graphicsContext = context; }
|
|
osg::GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
|
|
const osg::GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
|
|
|
|
virtual void draw(osg::State& state,RenderLeaf*& previous);
|
|
|
|
public:
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~RenderToTextureStage();
|
|
|
|
const osg::CameraNode* _camera;
|
|
|
|
osg::ref_ptr<osg::Texture> _texture;
|
|
unsigned int _level;
|
|
unsigned int _face;
|
|
|
|
osg::ref_ptr<osg::Image> _image;
|
|
GLenum _imageReadPixelFormat;
|
|
GLenum _imageReadPixelDataType;
|
|
|
|
osg::ref_ptr<osg::FrameBufferObject> _fbo;
|
|
osg::ref_ptr<osg::GraphicsContext> _graphicsContext;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
|
|