Hi Jean,
I decided to take the approach that displays graphics in a window. I am able to
get 2 windows. But right now, both monitors are displaying 2 windows. I am not
able to separate window 1 to screen 1 and window 2 to screen 2 only.
I tried following what you had suggested but I still get 2 windows in each
screen:
I have 2 graphics context - gc and gc2 (gc handles views 0, 1, 2 and gc2 view 3)
Below is how I have setup the graphics context and windowing system interface:
Code:
osg::GraphicsContext::WindowingSystemInterface* wsi =
osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available,
cannot create windows."<<std::endl;
return 1;
}
unsigned int windowWidth1, windowHeight1;
unsigned int windowWidth2, windowHeight2;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0),
windowWidth1, windowHeight1);
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(1),
windowWidth2, windowHeight2);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
traits->x = 100;
traits->y = 100;
traits->width = 1000;
traits->height = 800;
traits->windowDecoration = true;
traits->doubleBuffer = true;
traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(traits.get());
osg::ref_ptr<osg::GraphicsContext> gc2 =
osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid() && gc2.valid())
{
osg::notify(osg::INFO)<<" GraphicsWindow has been created
successfully."<<std::endl;
// need to ensure that the window is cleared make sure that the complete
window is
//set the correct colour rather than just the parts of the
window that are
//under the camera's viewports
gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f));
gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gc2->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f));
gc2->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else
{
osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created
successfully."<<std::endl;
}
This is the code for the window in the 2nd monitor (or view 3)
Code:
// view 3
{
osgViewer::View* view = new osgViewer::View;
view->setUpViewOnSingleScreen(1);
view->setName("View four");
viewer.addView(view);
view->setSceneData(root);
view->addEventHandler(keh.get());
view->getCamera()->setName("Cam four");
view->getCamera()->setProjectionMatrixAsPerspective(30.0,
double(traits->width) / double(traits->height), 1.0, 1000.0);
view->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width,
traits->height));
view->getCamera()->setGraphicsContext(gc2.get());
view->setCameraManipulator(new osgGA::TrackballManipulator);
osgGA::NodeTrackerManipulator* backhoeTracker = new
osgGA::NodeTrackerManipulator();
backhoeTracker->setTrackNode(backhoe1.getBackhoe());
view->setCameraManipulator(backhoeTracker);
}
Thanks
Sanat
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30584#30584
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org