Added --counter test

This commit is contained in:
Robert Osfield 2017-03-07 13:35:03 +00:00
parent fee826412c
commit 9b32395772

View File

@ -682,6 +682,31 @@ public:
};
struct TextCounterCallback : public osg::NodeCallback
{
unsigned int _textCounter;
TextCounterCallback():
_textCounter(100000) {}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osgText::Text* text = dynamic_cast<osgText::Text*>(node);
if (text)
{
std::stringstream str;
str <<"Text Counter "<<_textCounter<<std::endl;
OSG_NOTICE<<"Udating text"<<str.str()<<std::endl;
text->setText(str.str());
++_textCounter;
}
}
};
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
@ -714,6 +739,16 @@ int main(int argc, char** argv)
viewer.setSceneData(text.get());
}
else if (arguments.read("--counter"))
{
osg::ref_ptr<osgText::Text> text = new osgText::Text;
text->setUpdateCallback(new TextCounterCallback());
text->setFont("fonts/times.ttf");
text->setAxisAlignment(osgText::Text::XZ_PLANE);
text->setText("This is a counter test");
viewer.setSceneData(text.get());
}
else if (arguments.read("--mt", numThreads) || arguments.read("--mt"))
{
// construct a multi-threaded text updating test.