Hi all,
I have investigated a little deeper the problem... Indeed, on
Windows platform, the number of mipmaps returned by
osg::Image::computeNumberOfMipmapLevels( s, t, r ) is wrong, but
it is correct on Linux platforms for the same dds file...
Here is attached a little test program that explains why (it is
more or less a computeNumberOfMipmapLevels with s=t=1024 and r=1),
and it is not linked to OSG. Compile it on Windows 32 bits (works
on Win7 and WinXP) (g++ main.cpp -o main.exe) You will see the
following result :
logf(wf) = 6.93147182464599609375
log(wd) = 6.93147180559945308431
logf(2.0f) = 0.69314718246459960938
log(2.0) = 0.69314718055994528623
logf(wf)/logf(2.0f) = 10.00000000000000000000
log(wd)/log(2.0) = 10.00000000000000000000
floor(logf(wf)/logf(2.0f)) = 9.00000000000000000000 -> Here
is the error, it should be 10 too...
floor(log(wd)/log(2.0)) = 10.00000000000000000000
floor(testf) = 10.00000000000000000000
floor(testd) = 10.00000000000000000000
Replacing the include of math.h by cmath results in :
logf(wf) = 6.93147182464599609375
log(wd) = 6.93147180559945308431
logf(2.0f) = 0.69314718246459960938
log(2.0) = 0.69314718055994528623
logf(wf)/logf(2.0f) = 10.00000000000000000000
log(wd)/log(2.0) = 10.00000000000000000000
floor(logf(wf)/logf(2.0f)) = 10.00000000000000000000
floor(log(wd)/log(2.0)) = 10.00000000000000000000
floor(testf) = 10.00000000000000000000
floor(testd) = 10.00000000000000000000
Under Linux both solutions give the second results.
The problem is that osg/Math includes math.h and not cmath. I
don't know which would be the best solution :
- Replace math.h by cmath in include/osg/Math
- Store the logf division (float testf = logf(wf)/logf(2.0f))
of osg::Image::computeNumberOfMipmapLevels( s, t, r ) in a
float before computing the floor.
Up to the list to give the answer...
PS : this is also the solution to the discussion "osgPlugins :
dds problem on windows platform" I launched 07/03/2011
Cheers,
Christian Schulte