diff --git a/include/osg/Texture b/include/osg/Texture index d3e7f156f..231d79a47 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -415,6 +416,12 @@ class OSG_EXPORT Texture : public osg::StateAttribute virtual unsigned int getNumImages() const = 0; + /** Set the PBuffer graphis context to read from when using PBuffers for RenderToTexture.*/ + void setReadPBuffer(GraphicsContext* context) { _readPBuffer = context; } + + /** Get the PBuffer graphis context to read from when using PBuffers for RenderToTexture.*/ + GraphicsContext* getReadPBuffer() { return _readPBuffer.get(); } + /** Texture is a pure virtual base class, apply must be overriden. */ virtual void apply(State& state) const = 0; @@ -725,8 +732,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute protected: typedef buffered_object< ref_ptr > TextureObjectBuffer; - mutable TextureObjectBuffer _textureObjectBuffer; - + mutable TextureObjectBuffer _textureObjectBuffer; + mutable ref_ptr _readPBuffer; }; diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 8727c9df4..832610289 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -134,6 +134,10 @@ void Texture2D::apply(State& state) const getModifiedCount(contextID) = _image->getModifiedCount(); } + else if (_readPBuffer.valid()) + { + _readPBuffer->bindPBufferToTexture(GL_FRONT); + } } else if (_subloadCallback.valid()) @@ -221,6 +225,12 @@ void Texture2D::apply(State& state) const _internalFormat, GL_UNSIGNED_BYTE, 0); + + if (_readPBuffer.valid()) + { + _readPBuffer->bindPBufferToTexture(GL_FRONT); + } + } else {