Show
Ignore:
Timestamp:
01/05/07 17:46:57 (8 years ago)
Author:
robert
Message:

Cleaned up graphics window setup and added clear graphics window to single window,
multiple camera setup.

Files:
1 modified

Legend:

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

    r5911 r5916  
    2424    traits->width = width; 
    2525    traits->height = height; 
    26 #if 0 
    27     traits->windowDecoration = false; 
    28 #else 
    2926    traits->windowDecoration = true; 
    30 #endif             
    3127    traits->doubleBuffer = true; 
    3228    traits->sharedContext = 0; 
    3329 
    3430    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
     31    if (gc.valid()) 
     32    { 
     33        osg::notify(osg::INFO)<<"  GraphicsWindow has been created successfully."<<std::endl; 
    3534 
    36     osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get()); 
    37     if (gw) 
    38     { 
    39         osg::notify(osg::INFO)<<"  GraphicsWindow has been created successfully."<<gw<<std::endl; 
    40  
    41         gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height ); 
     35        // need to ensure that the window is cleared make sure that the complete window is set the correct colour 
     36        // rather than just the parts of the window that are under the camera's viewports 
     37        gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f)); 
     38        gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    4239    } 
    4340    else 
     
    8582        traits->width = width/numCameras-1; 
    8683        traits->height = height; 
    87     #if 0 
    88         traits->windowDecoration = false; 
    89     #else 
    9084        traits->windowDecoration = true; 
    91     #endif             
    9285        traits->doubleBuffer = true; 
    9386        traits->sharedContext = 0; 
    9487 
    9588        osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); 
    96  
    97         osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get()); 
    98         if (gw) 
     89        if (gc.valid()) 
    9990        { 
    100             osg::notify(osg::INFO)<<"  GraphicsWindow has been created successfully."<<gw<<std::endl; 
    101  
    102             gw->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, traits->width, traits->height ); 
     91            osg::notify(osg::INFO)<<"  GraphicsWindow has been created successfully."<<std::endl; 
    10392        } 
    10493        else