diff --git a/examples/osgtext/osgtext.cpp b/examples/osgtext/osgtext.cpp index 4fefec7fc..34926b383 100644 --- a/examples/osgtext/osgtext.cpp +++ b/examples/osgtext/osgtext.cpp @@ -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(node); + if (text) + { + + std::stringstream str; + str <<"Text Counter "<<_textCounter<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 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.