Deprecated Text:BackdropImplementation, removing the backend as it no longer required when using shaders for backdrop effects
This commit is contained in:
parent
28561b2b77
commit
8b12d2d71a
@ -473,7 +473,6 @@ void ComputeNode::addDataMonitor(osg::Vec3 placement, osg::Vec3 relativePlacemen
|
||||
pat->setName(labelCaption);
|
||||
text->setText(pat->getName());
|
||||
text->setBackdropType(osgText::Text::OUTLINE);
|
||||
text->setBackdropImplementation(osgText::Text::POLYGON_OFFSET);
|
||||
text->setBackdropOffset(0.05f);
|
||||
text->setBackdropColor(osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
|
@ -161,11 +161,6 @@ struct TextSettings
|
||||
text.setBackdropOffset(backdropOffset.x(), backdropOffset.y());
|
||||
text.setBackdropColor(backdropColor);
|
||||
|
||||
if (glyphTextureFeatures==osgText::GlyphTexture::ALL_FEATURES)
|
||||
{
|
||||
text.setBackdropImplementation(osgText::Text::USE_SHADERS);
|
||||
}
|
||||
|
||||
text.setFont(font.get());
|
||||
|
||||
}
|
||||
|
@ -154,7 +154,6 @@ osg:: Node* createTextBelow(const osg::BoundingBox& bb, const std::string& label
|
||||
if (s_useSDF)
|
||||
{
|
||||
text->getFont()->setGyphTextureFeatures(osgText::GlyphTexture::ALL_FEATURES);
|
||||
text->setBackdropImplementation(osgText::Text::USE_SHADERS);
|
||||
}
|
||||
|
||||
text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
@ -188,7 +187,6 @@ osg:: Node* createTextLeft(const osg::BoundingBox& bb, const std::string& label,
|
||||
if (s_useSDF)
|
||||
{
|
||||
text->getFont()->setGyphTextureFeatures(osgText::GlyphTexture::ALL_FEATURES);
|
||||
text->setBackdropImplementation(osgText::Text::USE_SHADERS);
|
||||
}
|
||||
|
||||
text->setAlignment(osgText::Text::RIGHT_CENTER);
|
||||
|
@ -432,7 +432,6 @@ static void Internal_SetAlpha(NSBitmapImageRep *imageRep, unsigned char alpha_va
|
||||
|
||||
default_text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
default_text->setBackdropType(osgText::Text::OUTLINE);
|
||||
// default_text->setBackdropImplementation(osgText::Text::POLYGON_OFFSET);
|
||||
default_text->setColor(osg::Vec4(1.0, 1.0, 0.0, 1.0));
|
||||
default_text->setBackdropColor(osg::Vec4(0.0, 0.0, 0.0, 1.0));
|
||||
default_text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||
|
@ -30,12 +30,6 @@ osgWidget::Label* createLabel(const std::string& l, unsigned int size=13) {
|
||||
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
label->setLabel(l);
|
||||
|
||||
/*
|
||||
text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
|
||||
text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER);
|
||||
text->setBackdropOffset(0.2f);
|
||||
*/
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
@ -60,33 +60,6 @@ public:
|
||||
NONE
|
||||
};
|
||||
|
||||
enum BackdropImplementation
|
||||
{
|
||||
/* No longer supported, naps to DELAYED_DEPTH_WRITES.*/
|
||||
POLYGON_OFFSET = 0,
|
||||
|
||||
/* No longer supported, naps to DELAYED_DEPTH_WRITES.*/
|
||||
NO_DEPTH_BUFFER,
|
||||
|
||||
/* No longer supported, naps to DELAYED_DEPTH_WRITES.*/
|
||||
DEPTH_RANGE,
|
||||
|
||||
/* No longer supported, naps to DELAYED_DEPTH_WRITES.*/
|
||||
STENCIL_BUFFER,
|
||||
|
||||
/* DELAYED_DEPTH_WRITES
|
||||
* This mode renders all text with depth writes turned off, then
|
||||
* again with depth writes on, but with the color buffer disabled.
|
||||
* This should render text accurately for all graphics cards. The
|
||||
* only downside is the additional pass to render to the depth
|
||||
* buffer. But if you don't need the depth buffer updated for
|
||||
* your, this extra pass can be disabled by calling
|
||||
* enableDepthWrites(false).*/
|
||||
DELAYED_DEPTH_WRITES,
|
||||
|
||||
USE_SHADERS
|
||||
};
|
||||
|
||||
/**
|
||||
* BackdropType gives you a background shadow text behind your regular
|
||||
* text. This helps give text extra contrast which can be useful when
|
||||
@ -141,18 +114,6 @@ public:
|
||||
|
||||
const osg::Vec4& getBackdropColor() const { return _backdropColor; }
|
||||
|
||||
/**
|
||||
* This specifies the underlying backdrop rendering implementation.
|
||||
* Unfortunately, at this time, there is no "perfect" rendering solution
|
||||
* so this function is provided to let you 'pick your poison'. Each
|
||||
* implementation has trade-offs. See BackdropImplementation enum
|
||||
* docs for details.*/
|
||||
void setBackdropImplementation(BackdropImplementation implementation);
|
||||
|
||||
BackdropImplementation getBackdropImplementation() const { return _backdropImplementation; }
|
||||
|
||||
|
||||
|
||||
enum ColorGradientMode
|
||||
{
|
||||
SOLID = 0, // a.k.a. ColorGradients off
|
||||
@ -224,6 +185,20 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
/** deprecated, value ignored.*/
|
||||
enum BackdropImplementation
|
||||
{
|
||||
POLYGON_OFFSET = 0,
|
||||
NO_DEPTH_BUFFER,
|
||||
DEPTH_RANGE,
|
||||
STENCIL_BUFFER,
|
||||
DELAYED_DEPTH_WRITES
|
||||
};
|
||||
|
||||
/** deprecated, value ignored.*/
|
||||
void setBackdropImplementation(BackdropImplementation) {}
|
||||
/** deprecated, value should be ignored.*/
|
||||
BackdropImplementation getBackdropImplementation() const { return DELAYED_DEPTH_WRITES; }
|
||||
|
||||
// internal structures, variable and methods used for rendering of characters.
|
||||
struct OSGTEXT_EXPORT GlyphQuads
|
||||
@ -310,7 +285,6 @@ protected:
|
||||
bool _enableDepthWrites;
|
||||
|
||||
BackdropType _backdropType;
|
||||
BackdropImplementation _backdropImplementation;
|
||||
|
||||
float _backdropHorizontalOffset;
|
||||
float _backdropVerticalOffset;
|
||||
|
@ -90,7 +90,7 @@ void Text::write(DataOutputStream* out){
|
||||
out->writeFloat(getBackdropVerticalOffset());
|
||||
|
||||
out->writeVec4(getBackdropColor());
|
||||
out->writeUInt(getBackdropImplementation());
|
||||
out->writeUInt(4); // old DELAYED_DEPTH_WRITES
|
||||
|
||||
out->writeUInt(getColorGradientMode());
|
||||
out->writeVec4(getColorGradientTopLeft());
|
||||
@ -213,7 +213,7 @@ void Text::read(DataInputStream* in){
|
||||
setBackdropOffset(horizontalOffset,verticalOffset);
|
||||
|
||||
setBackdropColor(in->readVec4());
|
||||
setBackdropImplementation((osgText::Text::BackdropImplementation) in->readUInt());
|
||||
in->readUInt(); // read old BackdropImplementation value, no longer used
|
||||
setColorGradientMode((osgText::Text::ColorGradientMode) in->readUInt());
|
||||
|
||||
osg::Vec4 colorGradientTopLeft,colorGradientBottomLeft,colorGradientBottomRight,colorGradientTopRight;
|
||||
|
@ -31,11 +31,6 @@ using namespace osgText;
|
||||
Text::Text():
|
||||
_enableDepthWrites(true),
|
||||
_backdropType(NONE),
|
||||
#if 1
|
||||
_backdropImplementation(DELAYED_DEPTH_WRITES),
|
||||
#else
|
||||
_backdropImplementation(USE_SHADERS),
|
||||
#endif
|
||||
_backdropHorizontalOffset(0.07f),
|
||||
_backdropVerticalOffset(0.07f),
|
||||
_backdropColor(0.0f, 0.0f, 0.0f, 1.0f),
|
||||
@ -47,17 +42,6 @@ Text::Text():
|
||||
{
|
||||
_supportsVertexBufferObjects = true;
|
||||
|
||||
char *ptr;
|
||||
if ((ptr = getenv("OSG_SDF_TEXT")) != 0)
|
||||
{
|
||||
_backdropImplementation = USE_SHADERS;
|
||||
}
|
||||
else if ((ptr = getenv("OSG_GREYSCALE_TEXT")) != 0)
|
||||
{
|
||||
_backdropImplementation = DELAYED_DEPTH_WRITES;
|
||||
}
|
||||
|
||||
|
||||
assignStateSet();
|
||||
}
|
||||
|
||||
@ -65,7 +49,6 @@ Text::Text(const Text& text,const osg::CopyOp& copyop):
|
||||
osgText::TextBase(text,copyop),
|
||||
_enableDepthWrites(text._enableDepthWrites),
|
||||
_backdropType(text._backdropType),
|
||||
_backdropImplementation(text._backdropImplementation),
|
||||
_backdropHorizontalOffset(text._backdropHorizontalOffset),
|
||||
_backdropVerticalOffset(text._backdropVerticalOffset),
|
||||
_backdropColor(text._backdropColor),
|
||||
@ -93,7 +76,7 @@ osg::StateSet* Text::createStateSet()
|
||||
|
||||
std::stringstream ss;
|
||||
osg::StateSet::DefineList defineList;
|
||||
if (_backdropType!=NONE && _backdropImplementation==USE_SHADERS)
|
||||
if (_backdropType!=NONE)
|
||||
{
|
||||
ss.str("");
|
||||
ss << "vec4("<<_backdropColor.r()<<", "<<_backdropColor.g()<<", "<<_backdropColor.b()<<", "<<_backdropColor.a()<<")";
|
||||
@ -128,8 +111,6 @@ osg::StateSet* Text::createStateSet()
|
||||
|
||||
defineList["SHADOW"] = osg::StateSet::DefinePair(ss.str(), osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (activeFont->getGlyphTextureFeatures()!=GlyphTexture::GREYSCALE)
|
||||
@ -147,7 +128,6 @@ osg::StateSet* Text::createStateSet()
|
||||
}
|
||||
|
||||
#if 0
|
||||
OSG_NOTICE<<"Text::createStateSet() _backdropType="<<_backdropType<<", _backdropImplementation="<<_backdropImplementation<<std::endl;
|
||||
OSG_NOTICE<<"Text::createStateSet() defines:"<<defineList.size()<<std::endl;
|
||||
for(osg::StateSet::DefineList::iterator itr = defineList.begin();
|
||||
itr != defineList.end();
|
||||
@ -1294,18 +1274,6 @@ void Text::setBackdropType(BackdropType type)
|
||||
computeGlyphRepresentation();
|
||||
}
|
||||
|
||||
void Text::setBackdropImplementation(BackdropImplementation implementation)
|
||||
{
|
||||
if (_backdropImplementation==implementation) return;
|
||||
|
||||
_backdropImplementation = implementation;
|
||||
|
||||
assignStateSet();
|
||||
|
||||
computeGlyphRepresentation();
|
||||
}
|
||||
|
||||
|
||||
void Text::setBackdropOffset(float offset)
|
||||
{
|
||||
_backdropHorizontalOffset = offset;
|
||||
|
@ -134,7 +134,6 @@ void Label::setFontColor(const Color& c) {
|
||||
|
||||
void Label::setShadow(point_type offset) {
|
||||
_text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
|
||||
_text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER);
|
||||
_text->setBackdropOffset(offset);
|
||||
|
||||
_calculateSize(getTextSize());
|
||||
|
@ -57,27 +57,6 @@ std::string convertBackdropTypeEnumToString(osgText::Text::BackdropType backdrop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
osgText::Text::BackdropImplementation convertBackdropImplementationStringToEnum(std::string & str)
|
||||
{
|
||||
if (str=="POLYGON_OFFSET") return osgText::Text::POLYGON_OFFSET;
|
||||
else if (str=="NO_DEPTH_BUFFER") return osgText::Text::NO_DEPTH_BUFFER;
|
||||
else if (str=="DEPTH_RANGE") return osgText::Text::DEPTH_RANGE;
|
||||
else if (str=="STENCIL_BUFFER") return osgText::Text::STENCIL_BUFFER;
|
||||
else return static_cast<osgText::Text::BackdropImplementation>(-1);
|
||||
}
|
||||
std::string convertBackdropImplementationEnumToString(osgText::Text::BackdropImplementation backdropImplementation)
|
||||
{
|
||||
switch (backdropImplementation)
|
||||
{
|
||||
case osgText::Text::POLYGON_OFFSET: return "POLYGON_OFFSET";
|
||||
case osgText::Text::NO_DEPTH_BUFFER: return "NO_DEPTH_BUFFER";
|
||||
case osgText::Text::DEPTH_RANGE: return "DEPTH_RANGE";
|
||||
case osgText::Text::STENCIL_BUFFER: return "STENCIL_BUFFER";
|
||||
default : return "";
|
||||
}
|
||||
}
|
||||
|
||||
osgText::Text::ColorGradientMode convertColorGradientModeStringToEnum(std::string & str)
|
||||
{
|
||||
if (str=="SOLID") return osgText::Text::SOLID;
|
||||
@ -155,12 +134,6 @@ bool Text_readLocalData(osg::Object &obj, osgDB::Input &fr)
|
||||
// backdropImplementation
|
||||
if (fr[0].matchWord("backdropImplementation"))
|
||||
{
|
||||
std::string str = fr[1].getStr();
|
||||
osgText::Text::BackdropImplementation backdropImplementation = convertBackdropImplementationStringToEnum(str);
|
||||
|
||||
if (backdropImplementation != static_cast<osgText::Text::BackdropImplementation>(-1))
|
||||
text.setBackdropImplementation(backdropImplementation);
|
||||
|
||||
fr += 2;
|
||||
itAdvanced = true;
|
||||
}
|
||||
@ -254,9 +227,6 @@ bool Text_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
|
||||
osg::Vec4 c = text.getBackdropColor();
|
||||
fw.indent() << "backdropColor " << c.x() << " " << c.y() << " " << c.z() << " " << c.w() << std::endl;
|
||||
|
||||
// backdropImplementation
|
||||
fw.indent() << "backdropImplementation " << convertBackdropImplementationEnumToString(text.getBackdropImplementation()) << std::endl;
|
||||
|
||||
// colorGradientMode
|
||||
fw.indent() << "colorGradientMode " << convertColorGradientModeEnumToString(text.getColorGradientMode()) << std::endl;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user