From 130f581b18711b63138580d306a39c27b891178c Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 21 Feb 2014 08:52:07 -0800 Subject: [PATCH] Tile-manager can request VBOs. Monitor /sim/rendering/use-vbos and pass the value into our SGReaderWriterOptions. --- src/Scenery/tilemgr.cxx | 28 ++++++++++++++++++++++++++++ src/Scenery/tilemgr.hxx | 7 +++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 1d4bd40ad..54fe7988e 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -53,12 +53,37 @@ using flightgear::SceneryPager; +class FGTileMgr::TileManagerListener : public SGPropertyChangeListener +{ +public: + TileManagerListener(FGTileMgr* manager) : + _manager(manager) + { + fgGetNode("/sim/rendering/use-vbos", true)->addChangeListener(this, true); + } + + ~TileManagerListener() + { + fgGetNode("/sim/rendering/use-vbos")->removeChangeListener(this); + } + + virtual void valueChanged(SGPropertyNode* prop) + { + bool useVBOs = prop->getBoolValue(); + _manager->_options->setPluginStringData("SimGear::USE_VBOS", + useVBOs ? "ON" : "OFF"); + } + +private: + FGTileMgr* _manager; +}; FGTileMgr::FGTileMgr(): state( Start ), last_state( Running ), scheduled_visibility(100.0), _terra_sync(NULL), + _listener(NULL), _visibilityMeters(fgGetNode("/environment/visibility-m", true)), _maxTileRangeM(fgGetNode("/sim/rendering/static-lod/bare", true)), _disableNasalHooks(fgGetNode("/sim/temp/disable-scenery-nasal", true)), @@ -71,6 +96,8 @@ FGTileMgr::FGTileMgr(): FGTileMgr::~FGTileMgr() { + delete _listener; + // remove all nodes we might have left behind osg::Group* group = globals->get_scenery()->get_terrain_branch(); group->removeChildren(0, group->getNumChildren()); @@ -84,6 +111,7 @@ void FGTileMgr::init() { SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." ); _options = new simgear::SGReaderWriterOptions; + _listener = new TileManagerListener(this); materialLibChanged(); _options->setPropertyNode(globals->get_props()); diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index 1f7627c04..6931d4acc 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -29,7 +29,6 @@ #include #include #include "SceneryPager.hxx" -#include "tileentry.hxx" #include "tilecache.hxx" namespace osg @@ -76,7 +75,11 @@ private: */ TileCache tile_cache; simgear::SGTerraSync* _terra_sync; - + + class TileManagerListener; + friend class TileManagerListener; + TileManagerListener* _listener; + // update various queues internal queues void update_queues(bool& isDownloadingScenery);