From Jean-Sebastien Guay, "Changes attached so that the CaptureOperation is passed in the constructor of the ScreenCaptureHandler (default 0 = default CaptureOperation). This way, you can do:
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler(
new osgViewer::WriteToFileCaptureOperation("filename", "jpg")));
and the filename will be what you want. The WriteToFileCaptureOperation will add the context ID and the file number (if in SEQUENTIAL_NUMBER mode) to the file name.
(The attached also clarifies some notify messages, and corrects the comment when adding the handler in osgviewer.cpp)
I also remembered, the current architecture could allow a different CaptureOperation for each context, but currently the API only allows setting one CaptureOperation for all contexts. This could be improved if need be.
"
This commit is contained in:
@@ -355,6 +355,7 @@ class OSGVIEWER_EXPORT WindowCaptureCallback : public osg::Camera::DrawCallback
|
||||
void updateTimings(osg::Timer_t tick_start,
|
||||
osg::Timer_t tick_afterReadPixels,
|
||||
osg::Timer_t tick_afterMemCpy,
|
||||
osg::Timer_t tick_afterCaptureOperation,
|
||||
unsigned int dataSize);
|
||||
|
||||
void read();
|
||||
@@ -384,8 +385,10 @@ class OSGVIEWER_EXPORT WindowCaptureCallback : public osg::Camera::DrawCallback
|
||||
unsigned int _reportTimingFrequency;
|
||||
unsigned int _numTimeValuesRecorded;
|
||||
double _timeForReadPixels;
|
||||
double _timeForFullCopy;
|
||||
double _timeForMemCpy;
|
||||
double _timeForCaptureOperation;
|
||||
double _timeForFullCopy;
|
||||
double _timeForFullCopyAndOperation;
|
||||
osg::Timer_t _previousFrameTick;
|
||||
|
||||
osg::ref_ptr<CaptureOperation> _captureOperation;
|
||||
@@ -411,13 +414,14 @@ class OSGVIEWER_EXPORT WindowCaptureCallback : public osg::Camera::DrawCallback
|
||||
mutable OpenThreads::Mutex _mutex;
|
||||
mutable ContextDataMap _contextDataMap;
|
||||
|
||||
osg::ref_ptr<CaptureOperation> _defaultCaptureOperation;
|
||||
};
|
||||
|
||||
/** Event handler that will capture the screen on key press. */
|
||||
class OSGVIEWER_EXPORT ScreenCaptureHandler : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
ScreenCaptureHandler();
|
||||
ScreenCaptureHandler(CaptureOperation* defaultOperation = 0);
|
||||
|
||||
void setKeyEventTakeScreenShot(int key) { _keyEventTakeScreenShot = key; }
|
||||
int getKeyEventTakeScreenShot() const { return _keyEventTakeScreenShot; }
|
||||
|
||||
Reference in New Issue
Block a user