From dda72a16e8dc55604c32b40d00d915ef48aca86a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 2 Jan 2007 12:03:48 +0000 Subject: [PATCH] Changed default multi-screen setup to set up for a flat wall configuration --- src/osgViewer/View.cpp | 148 ++++++++++++++++++++++++++++++----------- 1 file changed, 108 insertions(+), 40 deletions(-) diff --git a/src/osgViewer/View.cpp b/src/osgViewer/View.cpp index 115732b75..8840229d2 100644 --- a/src/osgViewer/View.cpp +++ b/src/osgViewer/View.cpp @@ -115,48 +115,100 @@ void View::setUpViewAcrossAllScreens() } else { - double rotate_x = - double(numScreens-1) * 0.5 * fovx; - - for(unsigned int i=0; igetScreenResolution(osg::GraphicsContext::ScreenIdentifier(i), width, height); + double rotate_x = - double(numScreens-1) * 0.5 * fovx; - osg::ref_ptr traits = new osg::GraphicsContext::Traits; - traits->screenNum = i; - traits->x = 0; - traits->y = 0; - traits->width = width; - traits->height = height; - traits->windowDecoration = false; - traits->doubleBuffer = true; - traits->sharedContext = 0; - - osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); - - osg::ref_ptr camera = new osg::Camera; - camera->setGraphicsContext(gc.get()); - - osgViewer::GraphicsWindow* gw = dynamic_cast(gc.get()); - if (gw) + for(unsigned int i=0; igetEventQueue()->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); + unsigned int width, height; + wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(i), width, height); - addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate( rotate_x, 0.0, 1.0, 0.0)); - + osg::ref_ptr traits = new osg::GraphicsContext::Traits; + traits->screenNum = i; + traits->x = 0; + traits->y = 0; + traits->width = width; + traits->height = height; + traits->windowDecoration = false; + traits->doubleBuffer = true; + traits->sharedContext = 0; + + osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + + osg::ref_ptr camera = new osg::Camera; + 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); + + addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::rotate( rotate_x, 0.0, 1.0, 0.0)); + + } + } + else + { + double translate_x = double(numScreens) - 1.0; + + for(unsigned int i=0; igetScreenResolution(osg::GraphicsContext::ScreenIdentifier(i), width, height); + + osg::ref_ptr traits = new osg::GraphicsContext::Traits; + traits->screenNum = i; + traits->x = 0; + traits->y = 0; + traits->width = width; + traits->height = height; + traits->windowDecoration = false; + traits->doubleBuffer = true; + traits->sharedContext = 0; + + osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + + osg::ref_ptr camera = new osg::Camera; + 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); + + addSlave(camera.get(), osg::Matrixd::translate( translate_x, 0.0, 0.0), osg::Matrixd() ); + + } } } @@ -277,6 +329,8 @@ void View::requestContinuousUpdate(bool) void View::requestWarpPointer(float x,float y) { + // osg::notify(osg::NOTICE)<<"View::requestWarpPointer("<getCurrentEventState(); bool view_invert_y = eventState->getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS; @@ -304,6 +358,11 @@ void View::requestWarpPointer(float x,float y) if (view_invert_y) y = - y; + // osg::notify(osg::NOTICE)<<" remapped ("<= viewport->x() && new_coord.y() >= viewport->y() && - new_coord.x() <= (viewport->x()+viewport->width()) && new_coord.y() <= (viewport->y()+viewport->height()) ) + new_coord.x() >= (viewport->x()-epsilon) && new_coord.y() >= (viewport->y()-epsilon) && + new_coord.x() < (viewport->x()+viewport->width()-1.0+epsilon) && new_coord.y() <= (viewport->y()+viewport->height()-1.0+epsilon) ) { + // osg::notify(osg::NOTICE)<<" in viewport "<(camera->getGraphicsContext()); if (gw) { @@ -338,11 +401,16 @@ void View::requestWarpPointer(float x,float y) return; } } + else + { + // osg::notify(osg::NOTICE)<<" not in viewport "<x()<<" "<<(viewport->x()+viewport->width())<