Improved handling of text

This commit is contained in:
Robert Osfield
2014-05-27 14:14:51 +00:00
parent faced0a896
commit 6af9edf33b
2 changed files with 8 additions and 13 deletions

View File

@@ -33,18 +33,10 @@ void Label::createGraphicsImplementation()
{
OSG_NOTICE<<"Label::createGraphicsImplementation()"<<std::endl;
if (_textDrawable.valid())
{
_textDrawable->setText(_text);
_graphicsInitialized = true;
}
else
{
Widget::createGraphicsImplementation();
Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get();
osg::ref_ptr<Node> node = style->createText(_extents, getAlignmentSettings(), getTextSettings(), _text);
_textDrawable = dynamic_cast<osgText::Text*>(node.get());
Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get();
osg::ref_ptr<Node> node = style->createText(_extents, getAlignmentSettings(), getTextSettings(), _text);
_textDrawable = dynamic_cast<osgText::Text*>(node.get());
addChild(node.get());
}
style->setupClipStateSet(_extents, getOrCreateStateSet());
setGraphicsSubgraph(node.get());
}

View File

@@ -88,6 +88,9 @@ osg::Node* Style::createText(const osg::BoundingBox& extents, const AlignmentSet
textDrawable->setText(text);
textDrawable->setPosition( osg::Vec3(extents.xMin(), extents.yMin(), extents.zMin()) );
textDrawable->setEnableDepthWrites(false);
if (ts)
{
textDrawable->setFont(ts->getFont());