Fix osgText issues under OSG 3.6

It looks like assigning an Effect to the geode containing the osgText is
enough and there aren't any conflicts with OSG own shaders. This might
change in the future if the switch to the core profile happens.

The text shaders also rely on fixed pipeline features like
gl_FrontColor. This is because aircraft developers are used to using
material animations to change the text color.
This commit is contained in:
Fernando García Liñán
2021-05-14 22:47:28 +02:00
parent d0f4e9018c
commit 64e4adf0b9

View File

@@ -27,6 +27,9 @@
#include <simgear/math/SGMath.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/misc/strutils.hxx>
#include <simgear/scene/material/Effect.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <osg/Geode>
#include <osg/MatrixTransform>
@@ -92,9 +95,16 @@ osg::Node * SGText::appendText(const SGPropertyNode* configNode,
SGConstPropertyNode_ptr p;
osgText::Text * text = new osgText::Text();
osg::Geode * g = new osg::Geode;
simgear::EffectGeode * g = new simgear::EffectGeode;
g->addDrawable( text );
SGPropertyNode_ptr effectProp = new SGPropertyNode;
makeChild(effectProp, "inherits-from")->setStringValue("Effects/text-default");
simgear::Effect* effect = simgear::makeEffect(
effectProp, true, dynamic_cast<const simgear::SGReaderWriterOptions*>(options));
if (effect)
g->setEffect(effect);
SGPath path("Fonts" );
path.append( configNode->getStringValue( "font", "Helvetica" ));
text->setFont( path.utf8Str() );