I'm having a problem with inheriting window data from an MFC window in
OSG 2.2.
 
When I run an application with a dual monitor display the application
runs and OSG starts but it starts in fullscreen mode rather than
inheriting the MFC window size and location.
 
When I run the same application on the same machine but with only a
single monitor the OSG inherits the MFC window correctly.
 
 
Is there something that I'm missing?
 
Here is the code I use to create the window (borrowed from the MFC
viewer example):
 
       // Local Variable to hold window size data
       RECT rect;
 
       // Create the viewer for this window
       mViewer = new osgViewer::Viewer();
 
       //// Add a Stats Handler to the viewer
       mViewer->addEventHandler(new osgViewer::StatsHandler);
 
       //// Get the current window size
       ::GetWindowRect(m_hWnd, &rect);
 
       //// Init the GraphicsContext Traits
       osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
 
       //// Init the Windata Variable that holds the handle for the
Window to display OSG in.
       osg::ref_ptr<osg::Referenced> windata = new
osgViewer::GraphicsWindowWin32::WindowData(m_hWnd);
 
       // Setup the traits parameters
       traits->x = 0;
       traits->y = 0;
       traits->width = rect.right - rect.left;
       traits->height = rect.bottom - rect.top;
       traits->windowDecoration = false;
       traits->doubleBuffer = true;
       traits->sharedContext = 0;
       traits->setInheritedWindowPixelFormat = true;
       traits->inheritedWindowData = windata;
 
       // Create the Graphics Context
       osg::GraphicsContext* gc =
osg::GraphicsContext::createGraphicsContext(traits.get());
 
       // Init a new Camera (Master for this View)
       _camera = new osg::Camera;
 
       // Assign Graphics Context to the Camera
       _camera->setGraphicsContext(gc);
 
       // Set the viewport for the Camera
       _camera->setViewport(new osg::Viewport(traits->x, traits->y,
traits->width, traits->height));
 
       // Add the Camera to the Viewer
       mViewer->addSlave(_camera.get());
 
       // Add the Camera Manipulator to the Viewer
       //mViewer->setCameraManipulator(keyswitchManipulator.get());
 
       // Set the Scene Data
       mViewer->setSceneData(mRoot.get());
 
       // Realize the Viewer
       //mViewer->getCamera()->setViewport(traits->x, traits->y,
traits->width, traits->height);
       mViewer->realize();
 
Thanks -Steve 
 
 
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to