Reputation: 55
i am using Qt 5.11.2 / osgEarth 2.9.0.
When I try to run the code below, I get an error:
Cannot make QOpenGLContext current in a different thread
I tried to find a solution on the Internet, but found only similar situations where people were just rewriting some of their code, even without osgEarth. But if you remove the Qt output from my code (last 2 lines)), everything works well, from which I concluded that the problem is not in my code. Maybe I forgot to install some package? Or installed it incorrectly?
Code:
Viewer *viewer = new Viewer();
EarthManipulator *manipulator = new EarthManipulator();
viewer->setLightingMode(osg::View::NO_LIGHT);
viewer->getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
viewer->setCameraManipulator(manipulator);
Map map = new Map();
MapNode mapnode = new MapNode(map);
Drivers::XYZOptions xyz;
xyz.url() = "http://[abc].tile.openstreetmap.org/{z}/{x}/{y}.png";
xyz.profile()->namedProfile() = "spherical-mercator";
ImageLayer* imageLayer = new ImageLayer("OSM", xyz);
map->addLayer(imageLayer);
viewer->setSceneData(mapnode);
MapNodeHelper().configureView(viewer);
QWidget *viewerWidget = new ViewerWidget(viewer);
layout->addWidget(viewerWidget);
Upvotes: 1
Views: 178