Expose NasalSys::gcSave/gcRelease to Canvas
This commit is contained in:
parent
bca6e9e890
commit
846a838c70
2 changed files with 35 additions and 0 deletions
|
@ -1,9 +1,11 @@
|
|||
#include "FGCanvasSystemAdapter.hxx"
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Scripting/NasalSys.hxx>
|
||||
#include <Viewer/renderer.hxx>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <stdexcept>
|
||||
|
||||
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<FGNasalSys*>(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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue