void InitWindowsSystem (osgViewer::Viewer& viewer, const char* const title, int x, int y, int width, int height) { viewer.setUpViewInWindow(x, y, width, height); //Get the traits of the current window osg::ref_ptr< osg::GraphicsContext::Traits > traits = new osg::GraphicsContext::Traits( *viewer.getCamera()->getGraphicsContext()->getTraits()); //Set the title traits->windowName = title; // disable vertical sync traits->vsync = false; //Create a new graphics context with the modified traits osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() ); gc->realize(); gc->makeCurrent(); // set the vertical black off by default osgViewer::Viewer::Windows windows; viewer.getWindows(windows); for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) { osgViewer::GraphicsWindow* const graphicsWindow = (*itr); graphicsWindow->setSyncToVBlank (false); } //Create the new camera which is a copy of the current camera in the viewer osg::ref_ptr<osg::Camera> cam = new osg::Camera( *viewer.getCamera() ); //Set the cameras graphics context to the gc we made above cam->setGraphicsContext( gc ); //assign the viewer the new camera viewer.setCamera( cam.get() ); // int the camera default perspective matrix SetCameraProjectionMatrix (viewer, 60.0f, dFloat (width) / height, 0.01, 1000.0f); // set the file find callback osg::ref_ptr<DemosFindFileCallback> filecallback = new DemosFindFileCallback; osgDB::Registry::instance()->setFindFileCallback (filecallback.get()); }