Hi,
I can confirm that it is working correctly on MS Visual C++ 2005 and 2010. Platform is Win7

cheers
Sebastian
Hi,

I just tried the compilation of my test code on Microsoft Visual C++, and the problem does not appear so it seems gcc linked... I will try to recompile OSG on my different platforms using cmath in osg/Math, hoping we don't see any other bugs.
Will keep you informed later today.

Christian


Le 09/01/2013 20:41, Jason Daly a écrit :

I was about to ask why we aren't just using the log2 function here, but apparently Microsoft doesn't consider this C99-standard function to be important (ie: it's not included in Microsoft's math.h).

Seems like cmath is indeed the best solution.

--"J"


On 01/09/2013 11:39 AM, Christian Schulte wrote:
Hi Robert,

I think the problem is linked indeed to a MS math.h problem, but in my
opinion it is not linked directly to the floor function but could affect even other functions. I don't know what would be the consequences on the
global OSG behaviour but I agree with you that replacing the math.h
include would be the best solution.
Maybe someone could try to compile my little test code with a Microsoft
compiler to see if it is gcc linked or Windows linked.

Cheers,

Christian

Le 09/01/2013 16:50, Robert Osfield a écrit :
Hi Christian,

Does this mean there is a bug in the MS version of math.h and the
floor function it provides?

Previously we haven't used cmath as some platforms didn't support it
properly, I recall IRIX being a problem, but am not sure if it extends
further than this.  IRIX support has long been deprecated so won't be
a constraint these days.  So... using #include<cmath> could well be a
viable solution,

It does still concern me that the MS version of math.h is giving
different results to cmath.

Robert.

On 9 January 2013 15:27, Christian Schulte<christian.schu...@onera.fr> wrote:
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




Le 20/12/2012 15:15, Lukasz Izdebski a écrit :

Hi,
i probably have solution for this problem, i have found a bug in dds plugin
ReaderWriterDDS.cpp
Line 633
unsigned numMipmaps = osg::Image::computeNumberOfMipmapLevels( s, t, r );

when compute numMipmaps returns wrong number. this number is less then number of mipmaps in dds file( ddsd.dwMipMapCount ) . This bug makes that when dds mipmaps are loaded to opengl last mipmap (4x4) isn't loaded. and
with combination with LINEAR_MIPMAP_LINEAR make this bug.


the numMipmaps should be taken form ddsd.dwMipMapCount


in attachment i send a corrected version of file.
...

Thank you!

Cheers,
Lukasz

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=51653#51653




Attachments:
http://forum.openscenegraph.org//files/readerwriterdds_204.cpp


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to