From 846a838c7027c01304dd42f92d0ddc8cc8e02fc0 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 22 Nov 2012 01:06:04 +0100 Subject: [PATCH] Expose NasalSys::gcSave/gcRelease to Canvas --- src/Canvas/FGCanvasSystemAdapter.cxx | 32 ++++++++++++++++++++++++++++ src/Canvas/FGCanvasSystemAdapter.hxx | 3 +++ 2 files changed, 35 insertions(+) diff --git a/src/Canvas/FGCanvasSystemAdapter.cxx b/src/Canvas/FGCanvasSystemAdapter.cxx index 0f56e3ed1..740973979 100644 --- a/src/Canvas/FGCanvasSystemAdapter.cxx +++ b/src/Canvas/FGCanvasSystemAdapter.cxx @@ -1,9 +1,11 @@ #include "FGCanvasSystemAdapter.hxx" #include
+#include #include #include +#include namespace canvas { @@ -67,4 +69,34 @@ namespace canvas return osgDB::readImageFile(tpath.c_str()); } + /** + * Get current FGNasalSys instance. + */ + static FGNasalSys* getNasalSys() + { + static FGNasalSys* nasal_sys = 0; + // TODO if Nasal is able to be removed and/or recreated at runtime we need + // to ensure that always the current instance is used + if( !nasal_sys ) + { + nasal_sys = dynamic_cast(globals->get_subsystem("nasal")); + if( !nasal_sys ) + throw std::runtime_error("FGCanvasSystemAdapter: no NasalSys"); + } + + return nasal_sys; + } + + //---------------------------------------------------------------------------- + int FGCanvasSystemAdapter::gcSave(naRef r) + { + return getNasalSys()->gcSave(r); + } + + //---------------------------------------------------------------------------- + void FGCanvasSystemAdapter::gcRelease(int key) + { + getNasalSys()->gcRelease(key); + } + } diff --git a/src/Canvas/FGCanvasSystemAdapter.hxx b/src/Canvas/FGCanvasSystemAdapter.hxx index 44239ee04..82896bda5 100644 --- a/src/Canvas/FGCanvasSystemAdapter.hxx +++ b/src/Canvas/FGCanvasSystemAdapter.hxx @@ -20,6 +20,9 @@ namespace canvas virtual void addCamera(osg::Camera* camera) const; virtual void removeCamera(osg::Camera* camera) const; virtual osg::Image* getImage(const std::string& path) const; + + virtual int gcSave(naRef r); + virtual void gcRelease(int key); }; }