snap shot

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Evil Game Manic
Posts: 12
Joined: Sun Apr 23, 2006 11:05 pm

snap shot

Post by Evil Game Manic »

I was wondering how the heck does someone take a snapshot of their game or other 3d application using the irrlicht engine while its running?
I have seen people show a snapshot of their game in forums, and so it would be easier for others to help if i gave a visual when i have a question.
So if anyone could HELP :shock: , PLEASE DO :o
I'm not Game Manic
TheRLG
Posts: 372
Joined: Thu Oct 07, 2004 11:20 pm

Post by TheRLG »

What you've probably seen is the Print Screen button pressed... which can be useful, but we still need to implement a screenshot system.
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Post by xterminhate »

May help...

Code: Select all

void irrScreenshot( irr::video::IVideoDriver * driver, bool const & windowed, std::string const & filename )
{
    LPDIRECT3DSURFACE9 Surface = 0;
    if (windowed)
    {
        driver->getExposedVideoData().D3D9.D3DDev9->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &Surface);
        D3DXSaveSurfaceToFile(filename.c_str(), D3DXIFF_BMP, Surface, NULL, NULL);
    }
    else
    {
        int Width  = GetSystemMetrics(SM_CXSCREEN);
        int Height = GetSystemMetrics(SM_CYSCREEN);
        driver->getExposedVideoData().D3D9.D3DDev9->CreateOffscreenPlainSurface(Width, Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &Surface, NULL);
        driver->getExposedVideoData().D3D9.D3DDev9->GetFrontBufferData(NULL, Surface);
        D3DXSaveSurfaceToFile(filename.c_str(), D3DXIFF_BMP, Surface, NULL, NULL);
    }
    Surface->Release();
}
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
Cleves
Posts: 224
Joined: Mon Sep 08, 2003 6:40 pm

Post by Cleves »

xterminhate wrote:May help...

Code: Select all

void irrScreenshot( irr::video::IVideoDriver * driver, bool const & windowed, std::string const & filename )
{
    LPDIRECT3DSURFACE9 Surface = 0;
    if (windowed)
    {
        driver->getExposedVideoData().D3D9.D3DDev9->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &Surface);
        D3DXSaveSurfaceToFile(filename.c_str(), D3DXIFF_BMP, Surface, NULL, NULL);
    }
    else
    {
        int Width  = GetSystemMetrics(SM_CXSCREEN);
        int Height = GetSystemMetrics(SM_CYSCREEN);
        driver->getExposedVideoData().D3D9.D3DDev9->CreateOffscreenPlainSurface(Width, Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &Surface, NULL);
        driver->getExposedVideoData().D3D9.D3DDev9->GetFrontBufferData(NULL, Surface);
        D3DXSaveSurfaceToFile(filename.c_str(), D3DXIFF_BMP, Surface, NULL, NULL);
    }
    Surface->Release();
}
ohh, that's nice. Thanks. :D
TheRLG
Posts: 372
Joined: Thu Oct 07, 2004 11:20 pm

Post by TheRLG »

Anyone have this for OpenGL as well?
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Post by xterminhate »

I did not test it, but I think it also works in OGL mode.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
Post Reply