Hi opensg friends,

i am back on my former screenshots problem.
I am running OpneSG in client-server mode,
with the client setting up the scene and controlling the navigation and the
server simply executing the render itself.

I want to take screenshots of the remote scene and save the images back to
the client. Doing it via the GrabForeGround ends up in client-side empty
pngs. Just to be sure that the foregrounds are working, I paired to the grab
Foreground a FileGrabForeground, which saves pngs remotely without a
problem.

My code looks like:

        fgndImage = osg::FileGrabForeground::create();
        
        beginEditCP(fgndImage);
                fgndImage->setIncrement(false);
                fgndImage->setAutoResize(true);
                fgndImage->setActive(false);
        endEditCP(fgndImage);

        fgndImageGrabber = GrabForeground::create();
        image = osg::Image::create();
        beginEditCP(image);
        image->set(Image::OSG_BGRA_PF,300,300);
        endEditCP(image);

        beginEditCP(fgndImageGrabber);
                fgndImageGrabber->setImage (image);
                fgndImageGrabber->setAutoResize(true);
                fgndImageGrabber->setActive(false);
        endEditCP(fgndImageGrabber);

        osg::ViewportPtr vpr = mwin->getPort (0);

        beginEditCP(vpr);
                vpr->getForegrounds().push_back(fgndImage);             
                vpr->getForegrounds().push_back(fgndImageGrabber);      
                vpr->setRoot(scene);
                vpr->setSize(0,0,1,1);
                vpr->setBackground(gb);
        endEditCP(vpr);




and the screenshot routine is simply:

void takeScreenshot ()
{
        static int i = 0;

        char buf[40];
        sprintf (buf,"./screenshots/image%d.png",i++);

        printf ("Shot %s\n",buf);

        beginEditCP(fgndImage/*, osg::GrabForeground::ImageFieldMask*/);
                fgndImage->setName(buf);
        endEditCP(fgndImage);

        beginEditCP(fgndImageGrabber/*,
osg::GrabForeground::ImageFieldMask*/);
                fgndImageGrabber->setActive(true);
        endEditCP(fgndImageGrabber);

        beginEditCP(fgndImage);
                fgndImage->setActive(true);
        endEditCP(fgndImage);

                        mgr->redraw();
// render pass

        beginEditCP(fgndImageGrabber);
                fgndImageGrabber->setActive(false);
        endEditCP(fgndImageGrabber);
        beginEditCP(fgndImage);
                fgndImage->setActive(false);
        endEditCP(fgndImage);

        image->write (buf);
}


Does anyone can find a reason why I can't get the pixmaps locally? 
I'd like to get 'em back to the client cause the final goal is to shrink all
the pngs to a single AVI (since I don't seem to be able to get the
avforeground working)

Thanks a lot,
E.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to