From 9dc369eec2be4fabc202d2d8093b60aac5ee5b6a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 5 Jan 2007 16:46:57 +0000 Subject: [PATCH] Cleaned up graphics window setup and added clear graphics window to single window, multiple camera setup. --- examples/osgcamera/osgcamera.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/examples/osgcamera/osgcamera.cpp b/examples/osgcamera/osgcamera.cpp index f7c1b5733..518e92567 100644 --- a/examples/osgcamera/osgcamera.cpp +++ b/examples/osgcamera/osgcamera.cpp @@ -23,22 +23,19 @@ void singleWindowMultipleCameras(osgViewer::Viewer& viewer) traits->y = 0; traits->width = width; traits->height = height; -#if 0 - traits->windowDecoration = false; -#else traits->windowDecoration = true; -#endif traits->doubleBuffer = true; traits->sharedContext = 0; osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); - - osgViewer::GraphicsWindow* gw = dynamic_cast(gc.get()); - if (gw) + if (gc.valid()) { - osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height ); + // need to ensure that the window is cleared make sure that the complete window is set the correct colour + // rather than just the parts of the window that are under the camera's viewports + gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f)); + gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } else { @@ -84,22 +81,14 @@ void multipleWindowMultipleCameras(osgViewer::Viewer& viewer) traits->y = 0; traits->width = width/numCameras-1; traits->height = height; - #if 0 - traits->windowDecoration = false; - #else traits->windowDecoration = true; - #endif traits->doubleBuffer = true; traits->sharedContext = 0; osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); - - osgViewer::GraphicsWindow* gw = dynamic_cast(gc.get()); - if (gw) + if (gc.valid()) { - osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, traits->width, traits->height ); + osg::notify(osg::INFO)<<" GraphicsWindow has been created successfully."<