Show Text on Main View

classic Classic list List threaded Threaded
2 messages Options
marcoma9023 marcoma9023
Reply | Threaded
Open this post in threaded view
|

Show Text on Main View

Hi Guys,

quick question: if I want to put an osgText or osg :: Geode on the main view (like a widget), what would be the correct way?

I tried to create some text and pass it to the root node, like below, but it doesn't show ...

osg::ref_ptr<osgText::Text> text = new osgText::Text;
text->setFont("fonts/times.ttf");
text->setAxisAlignment(osgText::Text::XZ_PLANE);
text->setText("Alingment\nAfter:");
text->setAlignment(osgText::Text::LEFT_TOP);

osg::Group* root = new osg::Group();
root->addChild(text);
root->getOrCreateStateSet()->setDefine(OE_LIGHTING_DEFINE, osg::StateAttribute::OFF |
osg::StateAttribute::PROTECTED);

g_viewer->setSceneData(root);

Solution?
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Show Text on Main View

Check out the osgtext example in the OSG repository:

https://github.com/openscenegraph/OpenSceneGraph/blob/master/examples/osgtext/osgtext.cpp

Hope this helps.
Glenn Waldron / Pelican Mapping