[osg-users] Best method for screencapture in OSG?

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Tue Sep 23 09:55:56 PDT 2008


Hello Stephen,

> Can any give insight into the benefits of the different means of getting a
> screen capture that can be transferred back to CPU/main memory?
> The app uses OSG to model a camera on the network and streams jpeg images
> at a target of 30Hz to client nodes.

I don't know the details, but as I understand the osgscreencapture 
example (which you should have in your OSG 2.6+ source tree) is designed 
to be a testbed for doing something similar to what you describe.

The osgViewer::ScreenCaptureHandler which I submitted (also in 2.6) was 
based on that example, but extended to give access to a user-overridable 
ScreenCaptureOperation which could do anything with the captured image - 
the default is to save the image to the disk but it could be to send it 
to a remote machine... So at a high level, you could use this handler.

The only problem I can see with using the ScreenCaptureHandler in your 
case is that it will remove itself after having captured a frame. It was 
designed to take screenshots based on a key press, for example, so that 
seemed a sensible thing to do. In your case, you would need to capture 
all frames, so the callback shouldn't remove itself. It would be simple 
to extend the handler to have a "remove after capture" Boolean flag.

I think it could also be extended to specify which buffer to capture 
(color, depth, ...) but I'm not sure.

This doesn't address your lower-level questions, and I'm not the best 
placed to answer them since I just took what Robert had done in the 
osgscreencapture handler and refactored it to be an event handler. 
Perhaps others will have better answers.

Hope this helps,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/



More information about the osg-users mailing list