I am working on an .Net MDI application in VS9 and I am trying to use a 
composite viewer that has multiple user created embedded views. I have tested 
the creation/destruction of multiple standalone view windows with a composite 
viewer and it appears to work fine. However, when I embed the views into .Net 
windows re-sizing of the windows stops working correctly. The first window 
works fine, but then when I create a second view window re-sizing quits working 
for both windows. I can resize the .net windows, but the osg views maintain the 
size they were when the second window was created. Other than the resizing 
thing both views appear to still work though. I did some google searches and 
found some stuff that seemed related to this, but most of it was for QT and I 
am not using that. I was wondering if anyone has any ideas or suggestions? I 
have provided the code I am using to embed the osg views into .net using the 
HWND below.


Code:

void VsSimulationWindow::InitEmbedded(Simulator *lpSim, VsSimulator *lpVsSim)
{
    m_osgView = new osgViewer::View;
    m_lpWinMgr->Viewer()->addView(m_osgView.get());

        osg::GraphicsContext::Traits *traits =  new 
osg::GraphicsContext::Traits();

        traits->inheritedWindowData = new 
osgViewer::GraphicsWindowWin32::WindowData( m_HWND );
        traits->setInheritedWindowPixelFormat = true;
        traits->doubleBuffer = true;
        traits->windowDecoration = false;
        traits->sharedContext = 0;
        traits->supportsResize = true;

        RECT rect;
        GetWindowRect( m_HWND, &rect );
        traits->x = 0;
        traits->y = 0;
        traits->width = rect.right - rect.left;
        traits->height = rect.bottom - rect.top;

        osg::GraphicsContext *gc =      
osg::GraphicsContext::createGraphicsContext(traits);

        osg::Camera *cam = m_osgView->getCamera();
        cam->setName("MyCam");
        cam->setGraphicsContext( gc );
        cam->setViewport( new osg::Viewport( traits->x, traits->y, 
traits->width, traits->height ) );
        float *vColor = lpSim->BackgroundColor();
        cam->setClearColor(osg::Vec4(vColor[0], vColor[1], vColor[2], 
vColor[3]));
        m_osgView->setName("MyTest");

        m_osgView->setSceneData(lpVsSim->OSGRoot());

   //m_osgView->addEventHandler( new osgViewer::WindowSizeHandler );
    //m_osgView->addEventHandler( new osgViewer::ThreadingHandler );

        m_osgManip = new VsCameraManipulator(lpSim);
        m_osgView->setCameraManipulator(m_osgManip.get());
}




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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to