1

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);
garbart
  • 55
  • 4
  • The error message is clear, but it's hidden for a user not handling threads and OpenGL directly. I'm not an OSG user, but it seems you need to integrate OSG and Qt, likely by [osgQt](http://public.vrac.iastate.edu/vancegroup/docs/OpenSceneGraphReferenceDocs-3.0/a01522.html) – Ripi2 Oct 10 '18 at 15:08
  • @Ripi2 I thought so. However, osgQt was already installed. Reinstalling did not give results. – garbart Oct 12 '18 at 06:13
  • Installed is not the same as used. Do you use it? – Ripi2 Oct 12 '18 at 12:22

0 Answers0