1
0
Fork 0

Torsten Dreyer: Check whether a valid graphic context has been created

before using a camera.
This commit is contained in:
durk 2008-04-19 10:28:07 +00:00
parent 9d65510b05
commit 8055c315ac

View file

@ -172,7 +172,6 @@ void fgOSOpenWindow(int w, int h, int bpp,
if (strcmp(cameraNode->getName(), "camera") != 0)
continue;
nCameras++;
// get a new copy of the traits struct
osg::ref_ptr<osg::GraphicsContext::Traits> cameraTraits;
cameraTraits = new osg::GraphicsContext::Traits(*traits);
@ -209,14 +208,17 @@ void fgOSOpenWindow(int w, int h, int bpp,
osg::GraphicsContext* gc;
gc = osg::GraphicsContext::createGraphicsContext(cameraTraits.get());
gc->realize();
camera->setGraphicsContext(gc);
// If a viewport isn't set on the camera, then it's hard to dig it
// out of the SceneView objects in the viewer, and the coordinates
// of mouse events are somewhat bizzare.
camera->setViewport(new osg::Viewport(0, 0, cameraTraits->width, cameraTraits->height));
camera->setProjectionResizePolicy(rsp);
viewer->addSlave(camera.get(), osg::Matrix::translate(-shearx, -sheary, 0), osg::Matrix());
if( gc != NULL ) {
gc->realize();
camera->setGraphicsContext(gc);
// If a viewport isn't set on the camera, then it's hard to dig it
// out of the SceneView objects in the viewer, and the coordinates
// of mouse events are somewhat bizzare.
camera->setViewport(new osg::Viewport(0, 0, cameraTraits->width, cameraTraits->height));
camera->setProjectionResizePolicy(rsp);
viewer->addSlave(camera.get(), osg::Matrix::translate(-shearx, -sheary, 0), osg::Matrix());
nCameras++;
}
}
if (nCameras > 1)
manipulator->setResizable(false);