Show
Ignore:
Timestamp:
01/05/07 16:30:49 (8 years ago)
Author:
robert
Message:

Cleaned up the GraphicsWindow? setup

Files:
1 modified

Legend:

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

    r5907 r5908  
    123123     
    124124    bool customWindows = false; 
    125     while(arguments.read("-1")) customWindows = true; 
    126     while(arguments.read("-2")) customWindows = false; 
     125    while(arguments.read("-2")) customWindows = true; 
    127126 
    128127    if (customWindows) 
     
    135134        } 
    136135 
    137         unsigned int width, height; 
    138         wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); 
    139  
    140         width -= 500; 
    141         height -= 500; 
    142  
    143136        osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; 
    144         traits->x = 500; 
    145         traits->y = 500; 
    146         traits->width = width; 
    147         traits->height = height; 
    148     #if 0 
    149         traits->windowDecoration = false; 
    150     #else 
     137        traits->x = 250; 
     138        traits->y = 200; 
     139        traits->width = 800; 
     140        traits->height = 600; 
    151141        traits->windowDecoration = true; 
    152     #endif             
    153142        traits->doubleBuffer = true; 
    154143        traits->sharedContext = 0; 
    155144 
    156145        osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
    157  
    158         osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get()); 
    159         if (gw) 
     146        if (gc.valid()) 
    160147        { 
    161             osg::notify(osg::NOTICE)<<"  GraphicsWindow has been created successfully."<<gw<<std::endl; 
    162  
    163             gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height ); 
    164              
    165148            // need to ensure that the window is cleared make sure that the complete window is set the correct colour 
    166149            // rather than just the parts of the window that are under the camera's viewports 
    167             gw->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f)); 
    168             gw->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     150            gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f)); 
     151            gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    169152        } 
    170153        else 
     
    179162            osg::ref_ptr<osg::Camera> camera = new osg::Camera; 
    180163            camera->setGraphicsContext(gc.get()); 
    181             camera->setViewport(new osg::Viewport((i*width)/numCameras,(i*height)/numCameras, width/numCameras, height/numCameras)); 
     164            camera->setViewport(new osg::Viewport((i* traits->width)/numCameras,(i* traits->height)/numCameras,  traits->width/numCameras,  traits->height/numCameras)); 
    182165            GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; 
    183166            camera->setDrawBuffer(buffer);