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/osgcamera/osgcamera.cpp

    r5859 r5863  
    3737    viewer.getCamera()->setClearColor(osg::Vec4f(0.6f,0.6f,0.8f,1.0f)); 
    3838 
     39#if 1 
     40 
     41    osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); 
     42    if (!wsi)  
     43    { 
     44        osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<<std::endl; 
     45        return 0; 
     46    } 
     47     
     48    unsigned int width, height; 
     49    wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); 
     50 
     51    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; 
     52    traits->x = 0; 
     53    traits->y = 0; 
     54    traits->width = width; 
     55    traits->height = height; 
     56#if 0 
     57    traits->windowDecoration = false; 
     58#else 
     59    traits->windowDecoration = true; 
     60#endif             
     61    traits->doubleBuffer = true; 
     62    traits->sharedContext = 0; 
     63 
     64    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
     65 
     66    osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get()); 
     67    if (gw) 
     68    { 
     69        osg::notify(osg::NOTICE)<<"  GraphicsWindow has been created successfully."<<gw<<std::endl; 
     70 
     71        gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height ); 
     72    } 
     73    else 
     74    { 
     75        osg::notify(osg::NOTICE)<<"  GraphicsWindow has not been created successfully."<<std::endl; 
     76    } 
     77 
     78    unsigned int numCameras = 2; 
     79    double aspectRatioScale = 1.0;///(double)numCameras; 
     80    for(unsigned int i=0; i<numCameras;++i) 
     81    { 
     82        osg::ref_ptr<osg::Camera> camera = new osg::Camera; 
     83        camera->setGraphicsContext(gc.get()); 
     84        camera->setViewport(new osg::Viewport((i*width)/numCameras,(i*height)/numCameras, width/numCameras, height/numCameras)); 
     85        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; 
     86        camera->setDrawBuffer(buffer); 
     87        camera->setReadBuffer(buffer); 
     88 
     89        viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::scale(aspectRatioScale,1.0,1.0)); 
     90    } 
     91 
     92    viewer.setUpRenderingSupport(); 
     93    viewer.assignSceneDataToCameras(); 
     94     
     95#else 
     96 
    3997    viewer.setUpViewAcrossAllScreens(); 
     98 
     99#endif     
     100     
    40101    viewer.realize(); 
    41102 
    42     bool limitNumberOfFrames = true; 
     103    gw->requestWarpPointer(100,100); 
     104 
     105    bool limitNumberOfFrames = false; 
    43106    unsigned int numFrames = 0; 
    44107    unsigned int maxFrames = 10;