Added setImageReadFormat and setImageReadDataType methods to RenderToTextureStage to

allow customization of what format/data type to read such as reading from the depth buffer etc.
This commit is contained in:
Robert Osfield 2005-01-09 19:30:56 +00:00
parent 341267d898
commit 728b8c9301
2 changed files with 11 additions and 1 deletions

View File

@ -45,6 +45,12 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
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; }
virtual void draw(osg::State& state,RenderLeaf*& previous);
@ -57,6 +63,8 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
osg::ref_ptr<osg::Texture2D> _texture;
osg::ref_ptr<osg::Image> _image;
GLenum _imageReadPixelFormat;
GLenum _imageReadPixelDataType;
};

View File

@ -20,6 +20,8 @@ using namespace osgUtil;
RenderToTextureStage::RenderToTextureStage()
{
_imageReadPixelFormat = GL_RGBA;
_imageReadPixelDataType = GL_UNSIGNED_BYTE;
}
RenderToTextureStage::~RenderToTextureStage()
@ -49,6 +51,6 @@ void RenderToTextureStage::draw(osg::State& state,RenderLeaf*& previous)
}
if (_image.valid())
_image->readPixels(_viewport->x(),_viewport->y(),_viewport->width(),_viewport->height(),GL_RGBA,GL_UNSIGNED_BYTE);
_image->readPixels(_viewport->x(),_viewport->y(),_viewport->width(),_viewport->height(),_imageReadPixelFormat,_imageReadPixelDataType);
}