[osg-users] Graphics context issues

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Mon Jul 9 00:23:12 PDT 2018


Hi Ryan,

I guess your interfering with the currently set context. You're not 
explaining where/when you call your snippet, but usually this would be 
done inside a "realizeOperation".

A small example operation:

<code>
class TestSupportOperation: public osg::GraphicsOperation
{
public:

	TestSupportOperation()
	: osg::GraphicsOperation("TestSupportOperation",false){}

	virtual void operator () (osg::GraphicsContext* gc)
	{
		OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
		unsigned int contextID = 	gc->getState()->getContextID();		

		osg::GLExtensions* glext = osg::GLExtensions::Get(contextID, true);
		if (!glext->isOpenGL20Supported)
		{
			std::cerr << No 2.0++ suppport available\n";
		}
	}
	OpenThreads::Mutex	mMutex;
};
</code>

In your viewer you simply add:

viewer->setRealizeOperation(new TestSupportOperation);


Hope that helps,
Sebastian




> Hi,
> 
> I'm trying to query GL parameters such as GL_VENDOR, which require an active graphics context to work.  I looked another thread on this forum which explains how to do it, but it only works for a single-threaded viewer.  I'm running the viewer in multithreaded mode, and am getting crashes due to context issues.  Does anyone have an idea on how to do this?
> Thanks
> 
> Example code.  Usually crashes at the makeCurrent() line:
> 
> Code:
> 
> //get renderer information
> osgViewer::ViewerBase::Contexts contexts;
> viewer->getContexts(contexts, true);
> contexts[0]->makeCurrent();
> std::string vendor = (const char*)glGetString(GL_VENDOR);
> Report("Vendor: " + vendor);
> contexts[0]->releaseContext();
> 
> 
> 
> 
> Ryan
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=74276#74276
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 


More information about the osg-users mailing list