Hi,

On 20/05/11 12:27, Giulio De Vecchi wrote:
Hi all,
   I have a viewer from wihch i take some snapshot. The code is something like 
this:

r_Viewer = new osgViewer::Viewer();
r_Viewer->setSceneData(p_RootNode);
p_hWND = reinterpret_cast<HWND>  (wnd);
osg::ref_ptr<osg::GraphicsContext::Traits>  traits = new 
osg::GraphicsContext::Traits();
traits->inheritedWindowData = new osgViewer::GraphicsWindowWin32::WindowData( 
p_hWND );
[...]
  // some init stuff
[...]
osg::ref_ptr<osg::GraphicsContext>  gc = 
osg::GraphicsContext::createGraphicsContext (traits.get());
osg::ref_ptr<osg::Camera>  camera = r_Viewer->getCamera();
camera->setGraphicsContext (gc.get());
camera->setViewport (...);
camera->setProjectionMatrixAsPerspective (...);

p_ScreenShot = new osg::Image;
camera->attach(osg::Camera::COLOR_BUFFER, p_ScreenShot);

[...]
r_Viewer->frame();
// Note that i call "frame()" on demand.
[...]
p_ScreenShot->readPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE);
This last call should not be needed, because if you attach the image to the camera OSG does the readPixels for you.

If you want to manually read pixels you will have to do it in the camera callback so that the context is current.

jp




This work fine.
The question is: what if i need to take an offscreen screenshot?
In particular I need to take a snapshot of the same scene from a different 
point of view, but without render it.
Is this possible?
Thank you.

Best regards.
Giulio

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39594#39594





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


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.

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

Reply via email to