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:
@@ -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?!!
|
||||
|
||||
Reference in New Issue
Block a user