[osg-users] Shader Program stops working after Changing Viewer GraphcsContext or Viewer

Eran Cohen ceranco at gmail.com
Mon May 21 08:10:09 PDT 2018


Hi,

I implemented a 'PausableViewer', to enable dynamically 'hiding' and 'showing' the window. I did it in the following way:
On pause, I set done to true, create a new GraphicsContext with the same traits of the previous GraphicsContext, stop the viewer threading and switch them - 

Code:
pause()
{
	auto traits = new GraphicsContext::Traits(*getCamera()->getGraphicsContext()->getTraits());
	auto gc = GraphicsContext::create(traits);
	
	stopThreading();
	getCamera()->setGraphicsContext(gc);
	setDone(true);
}



On resume, I resume the threading and set done to false - 

Code:
resume()
{
	setDone(false);
	startThreading();
}




This works well, but when using with osgEarth's SkyNode as the scene data of the viewer, after the second context switch and onward, I get these errors in a loop:

glValidateProgram  FAILED  ""  id=4  contextID=0
glValidateProgram  FAILED  "SimpleSky Atmosphere"  id=7  contextID=0
Warning: detected OpenGL error 'invalid operation' at RenderBin::draw(..)


I can also recreate the error using a regular Viewer, by closing a Viewer but saving the scene data and giving it to a new Viewer:


Code:
ref_ptr<Group> root = new Group;
auto mapNode = new MapNode;
auto skyNode = SkyNode::create(mapNode);

skyNode->addChild(mapNode);
root->addChild(skyNode);

while (true)
{
	Viewer viewer;
	viewer.setCameraManipulator(new EarthManipulator);
	viewer.setSceneData(root);
	viewer.run();
}



I know that this problem might stem from the osgEarth side of things, and I've asked there, but I'm wondering if anyone might have a clue to why this happens.

Cheers,
Eran

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73696#73696







More information about the osg-users mailing list