From 6af9edf33b22c73fa8cd4c4bb89783ab70783042 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 27 May 2014 14:14:51 +0000 Subject: [PATCH] Improved handling of text --- src/osgUI/Label.cpp | 18 +++++------------- src/osgUI/Style.cpp | 3 +++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/osgUI/Label.cpp b/src/osgUI/Label.cpp index 37c5fe05f..afafae91b 100644 --- a/src/osgUI/Label.cpp +++ b/src/osgUI/Label.cpp @@ -33,18 +33,10 @@ void Label::createGraphicsImplementation() { OSG_NOTICE<<"Label::createGraphicsImplementation()"<setText(_text); - _graphicsInitialized = true; - } - else - { - Widget::createGraphicsImplementation(); + Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get(); + osg::ref_ptr node = style->createText(_extents, getAlignmentSettings(), getTextSettings(), _text); + _textDrawable = dynamic_cast(node.get()); - Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get(); - osg::ref_ptr node = style->createText(_extents, getAlignmentSettings(), getTextSettings(), _text); - _textDrawable = dynamic_cast(node.get()); - addChild(node.get()); - } + style->setupClipStateSet(_extents, getOrCreateStateSet()); + setGraphicsSubgraph(node.get()); } diff --git a/src/osgUI/Style.cpp b/src/osgUI/Style.cpp index 143586300..647e27e19 100644 --- a/src/osgUI/Style.cpp +++ b/src/osgUI/Style.cpp @@ -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());