Update the camera properties after a resize event.
This commit is contained in:
parent
4f4434787f
commit
4e047d456f
3 changed files with 16 additions and 1 deletions
|
@ -446,6 +446,18 @@ void CameraGroup::setCameraCullMasks(Node::NodeMask nm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CameraGroup::resized()
|
||||||
|
{
|
||||||
|
for (CameraIterator i = camerasBegin(), e = camerasEnd(); i != e; ++i) {
|
||||||
|
CameraInfo *info = i->get();
|
||||||
|
const Viewport* viewport = info->camera->getViewport();
|
||||||
|
info->x = viewport->x();
|
||||||
|
info->y = viewport->y();
|
||||||
|
info->width = viewport->width();
|
||||||
|
info->height = viewport->height();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Camera* getGUICamera(CameraGroup* cgroup)
|
Camera* getGUICamera(CameraGroup* cgroup)
|
||||||
{
|
{
|
||||||
CameraGroup::CameraIterator end = cgroup->camerasEnd();
|
CameraGroup::CameraIterator end = cgroup->camerasEnd();
|
||||||
|
|
|
@ -171,7 +171,9 @@ public:
|
||||||
/** Set the cull mask on all non-GUI cameras
|
/** Set the cull mask on all non-GUI cameras
|
||||||
*/
|
*/
|
||||||
void setCameraCullMasks(osg::Node::NodeMask nm);
|
void setCameraCullMasks(osg::Node::NodeMask nm);
|
||||||
|
/** Update camera properties after a resize event.
|
||||||
|
*/
|
||||||
|
void resized();
|
||||||
protected:
|
protected:
|
||||||
CameraList _cameras;
|
CameraList _cameras;
|
||||||
osg::ref_ptr<osgViewer::Viewer> _viewer;
|
osg::ref_ptr<osgViewer::Viewer> _viewer;
|
||||||
|
|
|
@ -217,6 +217,7 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
|
||||||
(*mouseMotionHandler)(x, y);
|
(*mouseMotionHandler)(x, y);
|
||||||
return true;
|
return true;
|
||||||
case osgGA::GUIEventAdapter::RESIZE:
|
case osgGA::GUIEventAdapter::RESIZE:
|
||||||
|
CameraGroup::getDefault()->resized();
|
||||||
if (resizable && windowResizeHandler)
|
if (resizable && windowResizeHandler)
|
||||||
(*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight());
|
(*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight());
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue