[osg-users] Custom GraphicsContext Segmentation Fault when using Multithreading

Philipp Meyer philipp.meyer at fh-bielefeld.de
Wed Apr 20 07:46:33 PDT 2016


DISCLAIMER: I'm not a graphics or OpenGL expert, so if something is dumb or doesnt make sense please let me know.

Hi,

I am trying to use OSG to create an application for a real time Linux system without a windowing system.

To get OSG to work properly, I create my own GraphicsContext and assign it to each Camera I'm using. Within the GraphicsContext I set up EGL and DRM.

My GraphicsContext source code:

This works fine and I can run my application perfectly on the real time machine. However, if I switch from a single threaded rendering mode to multithreaded mode, I get a segmentation fault error and I'm having trouble understanding why.

I debugged the application via remote debugger and the segmentation fault happens here:


Code:
Shader::PerContextShader::PerContextShader(const Shader* shader, unsigned int contextID) :
        osg::Referenced(),
        _contextID( contextID )
{
    _shader = shader;
    _extensions = GLExtensions::Get( _contextID, true );
    _glShaderHandle = _extensions->glCreateShader( shader->getType() );
    requestCompile();
}




The function ptr "glCreateShader" is set to 0x0. After double checking it seems like the method to assign the function pointers fails because no valid OpenGL context can be found. The application also prints 


> Error: OpenGL version test failed, requires valid graphics context.


So now I'm wondering why this only happens if I enable multithreaded rendering, and not for singleThreaded rendering. What exactly do I need to change so that multithreading works on the real time machine?

Thank you!

Cheers,
mille25

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








More information about the osg-users mailing list