Added support for unref image data after apply in the osg::Texture*

classes.  Only unref's after all graphics context have been applied.
This commit is contained in:
Robert Osfield
2003-04-07 12:51:00 +00:00
parent 0df1b28672
commit 9f0fa75484
8 changed files with 102 additions and 5 deletions

View File

@@ -147,6 +147,22 @@ void Texture2D::apply(State& state) const
// update the modified tag to show that it is upto date.
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply)
{
// only unref image once all the graphics contexts has been set up.
int numLeftToBind=0;
for(int i=0;i<DisplaySettings::instance()->getMaxNumberOfGraphicsContexts();++i)
{
if (_handleList[i]==0) ++numLeftToBind;
}
if (numLeftToBind==0)
{
Texture2D* non_const_this = const_cast<Texture2D*>(this);
non_const_this->_image = 0;
}
}
// in theory the following line is redundent, but in practice
// have found that the first frame drawn doesn't apply the textures
// unless a second bind is called?!!