简体   繁体   中英

RGB image from osg::viewer

I have code which is something like this:

osgViewer::Viewer viewer;
viewer.setSceneData(scene);
viewer.setCameraManipulator( tracker.get() );
viewer.setUpViewInWindow(10,10,1024,768,0);
viewer.realize();

Now, this viewer object gives me a view of a scene which contains a vehicle model, terrain etc. I would like to get an RGB image out of this viewer, irrespective of how the data has been written into the scene.

Essentially, I want an RGB image from the viewer with no previous information as to what data is written into the scene. If the viewer shows something in a 1024*768 window, I want it as an RGB image.

If I understand you correctly, then the osg::ScreenCaptureHandler should fit your bill. It is part of the ViewerEventHandlers header located in include/osgViewer.

It is a simple event handler which, upon a key press, captures and stores an image of the current view. You can either use this or adapt it to your liking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM