From f26be0155c104ca53bd600eb216f29a24c14ded5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 1 Apr 2015 09:37:53 +0000 Subject: [PATCH] From Lionel Largarde, "fix for the Image::computeNumberOfMipmapLevels method. The method did use the float version of the log function and the / operator. It works for most of the input sizes, but fails for 8192, 32768... For 8192, the method returns 13 instead of 14." git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14815 16af8721-9629-0410-8352-f15c8da7e697 --- src/osg/Image.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 195ec8a60..1909fd336 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -799,7 +799,11 @@ int Image::computeNumberOfMipmapLevels(int s,int t, int r) { int w = maximum(s, t); w = maximum(w, r); - return 1 + static_cast(floor(logf(w)/logf(2.0f))); + + int n = 0; + while (w >>= 1) + ++n; + return n+1; } bool Image::isCompressed() const