IVideoDriver::createScreenShot() worries

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

IVideoDriver::createScreenShot() worries

Post by randomMesh »

I am using this code for taking screenshots in my application:

Code: Select all

void Game::makeScreenshot() const
{
	//get video::IImage from the last rendered frame
	irr::video::IImage* const image = this->videoDriver->createScreenShot();

	if (image) //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, "capture/screenshot_%u.png", this->timer->getRealTime());

		//write screenshot to file
		if (this->videoDriver->writeImageToFile(image, filename))
			this->device->getLogger()->log(L"Screenshot taken.");
		else
			this->device->getLogger()->log(L"Failed to take screenshot. Maybe you need to create the capture folder.");

		//Don't forget to drop image since we don't need it anymore.
		image->drop();
	}
}
In fullscreen mode all works as expected, but in window mode, the screenshot only contains my desktop, the window is invisible.

Could anyone please confirm?

Btw.: OpenGL, Windows XP, mingw, latest SVN trunk
Last edited by randomMesh on Mon Aug 04, 2008 5:44 pm, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I know I did extensive testing with screenshots in both windowed and fullscreen mode when writing the code originally. I know that there is an issue with capturing windows on top of the render area (say task manager is running with the force to top window style) when using the D3D driver, but I didn't see any way around that.

Travis
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Seems to work fine for me...

Code: Select all

#include <irrlicht.h>
using	namespace	irr;

#ifdef _MSC_VER
#	 pragma	comment(lib, "Irrlicht.lib")
#endif


class	MyEventReceiver	:	public IEventReceiver	
{	
  IrrlichtDevice*	Device;

public:	
  MyEventReceiver(IrrlichtDevice*	device)	
    :	Device(device) 
  { 
  } 

  virtual bool	OnEvent(const	SEvent&	event) 
  { 
    // if	shift	is down	and	mouse	clicked, then	do collision test	
    if (event.EventType	== EET_KEY_INPUT_EVENT &&	
      event.KeyInput.PressedDown &&	event.KeyInput.Key ==	'1') 
    {
      video::IVideoDriver* driver	=	Device->getVideoDriver();

      video::IImage* image = driver->createScreenShot(); 
      if (image)
      {	
        c8 filename[64]; 
        snprintf(filename, 64, "screenshot_%u.jpg",	Device->getTimer()->getRealTime());	

        const	bool success = driver->writeImageToFile(image, filename);

        image->drop(); 

        return success;
      }	
    }	

    return false;	
  } 
}; 


int	main() 
{
  IrrlichtDevice*	device = createDevice(video::EDT_DIRECT3D8,	core::dimension2d<s32>(800,	600),	16,	false, false,	0);	

  MyEventReceiver	receiver (device);
  device->setEventReceiver (&receiver);

  scene::ISceneManager*	smgr = device->getSceneManager();	
  smgr->loadScene("../../media/example.irr");
  smgr->addCameraSceneNodeFPS	();

  video::IVideoDriver* driver	=	device->getVideoDriver();	
  while(device->run()) 
  {	
    if (driver->beginScene(true, true, video::SColor(255,100,100,100)))
    {
      smgr->drawAll(); 

      driver->endScene();	
    }
  }	

  device->drop();	

  return 0;	
}	
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

vitek wrote:

Code: Select all

IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D8,	core::dimension2d<s32>(800,	600),	16,	false, false,	0);
I use OpenGL. Can't test with DirectX since i have no SDK installed.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, since we changed from backbuffer to frontbuffer for OpenGL there will also be a problem with overlapping windows. There's no way around (besides separate rendering into offscreen areas) since the OpenGL specs allow to skip rendering in hidden areas. At least D3D and OpenGL do the same here...
I couldn't reproduce this, yet, because I don't have a windows machine at hand.
Post Reply