+ const char* splash_texture = fgGetString("/sim/startup/splash-texture");
+ SGSharedPtr<SGPropertyNode> style = fgGetNode("/sim/gui/style[0]", true);
+
+ char *namestring = genNameString();
+ fgSetString("/sim/startup/program-name", namestring);
+ delete[] namestring;
+
+ SGPath tpath( globals->get_fg_root() );
+ if (splash_texture == NULL || !strcmp(splash_texture, "")) {
+ // load in the texture data
+ int num = (int)(sg_random() * 5.0 + 1.0);
+ char num_str[5];
+ snprintf(num_str, 4, "%d", num);
+
+ tpath.append( "Textures/Splash" );
+ tpath.concat( num_str );
+ tpath.concat( ".png" );
+ } else
+ tpath.append( splash_texture );
+
+ osg::Texture2D* splashTexture = new osg::Texture2D;
+ splashTexture->setImage(osgDB::readImageFile(tpath.c_str()));
+
+ osg::Camera* camera = new osg::Camera;
+ camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
+ camera->setProjectionMatrix(osg::Matrix::ortho2D(-1, 1, -1, 1));
+ camera->setViewMatrix(osg::Matrix::identity());
+ camera->setRenderOrder(osg::Camera::POST_RENDER, 10000);
+ camera->setClearMask(0);
+ camera->setAllowEventFocus(false);
+ camera->setCullingActive(false);
+
+ osg::StateSet* stateSet = camera->getOrCreateStateSet();
+ stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
+ stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
+ stateSet->setAttribute(new osg::BlendFunc);
+ stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
+ stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
+ stateSet->setAttribute(new osg::Depth(osg::Depth::ALWAYS, 0, 1, false));
+ stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
+
+
+ osg::Geometry* geometry = new osg::Geometry;
+ geometry->setSupportsDisplayList(false);
+
+ osg::Vec3Array* vertexArray = new osg::Vec3Array;
+ vertexArray->push_back(osg::Vec3(-1, -1, 0));
+ vertexArray->push_back(osg::Vec3( 1, -1, 0));
+ vertexArray->push_back(osg::Vec3( 1, 1, 0));
+ vertexArray->push_back(osg::Vec3(-1, 1, 0));
+ geometry->setVertexArray(vertexArray);
+ osg::Vec4Array* colorArray = new osg::Vec4Array;
+ colorArray->push_back(osg::Vec4(0, 0, 0, 1));
+ geometry->setColorArray(colorArray);
+ geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
+ geometry->addPrimitiveSet(new osg::DrawArrays(GL_POLYGON, 0, 4));
+ geometry->setUpdateCallback(new FGSplashUpdateCallback(colorArray,
+ style->getNode("colors/splash-screen")));
+
+ osg::Geode* geode = new osg::Geode;
+ geode->addDrawable(geometry);
+
+ 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);
+ 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;