Yep that solved it. Thanks.
Interesting though that no context is available after m_viewer->frame()
though...

/A

On Mon, Mar 11, 2013 at 1:26 PM, Laurens Voerman <[email protected]> wrote:

>  Hi Anders,
> did you try:
> m_viewer->setReleaseContextAtEndOfFrameHint(false);
> before the call to
> m_viewer->frame();
>
> Hope that helps,
> Laurens.
>
>
> On 3/11/2013 11:33 AM, Anders Backman wrote:
>
> No one with insight on this?
>
>  /Anders
>
>
> On Fri, Mar 8, 2013 at 11:27 AM, Anders Backman <[email protected]> wrote:
>
>> Hi all.
>>
>>  I have a small problem where I
>> use  osg::GraphicsContext::createGraphicsContext to create a context for a
>> window-widget (in .NET), but I also use another piece of software that
>> use wglGetCurrentContext  to check for context.
>> But wglGetCurrentContext() returns null for the context that OSG creates.
>>
>>  My init method:
>>
>>   bool GraphicsWindow::initOSG( HWND hwnd)
>> {
>>   if (m_viewer.valid())
>>     return true;
>>
>>    m_viewer = new osgViewer::Viewer();
>>   m_viewer->setThreadingModel( osgViewer::ViewerBase::SingleThreaded );
>>   m_root = new osg::Group;
>>   m_viewer->setSceneData( m_root.get() );
>>
>>
>>    m_traits = new osg::GraphicsContext::Traits();
>>   m_traits->inheritedWindowData = new
>> osgViewer::GraphicsWindowWin32::WindowData( hwnd );
>>   m_traits->setInheritedWindowPixelFormat = true;
>>   m_traits->doubleBuffer = true;
>>   m_traits->windowDecoration = true;
>>   m_traits->sharedContext = NULL;
>>   m_traits->supportsResize = true;
>>
>>    RECT rect;
>>   ::GetWindowRect( hwnd, &rect );
>>   m_traits->x = 0;
>>   m_traits->y = 0;
>>   m_traits->width = rect.right - rect.left;
>>   m_traits->height = rect.bottom - rect.top;
>>
>>    m_graphicsContext = osg::GraphicsContext::createGraphicsContext(
>> m_traits.get() );
>>
>>     m_viewer->getCamera()->setGraphicsContext( m_graphicsContext.get() );
>>     m_viewer->getCamera()->setViewport( new osg::Viewport( 0, 0,
>> m_traits->width, m_traits->height ) );
>>    m_viewer->getCamera()->setProjectionMatrixAsPerspective(30.0f,
>> static_cast<double>(m_traits->width)/static_cast<double>(m_traits->height),
>> 1.0f, 10000.0f);
>>
>>
>>    m_viewer->realize();
>>
>>    m_viewer->frame();
>>
>>
>>    assert(wglGetCurrentContext()); // Fails
>>
>>
>>  I have tried m_graphicsContext->makeCurrent();
>>
>>  wglGetCurrentContext STILL returns null...
>>
>>  I know that I'm missing something, question is what?
>>
>>
>>  /Anders
>>
>>  --
>> __________________________________________
>> Anders Backman, HPC2N
>> 90187 Umeå University, Sweden
>> [email protected] http://www.hpc2n.umu.se
>> Cell: +46-70-392 64 67 <%2B46-70-392%2064%2067>
>>
>
>
>
>  --
> __________________________________________
> Anders Backman, HPC2N
> 90187 Umeå University, Sweden
> [email protected] http://www.hpc2n.umu.se
> Cell: +46-70-392 64 67
>
>
> _______________________________________________
> osg-users mailing 
> [email protected]http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


-- 
__________________________________________
Anders Backman, HPC2N
90187 Umeå University, Sweden
[email protected] http://www.hpc2n.umu.se
Cell: +46-70-392 64 67
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to