From Wang Rui, "For a long time, the osgviewerMFC example uses addSlave() to setup the
graphics context and link it with a slave camera. I don't know the reason we perform like that, which will cause a problem that the GUIEventHandler may not obtain correct window coordinates because the main camera will use a default input range to receive events from the slave camera's graphics context. It is also weird to see the addSlave() used in non-cluster applications, which beginners will be confused with. I've make a slightly modification to the osgviewerMFC example to make it work without setting slave cameras. I've tested with the MDI framework and everything seems fine."
This commit is contained in:
parent
f2f085bc3f
commit
e601bb9cc3
@ -105,8 +105,15 @@ void cOSG::InitCameraConfig(void)
|
|||||||
// Set the viewport for the Camera
|
// Set the viewport for the Camera
|
||||||
camera->setViewport(new osg::Viewport(traits->x, traits->y, traits->width, traits->height));
|
camera->setViewport(new osg::Viewport(traits->x, traits->y, traits->width, traits->height));
|
||||||
|
|
||||||
|
// Set projection matrix and camera attribtues
|
||||||
|
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||||
|
camera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f));
|
||||||
|
camera->setProjectionMatrixAsPerspective(
|
||||||
|
30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0, 1000.0);
|
||||||
|
|
||||||
// Add the Camera to the Viewer
|
// Add the Camera to the Viewer
|
||||||
mViewer->addSlave(camera.get());
|
//mViewer->addSlave(camera.get());
|
||||||
|
mViewer->setCamera(camera.get());
|
||||||
|
|
||||||
// Add the Camera Manipulator to the Viewer
|
// Add the Camera Manipulator to the Viewer
|
||||||
mViewer->setCameraManipulator(keyswitchManipulator.get());
|
mViewer->setCameraManipulator(keyswitchManipulator.get());
|
||||||
@ -118,10 +125,10 @@ void cOSG::InitCameraConfig(void)
|
|||||||
mViewer->realize();
|
mViewer->realize();
|
||||||
|
|
||||||
// Correct aspect ratio
|
// Correct aspect ratio
|
||||||
double fovy,aspectRatio,z1,z2;
|
/*double fovy,aspectRatio,z1,z2;
|
||||||
mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
|
mViewer->getCamera()->getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
|
||||||
aspectRatio=double(traits->width)/double(traits->height);
|
aspectRatio=double(traits->width)/double(traits->height);
|
||||||
mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
|
mViewer->getCamera()->setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void cOSG::PreFrameUpdate()
|
void cOSG::PreFrameUpdate()
|
||||||
|
Loading…
Reference in New Issue
Block a user