From 502eced9948b9e43cdbcc21d6fe89d464aea83ba Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 19 Dec 2008 17:15:10 +0000 Subject: [PATCH] From Jean-Sebastein Guay, I recently had to reimplement screen capture functionality into our framework (which was broken since the switch from OSG 1.2 to 2.2 over a year and a half ago). I used the ScreenCaptureHandler which I had contributed right before OSG 2.6 shipped, bit I had to trigger the screen capture programatically instead of by a key press in some cases, so I added a convenience method to do that. It's a minimal change, it just calls an already existing protected method. It was trivial to subclass the handler to do it in our code, but pushing the change into OSG makes sense as it's generally useful to have it in the handler itself. I also noticed that the handle() method was overridden from osgGA::GUIEventHandler but wasn't marked virtual. It wasn't intended that subclasses not be able to override it in turn, so I've added the keyword."" --- include/osgViewer/ViewerEventHandlers | 5 ++++- src/osgViewer/ScreenCaptureHandler.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/osgViewer/ViewerEventHandlers b/include/osgViewer/ViewerEventHandlers index 4831c51a8..f6b875bee 100644 --- a/include/osgViewer/ViewerEventHandlers +++ b/include/osgViewer/ViewerEventHandlers @@ -347,7 +347,10 @@ class OSGVIEWER_EXPORT ScreenCaptureHandler : public osgGA::GUIEventHandler // aa will point to an osgViewer::View, so we will take a screenshot // of that view's graphics contexts. - bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa); + virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa); + + /** Capture the given viewer's views on the next frame. */ + virtual void captureNextFrame(osgViewer::ViewerBase& viewer); /** Get the keyboard and mouse usage of this manipulator.*/ virtual void getUsage(osg::ApplicationUsage& usage) const; diff --git a/src/osgViewer/ScreenCaptureHandler.cpp b/src/osgViewer/ScreenCaptureHandler.cpp index 36c7e0282..ae68f83d4 100644 --- a/src/osgViewer/ScreenCaptureHandler.cpp +++ b/src/osgViewer/ScreenCaptureHandler.cpp @@ -722,6 +722,12 @@ bool ScreenCaptureHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIAc return false; } +/** Capture the given viewer's views on the next frame. */ +void ScreenCaptureHandler::captureNextFrame(osgViewer::ViewerBase& viewer) +{ + addCallbackToViewer(viewer); +} + /** Get the keyboard and mouse usage of this manipulator.*/ void ScreenCaptureHandler::getUsage(osg::ApplicationUsage& usage) const {