From Romano Magacho, fixes to handle the subloading from Image when the
internal format changes requiring a rebuild of the texture object.
This commit is contained in:
@@ -741,16 +741,15 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
|
||||
|
||||
|
||||
void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei inwidth, GLsizei inheight,GLsizei numMipmapLevels) const
|
||||
void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei inwidth, GLsizei inheight, GLint inInternalFormat, GLint numMipmapLevels) const
|
||||
{
|
||||
// if we don't have a valid image we can't create a texture!
|
||||
if (!image || !image->data())
|
||||
return;
|
||||
|
||||
// image size has changed so we have to re-load the image from scratch.
|
||||
if (image->s()!=inwidth || image->t()!=inheight)
|
||||
if (image->s()!=inwidth || image->t()!=inheight || image->getInternalTextureFormat()!=inInternalFormat )
|
||||
{
|
||||
|
||||
applyTexImage2D_load(state, target, image, inwidth, inheight,numMipmapLevels);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ void Texture2D::apply(State& state) const
|
||||
else if (_image.valid() && getModifiedTag(contextID) != _image->getModifiedTag())
|
||||
{
|
||||
applyTexImage2D_subload(state,GL_TEXTURE_2D,_image.get(),
|
||||
_textureWidth, _textureHeight, _numMipmapLevels);
|
||||
_textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
@@ -172,7 +172,7 @@ void Texture2D::apply(State& state) const
|
||||
{
|
||||
//std::cout<<"Reusing texture object"<<std::endl;
|
||||
applyTexImage2D_subload(state,GL_TEXTURE_2D,_image.get(),
|
||||
_textureWidth, _textureHeight, _numMipmapLevels);
|
||||
_textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -225,7 +225,7 @@ void TextureCubeMap::apply(State& state) const
|
||||
const osg::Image* image = _images[n].get();
|
||||
if (image && getModifiedTag((Face)n,contextID) != image->getModifiedTag())
|
||||
{
|
||||
applyTexImage2D_subload( state, faceTarget[n], _images[n].get(), _textureWidth, _textureHeight, _numMipmapLevels);
|
||||
applyTexImage2D_subload( state, faceTarget[n], _images[n].get(), _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
|
||||
getModifiedTag((Face)n,contextID) = image->getModifiedTag();
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ void TextureCubeMap::apply(State& state) const
|
||||
{
|
||||
if (textureObject->isAllocated())
|
||||
{
|
||||
applyTexImage2D_subload( state, faceTarget[n], image, _textureWidth, _textureHeight, _numMipmapLevels);
|
||||
applyTexImage2D_subload( state, faceTarget[n], image, _textureWidth, _textureHeight, _internalFormat, _numMipmapLevels);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ void TextureRectangle::apply(State& state) const
|
||||
}
|
||||
else if (_image.valid() && getModifiedTag(contextID) != _image->getModifiedTag())
|
||||
{
|
||||
applyTexImage_subload(GL_TEXTURE_RECTANGLE_NV, _image.get(), state, _textureWidth, _textureHeight);
|
||||
applyTexImage_subload(GL_TEXTURE_RECTANGLE_NV, _image.get(), state, _textureWidth, _textureHeight, _internalFormat);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
@@ -212,13 +212,13 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
|
||||
inheight = image->t();
|
||||
}
|
||||
|
||||
void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const
|
||||
void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight, GLint& inInternalFormat) const
|
||||
{
|
||||
// if we don't have a valid image we can't create a texture!
|
||||
if (!image || !image->data())
|
||||
return;
|
||||
|
||||
if (image->s()!=inwidth || image->t()!=inheight)
|
||||
if (image->s()!=inwidth || image->t()!=inheight || image->getInternalTextureFormat()!=inInternalFormat)
|
||||
{
|
||||
applyTexImage_load(target, image, state, inwidth, inheight);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user