[osg-users] getGraphicsContext()/getState() segfault issue

Robert Osfield robert.osfield at gmail.com
Fri Nov 25 10:01:00 PST 2016


Hi Fabian,

The most likely cause is that the thread you are calling the
texture->apply() from doesn't have a graphics thread current.

The GraphicdWindowEmbedded is just a adapter class that allows you to
use the OSG with 3rd party SDK's like SDL where the graphics context
is created prior the OSG runs it's graphics.

In general with the OSG you don't usually explicitly call
texture->apply() instead you let the scene graph draw traversal do
this at the appropriate time.

What exactly you should be doing to fix things is something I can't
answer as the context is missing as how yu are creating the graphics
context and why you are doing what you are doing.

Robert.

On 25 November 2016 at 16:52, Fabien Boco <fabien.boco at gmail.com> wrote:
> Hi,
>
> I'm trying to do the folowing :
>
>
> Code:
> m_fboTexture->apply( *camera->getGraphicsContext()->getState() );
>
>
>
> But it crashes... More precisely, "applyTexParameters()" crashes. Everything has been initialized.
>
> Here is the complete sequence :
>
>
> Code:
> m_osgViewer = new osgViewer::Viewer();
> m_osgViewer->setUpViewerAsEmbeddedInWindow( 0, 0, m_width, m_height );
> m_osgViewer->getEventQueue()->windowResize( 0, 0, m_width, m_height );
>
> osg::Camera *camera = m_osgViewer->getCamera();
> camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT );
> camera->setViewport( 0, 0, m_width, m_height );
> camera->setProjectionMatrixAsPerspective( m_fov, m_width / m_height, m_zNear, m_zFar );
> camera->setNearFarRatio( m_zNearFarRatio );
> camera->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
> camera->setClearColor( m_color );
>
> m_fboTexture = new osg::Texture2D();
> m_fboTexture->setTextureSize( m_width, m_height );
> m_fboTexture->setInternalFormat( GL_RGBA );
> m_fboTexture->setFilter( osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR );
> m_fboTexture->setFilter( osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR );
> m_fboTexture->apply( *camera->getGraphicsContext()->getState() );
>
> camera->attach( osg::Camera::COLOR_BUFFER, m_fboTexture, 0, 0 );
>
>
>
> Seems there's an issue with the graphicsContext or/and State aquisition because this line crashes too :
>
>
> Code:
> unsigned int ctxId = m_osgViewer->getCamera()->getGraphicsContext()->getState()->getContextID();
>
>
>
> Thank you!
>
> Cheers,
> Fabien[/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=69500#69500
>
>
>
>
>
> _______________________________________________
> 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