1
0
Fork 0
flightgear/src/Canvas/FGCanvasSystemAdapter.cxx
Thomas Geymayer 28779e7a51 Update for new simgear Canvas system.
A refactored version of the Canvas system can now be found in
SimGear.
2012-11-04 14:18:31 +01:00

70 lines
1.7 KiB
C++

#include "FGCanvasSystemAdapter.hxx"
#include <Main/globals.hxx>
#include <Viewer/renderer.hxx>
#include <osgDB/ReadFile>
namespace canvas
{
//----------------------------------------------------------------------------
simgear::canvas::FontPtr
FGCanvasSystemAdapter::getFont(const std::string& name) const
{
SGPath path = globals->resolve_resource_path("Fonts/" + name);
if( path.isNull() )
{
SG_LOG
(
SG_GL,
SG_ALERT,
"canvas::Text: No such font: " << name
);
return simgear::canvas::FontPtr();
}
SG_LOG
(
SG_GL,
SG_INFO,
"canvas::Text: using font file " << path.str()
);
simgear::canvas::FontPtr font = osgText::readFontFile(path.c_str());
if( !font )
SG_LOG
(
SG_GL,
SG_ALERT,
"canvas::Text: Failed to open font file " << path.c_str()
);
return font;
}
//----------------------------------------------------------------------------
void FGCanvasSystemAdapter::addCamera(osg::Camera* camera) const
{
globals->get_renderer()->addCamera(camera, false);
}
//----------------------------------------------------------------------------
void FGCanvasSystemAdapter::removeCamera(osg::Camera* camera) const
{
globals->get_renderer()->removeCamera(camera);
}
//----------------------------------------------------------------------------
osg::Image* FGCanvasSystemAdapter::getImage(const std::string& path) const
{
SGPath tpath = globals->resolve_resource_path(path);
if( tpath.isNull() || !tpath.exists() )
{
SG_LOG(SG_GL, SG_ALERT, "canvas::Image: No such image: " << path);
return 0;
}
return osgDB::readImageFile(tpath.c_str());
}
}