With standard Open Inventor coding, pressing the 'p' key generates an offscreen image of the displayed scene.
SoDirectVizManager