From Terry Welsh, "Okay, here are the mods I wrote for drawing a filled bounding box

behind osgText::Text.  I made it so the box would get drawn using
whichever BackdropImplementation was selected.  However, I did not
implement STENCIL_BUFFER.  In that case it defaults to drawing the
bounding box using POLYGON_OFFSET instead.

Also made it so the BOUNDINGBOX and FILLEDBOUNDINGBOX are drawn with a
settable color and margin size.

While I was at it I tightened up the values applied with DEPTH_RANGE
and POLYGON_OFFSET, not just for drawing the bounding box but also for
drawing backdrop text (these values must be coupled since the bounding
box has to be drawn deeper in Z than the backdrop text).  The values
in use before seemed like overkill and I was seeing some z-clipping
with my background scenery in the case of DEPTH_RANGE.  If there was a
good reason for the large values please let me know...."
This commit is contained in:
Robert Osfield
2009-07-24 14:59:51 +00:00
parent 773ae51a45
commit 31a947fda6
4 changed files with 116 additions and 7 deletions

View File

@@ -194,15 +194,24 @@ public:
enum DrawModeMask
{
TEXT = 1, /// default
BOUNDINGBOX = 2,
ALIGNMENT = 4
TEXT = 1, /// default
BOUNDINGBOX = 2,
FILLEDBOUNDINGBOX = 4,
ALIGNMENT = 8
};
void setDrawMode(unsigned int mode);
unsigned int getDrawMode() const { return _drawMode; }
void setBoundingBoxMargin(float margin);
float getBoundingBoxMargin() const { return _textBBMargin; }
void setBoundingBoxColor(const osg::Vec4& color){ _textBBColor = color; }
const osg::Vec4& getBoundingBoxColor() const { return _textBBColor; }
void setKerningType(KerningType kerningType) { _kerningType = kerningType; }
@@ -255,6 +264,8 @@ protected:
bool _autoRotateToScreen;
Layout _layout;
unsigned int _drawMode;
float _textBBMargin;
osg::Vec4 _textBBColor;
KerningType _kerningType;
unsigned int _lineCount;