From 4e047d456f1a20199da2d86d98af69913c75780a Mon Sep 17 00:00:00 2001 From: timoore Date: Tue, 18 Nov 2008 22:46:19 +0000 Subject: [PATCH] Update the camera properties after a resize event. --- src/Main/CameraGroup.cxx | 12 ++++++++++++ src/Main/CameraGroup.hxx | 4 +++- src/Main/FGEventHandler.cxx | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Main/CameraGroup.cxx b/src/Main/CameraGroup.cxx index f218466bb..46ae0faea 100644 --- a/src/Main/CameraGroup.cxx +++ b/src/Main/CameraGroup.cxx @@ -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) { CameraGroup::CameraIterator end = cgroup->camerasEnd(); diff --git a/src/Main/CameraGroup.hxx b/src/Main/CameraGroup.hxx index 19b8a9920..a9e9b6973 100644 --- a/src/Main/CameraGroup.hxx +++ b/src/Main/CameraGroup.hxx @@ -171,7 +171,9 @@ public: /** Set the cull mask on all non-GUI cameras */ void setCameraCullMasks(osg::Node::NodeMask nm); - + /** Update camera properties after a resize event. + */ + void resized(); protected: CameraList _cameras; osg::ref_ptr _viewer; diff --git a/src/Main/FGEventHandler.cxx b/src/Main/FGEventHandler.cxx index 56dcb564c..16babdead 100644 --- a/src/Main/FGEventHandler.cxx +++ b/src/Main/FGEventHandler.cxx @@ -217,6 +217,7 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea, (*mouseMotionHandler)(x, y); return true; case osgGA::GUIEventAdapter::RESIZE: + CameraGroup::getDefault()->resized(); if (resizable && windowResizeHandler) (*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight()); return true;