Canvas cameras are slave cameras instead of scene graph cameras
This was a long-standing issue where Canvas cameras were rendered multiple times, once per slave camera. In the case of the Classic pipeline they were being rendered twice. Making them slave cameras has the issue of them not being shared across GraphicsContexts anymore, so it's not possible to see Canvas displays in extra CameraGroup windows. This is fixed by using OSG context sharing feature and sharing the initial windows' context with all subsequent windows.
This commit is contained in:
parent
11426c8177
commit
83b0a31b76
2 changed files with 21 additions and 2 deletions
|
@ -249,6 +249,11 @@ GraphicsWindow* WindowBuilder::buildWindow(const SGPropertyNode* winNode, bool i
|
|||
return result;
|
||||
}
|
||||
auto traits = new GraphicsContext::Traits(*defaultTraits);
|
||||
|
||||
// Attempt to share context with the window that was created first
|
||||
if (!wsa->windows.empty())
|
||||
traits->sharedContext = wsa->windows.front()->gc;
|
||||
|
||||
int traitsSet = setFromProperty(traits->hostName, winNode, "host-name");
|
||||
traitsSet |= setFromProperty(traits->displayNum, winNode, "display");
|
||||
traitsSet |= setFromProperty(traits->screenNum, winNode, "screen");
|
||||
|
|
|
@ -1106,13 +1106,27 @@ FGRenderer::setEventHandler(FGEventHandler* eventHandler_)
|
|||
void
|
||||
FGRenderer::addCamera(osg::Camera* camera, bool useSceneData)
|
||||
{
|
||||
_viewerSceneRoot->addChild(camera);
|
||||
osg::Camera *guiCamera = getGUICamera(CameraGroup::getDefault());
|
||||
osg::GraphicsContext *gc = guiCamera->getGraphicsContext();
|
||||
camera->setGraphicsContext(gc);
|
||||
if (composite_viewer) {
|
||||
composite_viewer->getView(0)->addSlave(camera, false);
|
||||
} else {
|
||||
viewer->addSlave(camera, false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FGRenderer::removeCamera(osg::Camera* camera)
|
||||
{
|
||||
_viewerSceneRoot->removeChild(camera);
|
||||
if (composite_viewer) {
|
||||
unsigned int index = composite_viewer->getView(0)
|
||||
->findSlaveIndexForCamera(camera);
|
||||
composite_viewer->getView(0)->removeSlave(index);
|
||||
} else {
|
||||
unsigned int index = viewer->findSlaveIndexForCamera(camera);
|
||||
viewer->removeSlave(index);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue