Re: [osg-users] wglGetCurrentContext vs osg::GraphicsContext::createGraphicsContext
No one with insight on this? /Anders On Fri, Mar 8, 2013 at 11:27 AM, Anders Backman ande...@cs.umu.se 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_castdouble(m_traits-width)/static_castdouble(m_traits-height), 1.0f, 1.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 and...@cs.umu.se http://www.hpc2n.umu.se Cell: +46-70-392 64 67 -- __ Anders Backman, HPC2N 90187 Umeå University, Sweden and...@cs.umu.se http://www.hpc2n.umu.se Cell: +46-70-392 64 67 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] wglGetCurrentContext vs osg::GraphicsContext::createGraphicsContext
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 ande...@cs.umu.se mailto:ande...@cs.umu.se 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_castdouble(m_traits-width)/static_castdouble(m_traits-height), 1.0f, 1.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 and...@cs.umu.se mailto:and...@cs.umu.se http://www.hpc2n.umu.se Cell: +46-70-392 64 67 tel:%2B46-70-392%2064%2067 -- __ Anders Backman, HPC2N 90187 Umeå University, Sweden and...@cs.umu.se mailto:and...@cs.umu.se http://www.hpc2n.umu.se Cell: +46-70-392 64 67 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] wglGetCurrentContext vs osg::GraphicsContext::createGraphicsContext
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_castdouble(m_traits-width)/static_castdouble(m_traits-height), 1.0f, 1.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 and...@cs.umu.se http://www.hpc2n.umu.se Cell: +46-70-392 64 67 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org