From cc07d064bf1efd3b6eabb8690c09c741cbec2a8d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sat, 24 May 2008 08:13:55 +0000 Subject: [PATCH] Changed default format to GL_BGR --- .../osgscreencapture/osgscreencapture.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/osgscreencapture/osgscreencapture.cpp b/examples/osgscreencapture/osgscreencapture.cpp index 581187627..1f51d82e6 100644 --- a/examples/osgscreencapture/osgscreencapture.cpp +++ b/examples/osgscreencapture/osgscreencapture.cpp @@ -50,7 +50,7 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback _gc(gc), _mode(mode), _fileName(name), - _pixelFormat(GL_RGB), + _pixelFormat(GL_BGR), _type(GL_UNSIGNED_BYTE), _width(0), _height(0), @@ -193,8 +193,10 @@ void WindowCaptureCallback::ContextData::readPixels() osg::Image* image = _imageBuffer[_currentImageIndex].get(); +#if 1 image->readPixels(0,0,_width,_height, _pixelFormat,_type); +#endif if (!_fileName.empty()) { @@ -251,7 +253,9 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo); } +#if 1 glReadPixels(0, 0, _width, _height, _pixelFormat, _type, 0); +#endif GLubyte* src = (GLubyte*)ext->glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB); @@ -314,6 +318,16 @@ void WindowCaptureCallback::ContextData::multiPBO(osg::BufferObject::Extensions* } + bool doCopy = copy_pbo!=0; + if (copy_pbo==0) + { + ext->glGenBuffers(1, ©_pbo); + ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, copy_pbo); + ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ); + + osg::notify(osg::NOTICE)<<"Generating pbo "<glGenBuffers(1, &read_pbo); @@ -327,10 +341,11 @@ void WindowCaptureCallback::ContextData::multiPBO(osg::BufferObject::Extensions* ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, read_pbo); } +#if 1 glReadPixels(0, 0, _width, _height, _pixelFormat, _type, 0); +#endif - - if (copy_pbo!=0) + if (doCopy) { ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, copy_pbo);