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:
parent
341267d898
commit
728b8c9301
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user