From 69407f4054c53c27f105b4745fa0fa1047f9c87b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Dec 2014 18:12:07 +0000 Subject: [PATCH] Removed redundent spaces git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14569 16af8721-9629-0410-8352-f15c8da7e697 --- .../osgscreencapture/osgscreencapture.cpp | 134 +++++++++--------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/examples/osgscreencapture/osgscreencapture.cpp b/examples/osgscreencapture/osgscreencapture.cpp index 9de19b634..1be926d20 100644 --- a/examples/osgscreencapture/osgscreencapture.cpp +++ b/examples/osgscreencapture/osgscreencapture.cpp @@ -1,9 +1,9 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * - * This application is open source and may be redistributed and/or modified + * This application is open source and may be redistributed and/or modified * freely and without restriction, both in commercial and non commercial applications, * as long as this copyright notice is maintained. - * + * * This application is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -36,7 +36,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback { public: - + enum Mode { READ_PIXELS, @@ -44,16 +44,16 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback DOUBLE_PBO, TRIPLE_PBO }; - + enum FramePosition { START_FRAME, END_FRAME }; - + struct ContextData : public osg::Referenced { - + ContextData(osg::GraphicsContext* gc, Mode mode, GLenum readBuffer, const std::string& name): _gc(gc), _mode(mode), @@ -81,46 +81,46 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback osg::notify(osg::NOTICE)<<"Select GL_BGRA read back format"<getTraits()) @@ -129,7 +129,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback height = gc->getTraits()->height; } } - + void updateTimings(osg::Timer_t tick_start, osg::Timer_t tick_afterReadPixels, osg::Timer_t tick_afterMemCpy, @@ -155,29 +155,29 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback readPixels(); } } - + void readPixels(); void singlePBO(osg::GLBufferObject::Extensions* ext); void multiPBO(osg::GLBufferObject::Extensions* ext); - + typedef std::vector< osg::ref_ptr > ImageBuffer; typedef std::vector< GLuint > PBOBuffer; - + osg::GraphicsContext* _gc; Mode _mode; GLenum _readBuffer; std::string _fileName; - + GLenum _pixelFormat; GLenum _type; int _width; int _height; - + unsigned int _currentImageIndex; ImageBuffer _imageBuffer; - + unsigned int _currentPboIndex; PBOBuffer _pboBuffer; @@ -188,7 +188,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback double _timeForMemCpy; osg::Timer_t _previousFrameTick; }; - + WindowCaptureCallback(Mode mode, FramePosition position, GLenum readBuffer): _mode(mode), _position(position), @@ -204,13 +204,13 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback filename << "test_"<<_contextDataMap.size()<<".jpg"; return new ContextData(gc, _mode, _readBuffer, filename.str()); } - + ContextData* getContextData(osg::GraphicsContext* gc) const { OpenThreads::ScopedLock lock(_mutex); osg::ref_ptr& data = _contextDataMap[gc]; if (!data) data = createContextData(gc); - + return data.get(); } @@ -222,16 +222,16 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback osg::ref_ptr cd = getContextData(gc); cd->read(); } - + typedef std::map > ContextDataMap; - Mode _mode; + Mode _mode; FramePosition _position; GLenum _readBuffer; mutable OpenThreads::Mutex _mutex; mutable ContextDataMap _contextDataMap; - - + + }; void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start, @@ -248,17 +248,17 @@ void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start, _timeForReadPixels += timeForReadPixels; _timeForFullCopy += timeForFullCopy; _timeForMemCpy += timeForMemCpy; - + ++_numTimeValuesRecorded; - + if (_numTimeValuesRecorded==_reportTimingFrequency) { timeForReadPixels = _timeForReadPixels/double(_numTimeValuesRecorded); timeForFullCopy = _timeForFullCopy/double(_numTimeValuesRecorded); timeForMemCpy = _timeForMemCpy/double(_numTimeValuesRecorded); - + double averageFrameTime = osg::Timer::instance()->delta_s(_previousFrameTick, tick_afterMemCpy)/double(_numTimeValuesRecorded); - double fps = 1.0/averageFrameTime; + double fps = 1.0/averageFrameTime; _previousFrameTick = tick_afterMemCpy; _timeForReadPixels = 0.0; @@ -341,14 +341,14 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensio } GLuint& pbo = _pboBuffer[0]; - + osg::Image* image = _imageBuffer[_currentImageIndex].get(); - if (image->s() != _width || + if (image->s() != _width || image->t() != _height) { osg::notify(osg::NOTICE)<<"Allocating image "<allocateImage(_width, _height, 1, _pixelFormat, _type); - + if (pbo!=0) { osg::notify(osg::NOTICE)<<"deleting pbo "<glGenBuffers(1, &pbo); @@ -384,7 +384,7 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::GLBufferObject::Extensio if(src) { memcpy(image->data(), src, image->getTotalSizeInBytes()); - + ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); } @@ -420,14 +420,14 @@ void WindowCaptureCallback::ContextData::multiPBO(osg::GLBufferObject::Extension GLuint& copy_pbo = _pboBuffer[_currentPboIndex]; GLuint& read_pbo = _pboBuffer[nextPboIndex]; - + osg::Image* image = _imageBuffer[_currentImageIndex].get(); - if (image->s() != _width || + if (image->s() != _width || image->t() != _height) { osg::notify(osg::NOTICE)<<"Allocating image "<allocateImage(_width, _height, 1, _pixelFormat, _type); - + if (read_pbo!=0) { osg::notify(osg::NOTICE)<<"deleting pbo "<glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); osg::Timer_t tick_afterMemCpy = osg::Timer::instance()->tick(); - + updateTimings(tick_start, tick_afterReadPixels, tick_afterMemCpy, image->getTotalSizeInBytes()); _currentImageIndex = nextImageIndex; @@ -506,7 +506,7 @@ void WindowCaptureCallback::ContextData::multiPBO(osg::GLBufferObject::Extension void addCallbackToViewer(osgViewer::ViewerBase& viewer, WindowCaptureCallback* callback) { - + if (callback->getFramePosition()==WindowCaptureCallback::START_FRAME) { osgViewer::ViewerBase::Windows windows; @@ -553,7 +553,7 @@ void addCallbackToViewer(osgViewer::ViewerBase& viewer, WindowCaptureCallback* c } } else - { + { osgViewer::ViewerBase::Windows windows; viewer.getWindows(windows); for(osgViewer::ViewerBase::Windows::iterator itr = windows.begin(); @@ -615,14 +615,14 @@ int main(int argc, char** argv) arguments.getApplicationUsage()->write(std::cout, helpType); return 1; } - + // report any errors if they have occurred when parsing the program arguments. if (arguments.errors()) { arguments.writeErrorMessages(std::cout); return 1; } - + if (arguments.argc()<=1) { arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); @@ -643,7 +643,7 @@ int main(int argc, char** argv) while (arguments.read("-p",pathfile)) { osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); - if (apm || !apm->valid()) + if (apm || !apm->valid()) { unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); @@ -657,13 +657,13 @@ int main(int argc, char** argv) // add the state manipulator viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); - + // add the thread model handler viewer.addEventHandler(new osgViewer::ThreadingHandler); // add the window size toggle handler viewer.addEventHandler(new osgViewer::WindowSizeHandler); - + // add the stats handler viewer.addEventHandler(new osgViewer::StatsHandler); @@ -691,12 +691,12 @@ int main(int argc, char** argv) while (arguments.read("--double-pbo")) mode = WindowCaptureCallback::DOUBLE_PBO; while (arguments.read("--triple-pbo")) mode = WindowCaptureCallback::TRIPLE_PBO; - + unsigned int width=1280; unsigned int height=1024; bool pbufferOnly = false; osg::ref_ptr pbuffer; - if (arguments.read("--pbuffer",width,height) || + if (arguments.read("--pbuffer",width,height) || (pbufferOnly = arguments.read("--pbuffer-only",width,height))) { osg::ref_ptr traits = new osg::GraphicsContext::Traits; @@ -724,10 +724,10 @@ int main(int argc, char** argv) } } - + // load the data osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); - if (!loadedModel) + if (!loadedModel) { std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; return 1; @@ -750,7 +750,7 @@ int main(int argc, char** argv) viewer.setSceneData( loadedModel.get() ); - + if (pbuffer.valid()) { osg::ref_ptr camera = new osg::Camera;