Show
Ignore:
Timestamp:
01/01/07 19:20:10 (8 years ago)
Author:
robert
Message:

Various work on osgViewer library, including warp point and graphics window resize support

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osghangglide/osghangglide.cpp

    r5851 r5863  
    144144    viewer.setSceneData( rootnode ); 
    145145 
    146     // set up the value with sensible default event handlers. 
     146#if 0 
     147 
     148    osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); 
     149    if (!wsi)  
     150    { 
     151        osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<<std::endl; 
     152        return 0; 
     153    } 
     154     
     155    unsigned int width, height; 
     156    wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); 
     157 
     158    width -= 500; 
     159    height -= 500; 
     160 
     161    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; 
     162    traits->x = 500; 
     163    traits->y = 500; 
     164    traits->width = width; 
     165    traits->height = height; 
     166#if 0 
     167    traits->windowDecoration = false; 
     168#else 
     169    traits->windowDecoration = true; 
     170#endif             
     171    traits->doubleBuffer = true; 
     172    traits->sharedContext = 0; 
     173 
     174    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
     175 
     176    osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get()); 
     177    if (gw) 
     178    { 
     179        osg::notify(osg::NOTICE)<<"  GraphicsWindow has been created successfully."<<gw<<std::endl; 
     180 
     181        gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height ); 
     182    } 
     183    else 
     184    { 
     185        osg::notify(osg::NOTICE)<<"  GraphicsWindow has not been created successfully."<<std::endl; 
     186    } 
     187 
     188    unsigned int numCameras = 2; 
     189    double aspectRatioScale = 1.0/(double)numCameras; 
     190    for(unsigned int i=0; i<numCameras;++i) 
     191    { 
     192        osg::ref_ptr<osg::Camera> camera = new osg::Camera; 
     193        camera->setGraphicsContext(gc.get()); 
     194        camera->setViewport(new osg::Viewport((i*width)/numCameras,(i*height)/numCameras, width/numCameras, height/numCameras)); 
     195        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; 
     196        camera->setDrawBuffer(buffer); 
     197        camera->setReadBuffer(buffer); 
     198 
     199        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::scale(aspectRatioScale,1.0,1.0)); 
     200    } 
     201 
     202    viewer.setUpRenderingSupport(); 
     203    viewer.assignSceneDataToCameras(); 
     204     
     205#else 
     206 
    147207    viewer.setUpViewAcrossAllScreens(); 
    148  
    149     // create the windows and run the threads. 
     208     
     209#endif     
     210 
    150211    viewer.realize(); 
    151212