diff --git a/examples/osgframerenderer/CaptureSettings.cpp b/examples/osgframerenderer/CaptureSettings.cpp index b214d15de..23df7cd65 100644 --- a/examples/osgframerenderer/CaptureSettings.cpp +++ b/examples/osgframerenderer/CaptureSettings.cpp @@ -5,6 +5,7 @@ using namespace gsc; CaptureSettings::CaptureSettings(): _stereoMode(OFF), _offscreen(false), + _outputImageFlip(false), _width(1024), _height(512), _screenWidth(0.0), @@ -26,6 +27,7 @@ CaptureSettings::CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& c _outputExtension(cs._outputExtension), _stereoMode(cs._stereoMode), _offscreen(cs._offscreen), + _outputImageFlip(cs._outputImageFlip), _width(cs._width), _height(cs._height), _screenWidth(cs._screenWidth), @@ -158,6 +160,7 @@ REGISTER_OBJECT_WRAPPER( gsc_CaptureSettings, END_ENUM_SERIALIZER(); // _renderTargetImplementation ADD_BOOL_SERIALIZER( Offscreen, false ); + ADD_BOOL_SERIALIZER( OutputImageFlip, false ); ADD_UINT_SERIALIZER( Width, 1024 ); ADD_UINT_SERIALIZER( Height, 512 ); diff --git a/examples/osgframerenderer/CaptureSettings.h b/examples/osgframerenderer/CaptureSettings.h index 9ed3398b3..0b022e8e6 100644 --- a/examples/osgframerenderer/CaptureSettings.h +++ b/examples/osgframerenderer/CaptureSettings.h @@ -42,6 +42,9 @@ public: void setOffscreen(bool o) { _offscreen = o; } bool getOffscreen() const { return _offscreen; } + void setOutputImageFlip(bool flip) { _outputImageFlip = flip; } + bool getOutputImageFlip() const { return _outputImageFlip; } + void setWidth(unsigned int width) { _width = width; } unsigned int getWidth() const { return _width; } @@ -109,6 +112,7 @@ protected: StereoMode _stereoMode; bool _offscreen; + bool _outputImageFlip; unsigned int _width; unsigned int _height; diff --git a/examples/osgframerenderer/osgframerenderer.cpp b/examples/osgframerenderer/osgframerenderer.cpp index 879acda3c..1719acd8e 100644 --- a/examples/osgframerenderer/osgframerenderer.cpp +++ b/examples/osgframerenderer/osgframerenderer.cpp @@ -17,7 +17,8 @@ struct ScreenShot : public osg::Camera::DrawCallback { - ScreenShot() {} + ScreenShot(bool flip): + _flip(flip) {} virtual void operator () (osg::RenderInfo& renderInfo) const { @@ -48,6 +49,8 @@ struct ScreenShot : public osg::Camera::DrawCallback image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(), GL_RGB, GL_UNSIGNED_BYTE, 1); + if (_flip) image->flipVertical(); + osgDB::writeImageFile(*image, outputFileName); } @@ -55,8 +58,9 @@ struct ScreenShot : public osg::Camera::DrawCallback typedef std::map CameraNumMap; - osg::ref_ptr _frameCapture; - CameraNumMap _cameraNumMap; + bool _flip; + osg::ref_ptr _frameCapture; + CameraNumMap _cameraNumMap; }; int main( int argc, char **argv ) @@ -226,6 +230,9 @@ int main( int argc, char **argv ) if (arguments.read("--offscreen")) fc->setOffscreen(true); if (arguments.read("--screen")) fc->setOffscreen(false); + if (arguments.read("--flip")) fc->setOutputImageFlip(true); + if (arguments.read("--no-flip")) fc->setOutputImageFlip(false); + unsigned int width = 1024; if (arguments.read("--width",width)) fc->setWidth(width); @@ -468,7 +475,7 @@ int main( int argc, char **argv ) viewer.realize(); // set up screen shot - osg::ref_ptr screenShot = new ScreenShot; + osg::ref_ptr screenShot = new ScreenShot(fc->getOutputImageFlip());; { osgViewer::Viewer::Cameras cameras;