Hi everybody,
First, I want to state that I am aware there is already quite a few posts about
this. I read most of them, trying to understand what is wrong with my
application; now that this is said, I can also state that I did not find out
the solution.
Basically, I am trying to achieve the same thing as a lot of people, taking a
screenshot of my current view and writing it to file. I really tried a lot of
ways to get this working, in vain.
:
- I tried to use the ScreenCaptureHandler, but this doesn't allow me to achieve
what I want (I want to record several frames during a given period) because of
the fact that it only takes screenshots when you press a key.
- I tried to have a look at osgscreencapture, which is unfortunately too
complex for me to get it clearly.
- I tried the basic
Code:
osg::Image* temp = new osg::Image();
temp->readPixels(0, 0,
viewer->getCamera()->getGraphicsContext()->getTraits()->width,
viewer->getCamera()->getGraphicsContext()->getTraits()->height, GL_RGB,
GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*temp, toto.jpg);
which gives me the result I have now (a black jpg file).
- I also tried to put that code in a handler derived from GUIEventHandler
Code:
bool ScreenshotHandler::handle(const osgGA::GUIEventAdapter&
ea,osgGA::GUIActionAdapter& aa)
{
osg::View* viewTest = aa.asView();
osg::Image* temp = new osg::Image();
temp->readPixels(0, 0,
viewTest->getCamera()->getGraphicsContext()->getTraits()->width,
viewTest->getCamera()->getGraphicsContext()->getTraits()->height, GL_RGB,
GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*temp, "toto2.jpg");
return true;
}
that I add to the viewer, but I still get the same problem.
I really am starting to be in a rush for this project, and getting depressed by
the complexity of getting a simple shot of the view.
Please help!
Thank you!
Cheers,
Thomas[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26457#26457
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org