Skip to content

Commit 9b76b1f

Browse files
committed
additional initialization for osgEarth
Earth plugin needs to be enabled, so that it is loaded early enough, before any GL contexts have been established/windows created
1 parent 60fb615 commit 9b76b1f

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/OpenCOVER/plugins/general/Earth/EarthPlugin.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ struct KMLUIBuilder : public osg::NodeVisitor
162162
EarthPlugin::EarthPlugin()
163163
: coVRPlugin(COVER_PLUGIN_NAME)
164164
{
165+
assert(!plugin);
165166
plugin = this;
167+
168+
osgEarth::initialize(); // has to be called before creating windows: load plugin from config
169+
realizeOp = new osgEarth::GL3RealizeOperation();
170+
VRViewer::instance()->addRealizeOperation(realizeOp);
171+
166172
mapNode = NULL;
167173
oldDump = NULL;
168174

@@ -445,6 +451,7 @@ int EarthPlugin::unloadKmlFile(const char *fn)
445451
// this is called if the plugin is removed at runtime
446452
EarthPlugin::~EarthPlugin()
447453
{
454+
VRViewer::instance()->removeRealizeOperation(realizeOp);
448455
plugin = NULL;
449456
}
450457

src/OpenCOVER/plugins/general/Earth/EarthPlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class EarthPlugin : public coVRPlugin, public coTUIListener
7878
static EarthPlugin *plugin;
7979

8080
private:
81+
osg::Operation *realizeOp = nullptr;
8182
osg::Node *loadedModel;
8283
osgEarth::MapNode *mapNode;
8384
bool useSky;

0 commit comments

Comments
 (0)