thanks for Robert's kind answers.
 Currently, my osg version is 3.3.1, and I  used the QUAD_BUFFER stereo mode.
 Next, I will try Robert's suggestion, using glReadBuffer()  and glReadPixles().
 thanks very much again. @Robert
 
 whu







At 2014-12-08 22:47:13, "c" <[email protected]> wrote:

Hi Whu,


How to capture stereo images will depend upon what type of stereo your 
application is using and which version of the OSG you are using.


The code you have provided might be roughly how you'd approach capturing a quad 
buffer stereo setup.  You'd need to change the Camera::setReadBuffer() call to 
glReadBuffer() call as the Camera::setReadBuffer() method only changes internal 
settings of the Camera, it' doesn't apply anything OpenGL right away - these 
setting is only used when the Camera's subgraph is being rendered.


Robert.



On 8 December 2014 at 12:12, whu <[email protected]> wrote:

Dear all,
I was still trying to fetch the left-eye and right-eye images in the stereo 
mode.
code as follow:

class:  class CaptureDrawCallBack : public osg::Camera::DrawCallback
the key overload function:

void operator()(osg::RenderInfo &renderInfo) const
    {
    // capture , bool ,when I want to capture the screen,key press event will 
switch it to be true.
     if(capture)
     {
      // osg::ref_ptr<osg::Image> _imageL, _imageR
        _imageL->allocateImage(scwidth,scheight,1,GL_RGBA,GL_UNSIGNED_BYTE);
        _imageR->allocateImage(scwidth,scheight,1,GL_RGBA,GL_UNSIGNED_BYTE);
        renderInfo.getCurrentCamera()->setReadBuffer(GL_BACK_LEFT);
        _imageL->readPixels(0,0,scwidth,scheight,GL_RGBA,GL_UNSIGNED_BYTE);
        osgDB::writeImageFile(*(_imageL.get()),fileNmaeL);
        renderInfo.getCurrentCamera()->setReadBuffer(GL_BACK_RIGHT);
        _imageR->readPixels(0,0,scwidth,scheight,GL_RGBA,GL_UNSIGNED_BYTE);
       osgDB::writeImageFile(*(_imageR.get()),fileNmaeR);
       capture = false;
      }
    }
  
   and in the main viewer's camera:
        viewer->getCamera()->setPostDrawCallback(new CaptureDrawCallBack());
  
   the program runs successfully(thoug no high effect ,just to test the 
function), with a  quadro card supproted, I can see the stero effect.
 
  but when I capture the screen :
   the two images saved by the above operation are the same, not as expected: a 
left-eye iamge, a right-eye image.

  can some one give me some suggestions?

  online waiting.
 
  thanks.

  whu




_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to