From edce2211fa72c62c1f8cb0ce5f006b5eef43cea2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Jan 2004 13:25:45 +0000 Subject: [PATCH] From Romano Magacho, fixes to handle the subloading from Image when the internal format changes requiring a rebuild of the texture object. --- include/osg/Texture | 2 +- include/osg/TextureRectangle | 2 +- include/osgDB/DatabasePager | 1 + src/osg/Texture.cpp | 5 ++--- src/osg/Texture2D.cpp | 4 ++-- src/osg/TextureCubeMap.cpp | 4 ++-- src/osg/TextureRectangle.cpp | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/osg/Texture b/include/osg/Texture index 6530fdce3..493f1f950 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -366,7 +366,7 @@ class SG_EXPORT Texture : public osg::StateAttribute /** Helper method which subloads images to the texture itself, but does not set or use texture binding. * Note, do not call this method directly unless you are implementing your own Subload callback*/ - void applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height,GLsizei numMipmapLevels) const; + void applyTexImage2D_subload(State& state, GLenum target, const Image* image, GLsizei width, GLsizei height, GLint inInternalFormat, GLsizei numMipmapLevels) const; protected : diff --git a/include/osg/TextureRectangle b/include/osg/TextureRectangle index 1d888e735..7b5977e97 100644 --- a/include/osg/TextureRectangle +++ b/include/osg/TextureRectangle @@ -97,7 +97,7 @@ class SG_EXPORT TextureRectangle : public Texture void applyTexParameters(GLenum target, State& state) const; void applyTexImage_load(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const; - void applyTexImage_subload(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight) const; + void applyTexImage_subload(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& inheight, GLint& inInternalFormat) const; // not ideal that _image is mutable, but its required since // Image::ensureDimensionsArePowerOfTwo() can only be called diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 14f244848..d0dffaf78 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -98,6 +98,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl /** Get the whether UseFrameBlock is on or off.*/ bool getUseFrameBlock() const { return _useFrameBlock; } + Block* getFrameBlock() { return _frameBlock.get(); } /** Set the priority of the database pager thread during the frame (i.e. while cull and draw are running.)*/ void setThreadPriorityDuringFrame(ThreadPriority duringFrame) { _threadPriorityDuringFrame = duringFrame; } diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index b6c0100b0..063f68a5c 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -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; } diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index a169ebb39..1683bde84 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -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"<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 { diff --git a/src/osg/TextureRectangle.cpp b/src/osg/TextureRectangle.cpp index 9408773d9..2aa2a3d9c 100644 --- a/src/osg/TextureRectangle.cpp +++ b/src/osg/TextureRectangle.cpp @@ -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;