Fixed unref image so it only unref's when images are STATIC

This commit is contained in:
Robert Osfield
2004-07-27 13:24:35 +00:00
parent 2e524ed9d7
commit 654764a0e9
5 changed files with 19 additions and 7 deletions

View File

@@ -152,7 +152,7 @@ void Texture1D::apply(State& state) const
// update the modified tag to show that it is upto date.
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{
Texture1D* non_const_this = const_cast<Texture1D*>(this);
non_const_this->_image = 0;

View File

@@ -188,7 +188,7 @@ void Texture2D::apply(State& state) const
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{
Texture2D* non_const_this = const_cast<Texture2D*>(this);
non_const_this->_image = 0;

View File

@@ -168,7 +168,7 @@ void Texture3D::apply(State& state) const
// update the modified tag to show that it is upto date.
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{
Texture3D* non_const_this = const_cast<Texture3D*>(this);
non_const_this->_image = 0;

View File

@@ -284,12 +284,15 @@ void TextureCubeMap::apply(State& state) const
}
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
{
TextureCubeMap* non_const_this = const_cast<TextureCubeMap*>(this);
for (int n=0; n<6; n++)
{
non_const_this->_images[n] = 0;
{
if (_images[n].valid() && _images[n]->getDataVariance()==STATIC)
{
non_const_this->_images[n] = 0;
}
}
}

View File

@@ -36,6 +36,8 @@ TextureRectangle::TextureRectangle():
_textureWidth(0),
_textureHeight(0)
{
osg::notify(osg::NOTICE)<<"TextureRectangle::TextureRectangle() "<<this<<std::endl;
setWrap(WRAP_S, CLAMP);
setWrap(WRAP_T, CLAMP);
@@ -47,6 +49,8 @@ TextureRectangle::TextureRectangle(Image* image):
_textureWidth(0),
_textureHeight(0)
{
osg::notify(osg::NOTICE)<<"TextureRectangle::TextureRectangle(Image*) "<<this<<std::endl;
setWrap(WRAP_S, CLAMP);
setWrap(WRAP_T, CLAMP);
@@ -134,6 +138,7 @@ void TextureRectangle::apply(State& state) const
if (textureObject != 0)
{
textureObject->bind();
if (getTextureParameterDirty(state.getContextID()))
applyTexParameters(GL_TEXTURE_RECTANGLE, state);
@@ -182,7 +187,7 @@ void TextureRectangle::apply(State& state) const
textureObject->setAllocated(1,_internalFormat,_textureWidth,_textureHeight,1,0);
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && _image->getDataVariance()==STATIC)
{
TextureRectangle* non_const_this = const_cast<TextureRectangle*>(this);
non_const_this->_image = 0;
@@ -212,6 +217,8 @@ void TextureRectangle::applyTexParameters(GLenum target, State& state) const
void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const
{
// if we don't have a valid image we can't create a texture!
osg::notify(osg::NOTICE)<<"TextureRectangle::applyTexImage_load "<<this<<std::endl;
if (!image || !image->data())
return;
@@ -257,6 +264,8 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight, GLint& inInternalFormat) const
{
osg::notify(osg::NOTICE)<<"TextureRectangle::applyTexImage_subload "<<this<<std::endl;
// if we don't have a valid image we can't create a texture!
if (!image || !image->data())
return;