You should render the scene and call createScreenShot which will give you an image of the scene. The image can be saved using the image writers. Check the demo code for the actual code required. Or read the API docs.
There is a demo application that comes as part of the Irrlicht SDK download. You just need to look at the source code for the demo. It has code that does lots of stuff that users frequently ask about.
By definition a screenshot includes everything that you see on the screen. The screenshot is actually a capture of the back or front buffer, so if you draw the gui then you will see the gui in the screenshot.
And greenya is right. You need to render the entire scene and then take your screenshot. If you just use the scene manager to render stuff, then that is pretty easy.
void takePhotoOfScene(IVideoDriver* driver, ISceneManager* smgr, const char* fileName)
{
// redraw the entire scene
if (driver->beginScene(true, true, video::SColor(255, 0, 0, 0)))
{
smgr->drawAll();
driver->endScene();
}
// take the screenshot
IImage* photo = driver->createScreenShot();
if (photo)
{
driver->writeImageToFile(photo, fileName);
photo->drop();
}
}
Unfortunately this might cause the screen to appear for a second without the GUI. This may be okay for your application. If it is not, I suggest you implement a render to texture solution and then just write that texture out using the writeImageToFile() function.
i use this photo function in a non fullscreen window. it works very good. I can resize the window and takeing photos without any problem. But if i click on the maximize button and then on my photo button the application breaks whith following message: An unhandled exception of type 'System.AccessViolationException' occurred in blabla.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
im thinking the problem is comming from the fact that the shot will be made to match what ever reslution and screen startup settings its originaly coded for .
i.e . if you have your app set to go windowed it will work in that mode only unless you add a if statement or possibly a case to define the different modes you want it to work in.
Hi! I mean the maximize button of the engine window and not the "pure" fullscreen mode. If the window is maximized that error will occure. In fullscreen mode it works perfect.