From 0cd64c8c4f0e0b60a8a8e852fef5cd234534c983 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 6 Jan 2007 21:06:35 +0000 Subject: [PATCH] Added View::setUpViewOnSingleScreen(uint) method to help set up view on a single full screen window --- include/osgViewer/View | 3 +++ src/osgViewer/View.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/osgViewer/View b/include/osgViewer/View index 0b909ad81..53179b6cb 100644 --- a/include/osgViewer/View +++ b/include/osgViewer/View @@ -49,6 +49,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter /** Convinience method for creating slave Cameras and associated GraphicsWindows across all screens.*/ void setUpViewAcrossAllScreens(); + + /** Convinience method for a single Camara associated with a single full screen GraphicsWindow.*/ + void setUpViewOnSingleScreen(unsigned int screenNum=0); virtual void requestRedraw(); virtual void requestContinuousUpdate(bool needed=true); diff --git a/src/osgViewer/View.cpp b/src/osgViewer/View.cpp index a0a31d6b7..2ec8ca660 100644 --- a/src/osgViewer/View.cpp +++ b/src/osgViewer/View.cpp @@ -218,6 +218,54 @@ void View::setUpViewAcrossAllScreens() assignSceneDataToCameras(); } +void View::setUpViewOnSingleScreen(unsigned int screenNum) +{ + osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); + if (!wsi) + { + osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<getScreenResolution(osg::GraphicsContext::ScreenIdentifier(screenNum), width, height); + + osg::ref_ptr traits = new osg::GraphicsContext::Traits; + traits->x = 0; + traits->y = 0; + traits->width = width; + traits->height = height; +#if 1 + traits->windowDecoration = false; +#else + traits->windowDecoration = true; +#endif + traits->doubleBuffer = true; + traits->sharedContext = 0; + + osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + + _camera->setGraphicsContext(gc.get()); + + osgViewer::GraphicsWindow* gw = dynamic_cast(gc.get()); + if (gw) + { + osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height ); + } + else + { + osg::notify(osg::NOTICE)<<" GraphicsWindow has not been created successfully."<setViewport(new osg::Viewport(0, 0, width, height)); + + GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; + + _camera->setDrawBuffer(buffer); + _camera->setReadBuffer(buffer); +} + void View::assignSceneDataToCameras() { osg::Node* sceneData = _scene.valid() ? _scene->getSceneData() : 0;