From c5b22f341a2aa2af27d88e8bc23244168ed66536 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 26 Apr 2017 09:48:08 +0100 Subject: [PATCH] Added ability to create windows for each view using -w command line hint. --- .../osgautotransform/osgautotransform.cpp | 57 ++++++++++++++----- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/examples/osgautotransform/osgautotransform.cpp b/examples/osgautotransform/osgautotransform.cpp index 118dd6130..8668abf12 100644 --- a/examples/osgautotransform/osgautotransform.cpp +++ b/examples/osgautotransform/osgautotransform.cpp @@ -199,6 +199,29 @@ osgViewer::View* createView(osg::ref_ptr scenegraph, osg::ref_ptr traits = new osg::GraphicsContext::Traits; + traits->x = x; + traits->y = y; + traits->width = width; + traits->height = height; + traits->windowDecoration = true; + traits->doubleBuffer = true; + traits->sharedContext = 0; + + gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + if (!gc) + { + osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<getCamera()->setGraphicsContext(gc); view->getCamera()->setViewport(new osg::Viewport(x, y, width, height)); @@ -222,6 +245,9 @@ int main(int argc, char** argv) unsigned int numViews = 1; while (arguments.read("-n",numViews)) {} + bool windows = false; + while (arguments.read("-w")) { windows = true; } + if (numViews<=1) { osgViewer::View* view = new osgViewer::View; @@ -246,21 +272,24 @@ int main(int argc, char** argv) unsigned int x=0, y=0; while(arguments.read("--window", x, y, width, height)) {} - osg::ref_ptr traits = new osg::GraphicsContext::Traits; - traits->x = x; - traits->y = y; - traits->width = width; - traits->height = height; - traits->windowDecoration = true; - traits->doubleBuffer = true; - traits->sharedContext = 0; - - - osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); - if (!gc) + osg::ref_ptr gc; + if (!windows) { - osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."< traits = new osg::GraphicsContext::Traits; + traits->x = x; + traits->y = y; + traits->width = width; + traits->height = height; + traits->windowDecoration = true; + traits->doubleBuffer = true; + traits->sharedContext = 0; + + gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + if (!gc) + { + osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<