1
0
Fork 0

Expose OSG notify severity at runtime.

Define a new property /sim/rendering/osg-notify-level and listen
to it, so we can update the notification level at run time.
This commit is contained in:
James Turner 2013-10-20 09:44:38 +01:00
parent 80fb317eeb
commit 46e8c65612

View file

@ -29,6 +29,8 @@
#include <stdlib.h> #include <stdlib.h>
// Boost
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <simgear/compiler.h> #include <simgear/compiler.h>
@ -217,11 +219,41 @@ private:
} }
}; };
class NotifyLevelListener : public SGPropertyChangeListener
{
public:
void valueChanged(SGPropertyNode* node)
{
osg::NotifySeverity severity = osg::WARN;
string val = boost::to_lower_copy(string(node->getStringValue()));
if (val == "fatal") {
severity = osg::FATAL;
} else if (val == "warn") {
severity = osg::WARN;
} else if (val == "notice") {
severity = osg::NOTICE;
} else if (val == "info") {
severity = osg::INFO;
} else if ((val == "debug") || (val == "debug-info")) {
severity = osg::DEBUG_INFO;
}
osg::setNotifyLevel(severity);
}
};
void updateOSGNotifyLevel()
{
}
void fgOSOpenWindow(bool stencil) void fgOSOpenWindow(bool stencil)
{ {
osg::setNotifyHandler(new NotifyLogger); osg::setNotifyHandler(new NotifyLogger);
//osg::setNotifyLevel(osg::DEBUG_INFO);
SGPropertyNode* osgLevel = fgGetNode("/sim/rendering/osg-notify-level", true);
osgLevel->addChangeListener(new NotifyLevelListener, true);
viewer = new osgViewer::Viewer; viewer = new osgViewer::Viewer;
viewer->setDatabasePager(FGScenery::getPagerSingleton()); viewer->setDatabasePager(FGScenery::getPagerSingleton());
CameraGroup* cameraGroup = 0; CameraGroup* cameraGroup = 0;