- Timestamp:
- 05/25/08 23:52:32 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgscreencapture/osgscreencapture.cpp
r8338 r8339 53 53 { 54 54 55 ContextData(osg::GraphicsContext* gc, Mode mode, FramePosition position, const std::string& name):55 ContextData(osg::GraphicsContext* gc, Mode mode, GLenum readBuffer, const std::string& name): 56 56 _gc(gc), 57 57 _mode(mode), 58 _ position(position),58 _readBuffer(readBuffer), 59 59 _fileName(name), 60 60 _pixelFormat(GL_BGR), … … 75 75 switch(_mode) 76 76 { 77 case(READ_PIXELS): 77 case(READ_PIXELS): 78 78 osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with out PixelBufferObject."<<std::endl; 79 79 break; … … 133 133 osg::GraphicsContext* _gc; 134 134 Mode _mode; 135 FramePosition _position;135 GLenum _readBuffer; 136 136 std::string _fileName; 137 137 … … 148 148 }; 149 149 150 WindowCaptureCallback(Mode mode, FramePosition position ):150 WindowCaptureCallback(Mode mode, FramePosition position, GLenum readBuffer): 151 151 _mode(mode), 152 _position(position) 152 _position(position), 153 _readBuffer(readBuffer) 153 154 { 154 155 } … … 160 161 std::stringstream filename; 161 162 filename << "test_"<<_contextDataMap.size()<<".jpg"; 162 return new ContextData(gc, _mode, _ position, filename.str());163 return new ContextData(gc, _mode, _readBuffer, filename.str()); 163 164 } 164 165 … … 174 175 virtual void operator () (osg::RenderInfo& renderInfo) const 175 176 { 176 if (_position==START_FRAME) 177 { 178 glReadBuffer(GL_FRONT); 179 } 180 else 181 { 182 glReadBuffer(GL_BACK); 183 } 177 glReadBuffer(_readBuffer); 184 178 185 179 osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext(); … … 192 186 Mode _mode; 193 187 FramePosition _position; 188 GLenum _readBuffer; 194 189 mutable OpenThreads::Mutex _mutex; 195 190 mutable ContextDataMap _contextDataMap; … … 567 562 viewer.addEventHandler(new osgViewer::LODScaleHandler); 568 563 564 GLenum readBuffer = GL_BACK; 569 565 WindowCaptureCallback::FramePosition position = WindowCaptureCallback::END_FRAME; 570 while (arguments.read("--start-frame")) position = WindowCaptureCallback::START_FRAME; 566 WindowCaptureCallback::Mode mode = WindowCaptureCallback::DOUBLE_PBO; 567 568 while (arguments.read("--start-frame")) { position = WindowCaptureCallback::START_FRAME; readBuffer = GL_FRONT; } 571 569 while (arguments.read("--end-frame")) position = WindowCaptureCallback::END_FRAME; 572 570 573 WindowCaptureCallback::Mode mode = WindowCaptureCallback::DOUBLE_PBO; 571 while (arguments.read("--front")) readBuffer = GL_FRONT; 572 while (arguments.read("--back")) readBuffer = GL_BACK; 573 574 574 while (arguments.read("--no-pbo")) mode = WindowCaptureCallback::READ_PIXELS; 575 575 while (arguments.read("--single-pbo")) mode = WindowCaptureCallback::SINGLE_PBO; 576 576 while (arguments.read("--double-pbo")) mode = WindowCaptureCallback::DOUBLE_PBO; 577 578 577 579 578 580 // load the data … … 603 605 viewer.realize(); 604 606 605 addCallbackToViewer(viewer, new WindowCaptureCallback(mode, position ));607 addCallbackToViewer(viewer, new WindowCaptureCallback(mode, position, readBuffer)); 606 608 607 609 return viewer.run();
