From 5664c51cf0ee981c96b6ae1f74a93d889c182feb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 25 May 2008 21:52:32 +0000 Subject: [PATCH] Added option for setting whether the front or back buffer should be read using --front and --back command line options. --- .../osgscreencapture/osgscreencapture.cpp | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/examples/osgscreencapture/osgscreencapture.cpp b/examples/osgscreencapture/osgscreencapture.cpp index 1a9f0cd5f..eb9f09a16 100644 --- a/examples/osgscreencapture/osgscreencapture.cpp +++ b/examples/osgscreencapture/osgscreencapture.cpp @@ -52,10 +52,10 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback struct ContextData : public osg::Referenced { - ContextData(osg::GraphicsContext* gc, Mode mode, FramePosition position, const std::string& name): + ContextData(osg::GraphicsContext* gc, Mode mode, GLenum readBuffer, const std::string& name): _gc(gc), _mode(mode), - _position(position), + _readBuffer(readBuffer), _fileName(name), _pixelFormat(GL_BGR), _type(GL_UNSIGNED_BYTE), @@ -74,7 +74,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback // double buffer PBO. switch(_mode) { - case(READ_PIXELS): + case(READ_PIXELS): osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with out PixelBufferObject."<getGraphicsContext(); osg::ref_ptr cd = getContextData(gc); @@ -191,6 +185,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback Mode _mode; FramePosition _position; + GLenum _readBuffer; mutable OpenThreads::Mutex _mutex; mutable ContextDataMap _contextDataMap; @@ -566,14 +561,21 @@ int main(int argc, char** argv) // add the LOD Scale handler viewer.addEventHandler(new osgViewer::LODScaleHandler); + GLenum readBuffer = GL_BACK; WindowCaptureCallback::FramePosition position = WindowCaptureCallback::END_FRAME; - while (arguments.read("--start-frame")) position = WindowCaptureCallback::START_FRAME; + WindowCaptureCallback::Mode mode = WindowCaptureCallback::DOUBLE_PBO; + + while (arguments.read("--start-frame")) { position = WindowCaptureCallback::START_FRAME; readBuffer = GL_FRONT; } while (arguments.read("--end-frame")) position = WindowCaptureCallback::END_FRAME; - WindowCaptureCallback::Mode mode = WindowCaptureCallback::DOUBLE_PBO; + while (arguments.read("--front")) readBuffer = GL_FRONT; + while (arguments.read("--back")) readBuffer = GL_BACK; + while (arguments.read("--no-pbo")) mode = WindowCaptureCallback::READ_PIXELS; while (arguments.read("--single-pbo")) mode = WindowCaptureCallback::SINGLE_PBO; while (arguments.read("--double-pbo")) mode = WindowCaptureCallback::DOUBLE_PBO; + + // load the data osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); @@ -602,7 +604,7 @@ int main(int argc, char** argv) viewer.realize(); - addCallbackToViewer(viewer, new WindowCaptureCallback(mode, position)); + addCallbackToViewer(viewer, new WindowCaptureCallback(mode, position, readBuffer)); return viewer.run();