From 83e47c0de60012d67c5bab70af2eb33a7e083c98 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 2 Jun 2009 08:53:21 +0000 Subject: [PATCH] Moved assigned of texture object to _textureObjectBuffer to earlier in Texture2D::apply() to prevent problems with non power of two texture mipmap generation. --- src/osg/Texture2D.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 1f545e316..b8ebe846c 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -194,14 +194,13 @@ void Texture2D::apply(State& state) const // compute the internal texture format, this set the _internalFormat to an appropriate value. computeInternalFormat(); - + // compute the dimensions of the texture. computeRequiredTextureDimensions(state,*image,_textureWidth, _textureHeight, _numMipmapLevels); - - - textureObject = generateTextureObject( + + _textureObjectBuffer[contextID] = textureObject = generateTextureObject( contextID,GL_TEXTURE_2D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0); - + textureObject->bind(); applyTexParameters(GL_TEXTURE_2D,state); @@ -217,16 +216,13 @@ void Texture2D::apply(State& state) const //notify(NOTICE)<<"Creating new texture object"<setAllocated(true); } - - + // update the modified tag to show that it is upto date. getModifiedCount(contextID) = image->getModifiedCount(); - _textureObjectBuffer[contextID] = textureObject; - if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && image->getDataVariance()==STATIC) { Texture2D* non_const_this = const_cast(this);