+ stateSet = geode->getOrCreateStateSet();
+ stateSet->setRenderBinDetails(1, "RenderBin");
+ camera->addChild(geode);
+
+
+ // The group is needed because of osg is handling the cull callbacks in a
+ // different way for groups than for a geode. It does not hurt here ...
+ osg::Group* group = new osg::Group;
+ group->setCullCallback(new FGSplashContentProjectionCalback);
+ camera->addChild(group);
+
+ geode = new osg::Geode;
+ stateSet = geode->getOrCreateStateSet();
+ stateSet->setRenderBinDetails(2, "RenderBin");
+ group->addChild(geode);
+
+
+ geometry = new osg::Geometry;
+ geometry->setSupportsDisplayList(false);
+
+ vertexArray = new osg::Vec3Array;
+ vertexArray->push_back(osg::Vec3(-0.84, -0.84, 0));
+ vertexArray->push_back(osg::Vec3( 0.84, -0.84, 0));
+ vertexArray->push_back(osg::Vec3( 0.84, 0.84, 0));
+ vertexArray->push_back(osg::Vec3(-0.84, 0.84, 0));
+ geometry->setVertexArray(vertexArray);
+ osg::Vec2Array* texCoordArray = new osg::Vec2Array;
+ texCoordArray->push_back(osg::Vec2(0, 0));
+ texCoordArray->push_back(osg::Vec2(1, 0));
+ texCoordArray->push_back(osg::Vec2(1, 1));
+ texCoordArray->push_back(osg::Vec2(0, 1));
+ geometry->setTexCoordArray(0, texCoordArray);
+ colorArray = new osg::Vec4Array;
+ colorArray->push_back(osg::Vec4(1, 1, 1, 1));
+ geometry->setColorArray(colorArray);
+ geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
+ geometry->addPrimitiveSet(new osg::DrawArrays(GL_POLYGON, 0, 4));
+ geometry->setUpdateCallback(new FGSplashUpdateCallback(colorArray, 0));
+ stateSet = geometry->getOrCreateStateSet();
+ stateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
+ stateSet->setTextureAttribute(0, splashTexture);
+ geode->addDrawable(geometry);
+
+
+ osgText::Text* text = new osgText::Text;
+ std::string fn = style->getStringValue("fonts/splash", "");
+ text->setFont(globals->get_fontcache()->getfntpath(fn.c_str()).str());
+ text->setCharacterSize(0.06);
+ text->setColor(osg::Vec4(1, 1, 1, 1));
+ text->setPosition(osg::Vec3(0, -0.92, 0));
+ text->setAlignment(osgText::Text::CENTER_CENTER);
+ SGPropertyNode* prop = fgGetNode("/sim/startup/splash-progress-text", true);
+ prop->setStringValue("initializing");
+ text->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
+ geode->addDrawable(text);
+
+ text = new osgText::Text;
+ text->setFont(globals->get_fontcache()->getfntpath(fn.c_str()).str());
+ text->setCharacterSize(0.08);
+ text->setColor(osg::Vec4(1, 1, 1, 1));
+ text->setPosition(osg::Vec3(0, 0.92, 0));
+ text->setAlignment(osgText::Text::CENTER_CENTER);
+ prop = fgGetNode("/sim/startup/program-name", "FlightGear");
+ text->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
+ geode->addDrawable(text);
+
+
+ text = new osgText::Text;
+ text->setFont(globals->get_fontcache()->getfntpath(fn.c_str()).str());
+ text->setCharacterSize(0.06);
+ text->setColor(osg::Vec4(1, 1, 1, 1));
+ text->setPosition(osg::Vec3(0, 0.82, 0));
+ text->setAlignment(osgText::Text::CENTER_CENTER);
+ prop = fgGetNode("/sim/startup/splash-title", true);
+ text->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
+ geode->addDrawable(text);
+
+ return camera;
+}
+
+// update callback for the switch node guarding that splash
+class FGSplashGroupUpdateCallback : public osg::NodeCallback {
+public:
+ FGSplashGroupUpdateCallback() :
+ _splashAlphaNode(fgGetNode("/sim/startup/splash-alpha", true))
+ { }
+ virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
+ {
+ assert(dynamic_cast<osg::Group*>(node));
+ osg::Group* group = static_cast<osg::Group*>(node);
+
+ double alpha = _splashAlphaNode->getDoubleValue();
+ if (alpha <= 0 || !fgGetBool("/sim/startup/splash-screen"))
+ group->removeChild(0, group->getNumChildren());
+ else if (group->getNumChildren() == 0)
+ group->addChild(fgCreateSplashCamera());
+
+ traverse(node, nv);
+ }
+private:
+ SGSharedPtr<const SGPropertyNode> _splashAlphaNode;
+};
+
+osg::Node* fgCreateSplashNode() {
+ osg::Group* group = new osg::Group;
+ group->setUpdateCallback(new FGSplashGroupUpdateCallback);
+ return group;