Moved text color into TextBase, added support for colour into Text3D
This commit is contained in:
@@ -38,10 +38,6 @@ public:
|
||||
virtual const char* libraryName() const { return "osgText"; }
|
||||
|
||||
|
||||
void setColor(const osg::Vec4& color);
|
||||
const osg::Vec4& getColor() const { return _color; }
|
||||
|
||||
|
||||
/**
|
||||
* Turns off writing to the depth buffer when rendering text. This only affects text
|
||||
* with no backdrop or text using the DELAYED_DEPTH_WRITES implementation, since
|
||||
@@ -351,7 +347,6 @@ protected:
|
||||
String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
|
||||
|
||||
// members which have public access.
|
||||
osg::Vec4 _color;
|
||||
|
||||
// iternal map used for rendering. Set up by the computeGlyphRepresentation() method.
|
||||
mutable TextureGlyphQuadMap _textureGlyphQuadMap;
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
virtual const char* className() const { return "TextBase"; }
|
||||
virtual const char* libraryName() const { return "osgText"; }
|
||||
|
||||
|
||||
void setColor(const osg::Vec4& color);
|
||||
const osg::Vec4& getColor() const { return _color; }
|
||||
|
||||
/** Set the Font to use to render the text.
|
||||
* setFont(0) sets the use of the default font.*/
|
||||
@@ -279,6 +280,7 @@ protected:
|
||||
|
||||
|
||||
// members which have public access.
|
||||
osg::Vec4 _color;
|
||||
osg::ref_ptr<Font> _font;
|
||||
osg::ref_ptr<Style> _style;
|
||||
FontResolution _fontSize;
|
||||
|
||||
@@ -30,7 +30,6 @@ using namespace osgText;
|
||||
//#define TREES_CODE_FOR_MAKING_SPACES_EDITABLE
|
||||
|
||||
Text::Text():
|
||||
_color(1.0f,1.0f,1.0f,1.0f),
|
||||
_enableDepthWrites(true),
|
||||
_backdropType(NONE),
|
||||
_backdropImplementation(DELAYED_DEPTH_WRITES),
|
||||
@@ -46,7 +45,6 @@ Text::Text():
|
||||
|
||||
Text::Text(const Text& text,const osg::CopyOp& copyop):
|
||||
osgText::TextBase(text,copyop),
|
||||
_color(text._color),
|
||||
_enableDepthWrites(text._enableDepthWrites),
|
||||
_backdropType(text._backdropType),
|
||||
_backdropImplementation(text._backdropImplementation),
|
||||
@@ -67,12 +65,6 @@ Text::~Text()
|
||||
}
|
||||
|
||||
|
||||
void Text::setColor(const osg::Vec4& color)
|
||||
{
|
||||
_color = color;
|
||||
}
|
||||
|
||||
|
||||
Font* Text::getActiveFont()
|
||||
{
|
||||
return _font.valid() ? _font.get() : Font::getDefaultFont().get();
|
||||
|
||||
@@ -534,6 +534,8 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
osg::State & state = *renderInfo.getState();
|
||||
unsigned int contextID = state.getContextID();
|
||||
|
||||
state.disableColorPointer();
|
||||
state.Color(_color.r(),_color.g(),_color.b(),_color.a());
|
||||
|
||||
// ** save the previous modelview matrix
|
||||
osg::Matrix previous(state.getModelViewMatrix());
|
||||
|
||||
@@ -31,6 +31,7 @@ using namespace osgText;
|
||||
//#define TREES_CODE_FOR_MAKING_SPACES_EDITABLE
|
||||
|
||||
TextBase::TextBase():
|
||||
_color(1.0f,1.0f,1.0f,1.0f),
|
||||
_fontSize(32,32),
|
||||
_characterHeight(32),
|
||||
_characterSizeMode(OBJECT_COORDS),
|
||||
@@ -54,6 +55,7 @@ TextBase::TextBase():
|
||||
|
||||
TextBase::TextBase(const TextBase& textBase,const osg::CopyOp& copyop):
|
||||
osg::Drawable(textBase,copyop),
|
||||
_color(textBase._color),
|
||||
_font(textBase._font),
|
||||
_style(textBase._style),
|
||||
_fontSize(textBase._fontSize),
|
||||
@@ -81,6 +83,12 @@ TextBase::~TextBase()
|
||||
{
|
||||
}
|
||||
|
||||
void TextBase::setColor(const osg::Vec4& color)
|
||||
{
|
||||
_color = color;
|
||||
}
|
||||
|
||||
|
||||
void TextBase::setFont(osg::ref_ptr<Font> font)
|
||||
{
|
||||
if (_font==font) return;
|
||||
|
||||
Reference in New Issue
Block a user