Hi David,
Ooopps!! I forgot the "-Wl, -E", well I attach you another test.
The problem I have here is that the viewer is not a referenced
object and the variant cast returns it as a valid pointer:
vec3 = 0
viewer(variant_cast) = 0xbfb3aba4
viewer(dynamic_cast) = 0
group (variant_cast)= 0x82149b8
group (dynamic_cast) = 0x82149b8
the viewer gets converted to a Referenced through variant_cast... and
is not correct.
Cheers,
Jose L.
On 10/17/06, david callu <[EMAIL PROTECTED]> wrote:
1) under linux, use the -Wl,-E in the link line
2) under windows, i use visual studio 8.0 and the
osgIntrospection::variant_cast call could not compile
the compilator give an obscure error, i use
osgIntrospection::getInstance instead
I don'l like window sufficiently to look for the problem and find an
explication
if you use the -Wl,-E option the exception is not throw.
see the example file joint with the mail
There are something wrong in osgUtil ...
compile line : g++ -W -Wall -Wl,-E
osgintrospection_variant_cast.cpp -losgIntrospection -losg
-losgDB
--
Jose L. Hidalgo ValiƱo (PpluX)
---- http://www.pplux.com ----
#include <osgIntrospection/Value>
#include <osgIntrospection/variant_cast>
#include <osgIntrospection/Exceptions>
#include <osg/Vec3>
#include <osg/Referenced>
#include <osg/Group>
#include <osgProducer/Viewer>
#include <osgDB/DynamicLibrary>
#include <osg/io_utils>
// borrowed from osgDB...
std::string createLibraryNameForWrapper(const std::string& ext)
{
#if defined(WIN32)
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
#ifdef __CYGWIN__
return "cygosgwrapper_"+ext+".dll";
#elif defined(__MINGW32__)
return "libosgwrapper_"+ext+".dll";
#else
#ifdef _DEBUG
return "osgwrapper_"+ext+"d.dll";
#else
return "osgwrapper_"+ext+".dll";
#endif
#endif
#elif macintosh
return "osgwrapper_"+ext;
#elif defined(__hpux__)
// why don't we use PLUGIN_EXT from the makefiles here?
return "osgwrapper_"+ext+".sl";
#else
return "osgwrapper_"+ext+".so";
#endif
}
osgDB::DynamicLibrary *load(const std::string &name)
{
std::cout << "loading ... " << name << std::endl;
return osgDB::DynamicLibrary::loadLibrary(
createLibraryNameForWrapper(name)
);
}
int main()
{
osg::ref_ptr<osgDB::DynamicLibrary> osg_lib = load("osg");
osg::ref_ptr<osgDB::DynamicLibrary> osgProducer_lib = load("osgProducer");
std::cout << "osg = " << osg_lib.valid() << std::endl;
std::cout << "osgProducer = " << osgProducer_lib.valid() << std::endl;
osg::Vec3 v3;
osgProducer::Viewer viewer;
osg::ref_ptr<osg::Group> group = new osg::Group();
{
osgIntrospection::Value v(v3);
std::cout << "vec3 = " << osgIntrospection::variant_cast<osg::Referenced*>(v) << std::endl;
}
{
osgIntrospection::Value v(&viewer);
std::cout << "viewer(variant_cast) = " << osgIntrospection::variant_cast<osg::Referenced*>(v) << std::endl;
std::cout << "viewer(dynamic_cast) = " << dynamic_cast<osg::Referenced*>(&viewer) << std::endl;
}
{
osgIntrospection::Value v(group.get());
std::cout << "group (variant_cast)= " << osgIntrospection::variant_cast<osg::Referenced*>(v) << std::endl;
std::cout << "group (dynamic_cast) = " << dynamic_cast<osg::Referenced*>(group.get()) << std::endl;
}
return 0;
}
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/