Hi all,
Playing with osgIntrospection I found a problem with osgText, It
fails when I try to call setFont method with a std::string. Here is
attached an example, as usual :) I'm working with osg of the CVS
(updated yesterday)
Cheers,
Jose L.
--
Jose L. Hidalgo ValiƱo (PpluX)
---- http://www.pplux.com ----
// g++ osgText_setFont.cpp -W -Wall -losg -losgDB -losgIntrospection -Wl,-E
#include <osgIntrospection/Value>
#include <osgIntrospection/MethodInfo>
#include <osgIntrospection/variant_cast>
#include <osgIntrospection/Exceptions>
#include <osg/Referenced>
#include <osg/Group>
#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)
);
}
using namespace osgIntrospection;
int main()
{
osg::ref_ptr<osgDB::DynamicLibrary> osg_lib = load("osg");
osg::ref_ptr<osgDB::DynamicLibrary> osgProducer_lib = load("osgText");
// get the type
std::cout << "find type osgText" << std::endl;
const Type &type = Reflection::getType("osgText::Text");
// create an instance
std::cout << "find type osgText" << std::endl;
Value text = type.createInstance();
{ // Get the method (1)
ValueList vl;
vl.push_back(Value(std::string("The text")));
std::cout << "get method setText" << std::endl;
const MethodInfo *method = type.getCompatibleMethod("setText",vl, true);
// call
if (method)
{
method->invoke(text, vl);
std::cout << "method executed" << std::endl;
}
}
{ // Get the method (2)
ValueList vl;
vl.push_back(Value(std::string("fonts/arial.ttf")));
std::cout << "get method setFont" << std::endl;
const MethodInfo *method = type.getCompatibleMethod("setFont",vl, true);
// call
if (method)
{
method->invoke(text, vl);
std::cout << "method executed" << std::endl;
}
}
return 0;
}
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/