Added graphics context pointer to osg::Texture in prep for support for Pbuffer

Render To Texture.
This commit is contained in:
Robert Osfield
2005-08-31 12:56:15 +00:00
parent 8686ed3136
commit 7fc95ddae7
2 changed files with 19 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
#include <osg/GL>
#include <osg/Image>
#include <osg/StateAttribute>
#include <osg/GraphicsContext>
#include <osg/ref_ptr>
#include <osg/Vec4>
#include <osg/buffered_value>
@@ -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<TextureObject> > TextureObjectBuffer;
mutable TextureObjectBuffer _textureObjectBuffer;
mutable TextureObjectBuffer _textureObjectBuffer;
mutable ref_ptr<GraphicsContext> _readPBuffer;
};

View File

@@ -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
{