screenshot a render to texture

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
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

screenshot a render to texture

Post by The_Glitch »

Is it possible to print one of my render to textures? I'm trying to work out post processing issue's and it would be really helpful If I could maybe do something similar to Irrlicht's print screen function.

Code: Select all

 
 
irr::video::IVideoDriver* const driver = device->getVideoDriver();
 
            //get image from the last rendered frame 
            irr::video::IImage* const rt = driver->createScreenShot();
            if (rt) //should always be true, but you never know. ;) 
            {
                //construct a filename, consisting of local time and file extension 
                irr::c8 filename[64];
                snprintf(filename, 64, "screenshot_%u.bmp", device->getTimer()->getRealTime());
 
                //write screen shot to file 
                if (!driver->writeImageToFile(rt, filename))
                    device->getLogger()->log(L"Failed to take screenshot.", irr::ELL_WARNING);
 
                //Don't forget to drop image since we don't need it anymore. 
                rt->drop();
 
            }
 
 
Like the above but have it use an already made render target texture so I can see in one steps or the post processing an issue is occurring.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: screenshot a render to texture

Post by hendu »

Code: Select all

void savetex(ITexture *tex) {
 
        IImage *tmp = g->irrdrv->createImage(tex, position2di(0,0), tex->getSize());
        stringc name = tex->getName().getPath();
        name += ".png";
        g->irrdrv->writeImageToFile(tmp, name.c_str());
        tmp->drop();
}
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: screenshot a render to texture

Post by The_Glitch »

Thanks hendu I'll try this later.
Post Reply