+static void initTerrasync()
+{
+ // add the terrasync root as a data path so data can be retrieved from it
+ // (even if we are in read-only mode)
+ std::string terraSyncDir(fgGetString("/sim/terrasync/scenery-dir"));
+ globals->append_data_path(terraSyncDir);
+
+ if (fgGetBool("/sim/fghome-readonly", false)) {
+ return;
+ }
+
+ // start TerraSync up now, so it can be synchronizing shared models
+ // and airports data in parallel with a nav-cache rebuild.
+ SGPath tsyncCache(globals->get_fg_home());
+ tsyncCache.append("terrasync-cache.xml");
+
+ // wipe the cache file if requested
+ if (flightgear::Options::sharedInstance()->isOptionSet("restore-defaults")) {
+ SG_LOG(SG_GENERAL, SG_INFO, "restore-defaults requested, wiping terrasync update cache at " <<
+ tsyncCache);
+ if (tsyncCache.exists()) {
+ tsyncCache.remove();
+ }
+ }
+
+ fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str());
+
+ simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync();
+ terra_sync->setRoot(globals->get_props());
+ globals->add_subsystem("terrasync", terra_sync);
+
+ terra_sync->bind();
+ terra_sync->init();
+}
+
+static void checkOpenGLVersion()
+{
+#if defined(SG_MAC)
+ // Mac users can't upgrade their drivers, so complaining about
+ // versions doesn't help them much
+ return;
+#endif
+
+ // format of these strings is not standardised, so be careful about
+ // parsing them.
+ std::string versionString(fgGetString("/sim/rendering/gl-version"));
+ string_list parts = simgear::strutils::split(versionString);
+ if (parts.size() == 3) {
+ if (parts[1].find("NVIDIA") != std::string::npos) {
+ // driver version number, dot-seperared
+ string_list driverVersion = simgear::strutils::split(parts[2], ".");
+ if (!driverVersion.empty()) {
+ int majorDriverVersion = simgear::strutils::to_int(driverVersion[0]);
+ if (majorDriverVersion < 300) {
+ std::ostringstream ss;
+ ss << "Please upgrade to at least version 300 of the nVidia drivers (installed version is " << parts[2] << ")";
+
+ flightgear::modalMessageBox("Outdated graphics drivers",
+ "FlightGear has detected outdated drivers for your graphics card.",
+ ss.str());
+ }
+ }
+ } // of NVIDIA-style version string
+ } // of three parts
+}