From 2cb360dd38bd1549bbbafa82104a1f352afb4bd9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 27 Dec 2003 11:30:41 +0000 Subject: [PATCH] From Rommano Silva, admendments to Texture::computeRequiredTextureDimensions so that it takes into account the current mip map settings. --- src/osg/Texture.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index c4905da25..1411cbea0 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -516,20 +516,31 @@ void Texture::computeRequiredTextureDimensions(State& state, const osg::Image& i inwidth = width; inheight = height; - numMipmapLevels = 0; - - for( ; (width || height) ;++numMipmapLevels) + bool useHardwareMipMapGeneration = !image.isMipmap() && _useHardwareMipMapGeneration && extensions->isGenerateMipMapSupported(); + + if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration ) { + numMipmapLevels = 1; + } + else if( image.isMipmap() ) + { + numMipmapLevels = image.getNumMipmapLevels(); + } + else + { + numMipmapLevels = 0; + for( ; (width || height) ;++numMipmapLevels) + { - if (width == 0) - width = 1; - if (height == 0) - height = 1; + if (width == 0) + width = 1; + if (height == 0) + height = 1; - - width >>= 1; - height >>= 1; - } + width >>= 1; + height >>= 1; + } + } } bool Texture::areAllTextureObjectsLoaded() const