Moved the modified tag's from osg::Texture into the osg::Texture1D,2D,3D and
CubeMap classes.
This commit is contained in:
@@ -379,16 +379,11 @@ void Texture::applyTexImage2D_load(GLenum target, const Image* image, State& sta
|
||||
|
||||
bool generateMipMapSupported = extensions->isGenerateMipMapSupported();
|
||||
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = image->getModifiedTag();
|
||||
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
computeInternalFormat();
|
||||
|
||||
// select the internalFormat required for the texture.
|
||||
bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
|
||||
; bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
|
||||
|
||||
@@ -592,11 +587,6 @@ void Texture::applyTexImage2D_subload(GLenum target, const Image* image, State&
|
||||
|
||||
bool generateMipMapSupported = extensions->isGenerateMipMapSupported();
|
||||
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = image->getModifiedTag();
|
||||
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
computeInternalFormat();
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ void Texture1D::setImage(Image* image)
|
||||
dirtyTextureObject();
|
||||
|
||||
_image = image;
|
||||
_modifiedTag.setAllElementsTo(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +108,9 @@ void Texture1D::apply(State& state) const
|
||||
else if (_image.valid() && getModifiedTag(contextID) != _image->getModifiedTag())
|
||||
{
|
||||
applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMimpmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,6 +141,10 @@ void Texture1D::apply(State& state) const
|
||||
|
||||
applyTexImage1D(GL_TEXTURE_1D,_image.get(),state, _textureWidth, _numMimpmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
|
||||
|
||||
// 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?!!
|
||||
@@ -165,9 +174,6 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = image->getModifiedTag();
|
||||
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
computeInternalFormat();
|
||||
|
||||
@@ -80,13 +80,8 @@ int Texture2D::compare(const StateAttribute& sa) const
|
||||
|
||||
void Texture2D::setImage(Image* image)
|
||||
{
|
||||
// delete old texture objects.
|
||||
// dirtyTextureObject();
|
||||
|
||||
// replace dirtyTextureObject() with reseting the modified tag.
|
||||
_modifiedTag.setAllElementsTo(0);
|
||||
|
||||
_image = image;
|
||||
_modifiedTag.setAllElementsTo(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +109,10 @@ void Texture2D::apply(State& state) const
|
||||
{
|
||||
applyTexImage2D_subload(GL_TEXTURE_2D,_image.get(),state,
|
||||
_textureWidth, _textureHeight, _numMimpmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -145,6 +144,9 @@ void Texture2D::apply(State& state) const
|
||||
applyTexImage2D_load(GL_TEXTURE_2D,_image.get(),state,
|
||||
_textureWidth, _textureHeight, _numMimpmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
|
||||
// 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?!!
|
||||
|
||||
@@ -88,6 +88,8 @@ void Texture3D::setImage(Image* image)
|
||||
// delete old texture objects.
|
||||
dirtyTextureObject();
|
||||
|
||||
_modifiedTag.setAllElementsTo(0);
|
||||
|
||||
_image = image;
|
||||
}
|
||||
|
||||
@@ -123,6 +125,9 @@ void Texture3D::apply(State& state) const
|
||||
else if (_image.get() && getModifiedTag(contextID) != _image->getModifiedTag())
|
||||
{
|
||||
applyTexImage3D(GL_TEXTURE_3D,_image.get(),state, _textureWidth, _textureHeight, _textureDepth,_numMimpmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -153,6 +158,9 @@ void Texture3D::apply(State& state) const
|
||||
|
||||
applyTexImage3D(GL_TEXTURE_3D,_image.get(),state, _textureWidth, _textureHeight, _textureDepth,_numMimpmapLevels);
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||
|
||||
// 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?!!
|
||||
@@ -181,12 +189,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
|
||||
// update the modified tag to show that it is upto date.
|
||||
getModifiedTag(contextID) = image->getModifiedTag();
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
// compute the internal texture format, this set the _internalFormat to an appropriate value.
|
||||
computeInternalFormat();
|
||||
|
||||
@@ -107,6 +107,13 @@ TextureCubeMap::TextureCubeMap(const TextureCubeMap& text,const CopyOp& copyop):
|
||||
_images[4] = copyop(text._images[4].get());
|
||||
_images[5] = copyop(text._images[5].get());
|
||||
|
||||
_modifiedTag[0].setAllElementsTo(0);
|
||||
_modifiedTag[1].setAllElementsTo(0);
|
||||
_modifiedTag[2].setAllElementsTo(0);
|
||||
_modifiedTag[3].setAllElementsTo(0);
|
||||
_modifiedTag[4].setAllElementsTo(0);
|
||||
_modifiedTag[5].setAllElementsTo(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +167,7 @@ void TextureCubeMap::setImage( Face face, Image* image)
|
||||
{
|
||||
dirtyTextureObject();
|
||||
_images[face] = image;
|
||||
_modifiedTag[face].setAllElementsTo(0);
|
||||
}
|
||||
|
||||
Image* TextureCubeMap::getImage(Face face)
|
||||
@@ -211,6 +219,15 @@ void TextureCubeMap::apply(State& state) const
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int n=0; n<6; n++)
|
||||
{
|
||||
osg::Image* image = _images[n].get();
|
||||
if (image && getModifiedTag((Face)n,contextID) != image->getModifiedTag())
|
||||
{
|
||||
applyTexImage2D_subload( faceTarget[n], _images[n].get(), state, _textureWidth, _textureHeight, _numMimpmapLevels);
|
||||
getModifiedTag((Face)n,contextID) = image->getModifiedTag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -245,6 +262,15 @@ void TextureCubeMap::apply(State& state) const
|
||||
applyTexImage2D_load( faceTarget[n], _images[n].get(), state, _textureWidth, _textureHeight, _numMimpmapLevels);
|
||||
}
|
||||
|
||||
for (int n=0; n<6; n++)
|
||||
{
|
||||
osg::Image* image = _images[n].get();
|
||||
if (image)
|
||||
{
|
||||
applyTexImage2D_load( faceTarget[n], _images[n].get(), state, _textureWidth, _textureHeight, _numMimpmapLevels);
|
||||
getModifiedTag((Face)n,contextID) = image->getModifiedTag();
|
||||
}
|
||||
}
|
||||
|
||||
// in theory the following line is redundent, but in practice
|
||||
// have found that the first frame drawn doesn't apply the textures
|
||||
|
||||
Reference in New Issue
Block a user