Screenshot resolution

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Screenshot resolution

Post by zielin »

Hello,

I wonder if is there possiblity to define resolution of printscreen?
In my application I'm rendering into resizable window. When window resizes, I call IVideoDriver::OnResize with new dimensions:

Code: Select all

 
    if (m_videoDriver != NULL)
    {
        m_videoDriver->OnResize(core::dimension2d<u32>(geometry().width() , geometry().height()));
 
        if (m_sceneManager->getActiveCamera() != NULL)
        {
            m_sceneManager->getActiveCamera()->setAspectRatio((irr::f32)geometry().width() / (irr::f32)geometry().height());
        }
    }
 
Now, when window is maximized I get screenshots with proportional higher resolution than resolution in smaller windows. I want to render scene using models with high resolution (it consumes about 20 secs.) so I thought it would be nice to do this in background in some invisible place, but it seems that Irrlicht is making screenshots of what is visible including scene size.
Is there possibility to make screenshots with definded resolution ?

The other problem is that when I'm using DirectX, I get on my printscreens other windows from others apps when theirs windows covers Irrlicht window during screenshot execution. That's why I'm looking for solution with rendering in background.

Thank's for any help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Screenshot resolution

Post by hybrid »

Better use render to texture and take the texture directly as image for further processing. This has no such restrictions and can be used with resolutions up to 8192x8192 typically (sometimes even larger)
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: Screenshot resolution

Post by zielin »

Ok, currently I have this code for saving my Textures into files but I get only black screenshots. They have set resolution prpoperly, but they are empty. Probably setting the cammera is obsolete so I only change rendering target, Nothing else. My rendering device is Directx9.

Code: Select all

 
 
irr:video::ITexture *texture =  m_videoDriver->addRenderTargetTexture(core::dimension2d<u32>(800, 600), "rt", irr::video::ECF_A8R8G8B8);
 
if (texture != NULL)
{
    if (m_videoDriver->setRenderTarget(texture, true, true, video::SColor(0,0,0,255)))
    {
        // Rendering runs in other thread, so when screenshot is taken, the rendering thread is locked. Here I make only one animation frame.
        m_videoDriver->beginScene();
        m_sceneManager->drawAll();
        m_videoDriver->endScene();
 
        video::IImage* image = m_videoDriver->createImageFromData( texture->getColorFormat(), texture->getSize(), texture->lock(), false );
 
        if (image != NULL)
        {
            // Variable 'fileName' is QString class from QT library. I pass const char * as file name to writeImageToFile
            m_videoDriver->writeImageToFile(image, fileName.toStdString().c_str());
            image->drop();
        }
 
        texture->drop();
        m_videoDriver->setRenderTarget(NULL);
        return true;
    }
}
 
Image files creates they have set resolution but as I wrote above, they are empty - only 7,3 KB.
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: Screenshot resolution

Post by zielin »

Partially I solved the problem. It was my mistake which comes from thread synchronization. Now it renders but i get black background. When I solve it I'll write why I get error.
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: Screenshot resolution

Post by zielin »

Ok, all errors resulted from my mistakes which were not connected with Irrlicht. Black screens were created when I was killling timerevent threads responsible for rendering frames. After cheange from killing timer to thread synchronization based on mutex everything started working fine. Now locking rendering thread, and taking ownership of rendering device for making screenshots works perfectly.
Post Reply