createScreenShot not working with DirectX

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.

createScreenShot not working with DirectX

Postby kkrizka » Thu Oct 23, 2008 6:47 am

Hi all,

I tried to use the createScreenShot method to grab the last rendered frame of a scene and save it to a file. However when I save it, the file contains an empty image...

I managed to reproduce this problem with the 01.HelloWord example by having the main loop contain the following lines:

Code: Select all
driver->beginScene(true, true, SColor(255,100,101,140));

smgr->drawAll();
guienv->drawAll();
driver->endScene();

IImage *ss=driver->createScreenShot();
driver->writeImageToFile(ss,"test.png");


The same code works when I use the OpenGL or Software renders. It only fails if I use DirectX 9.
Cheers,
Karol Krizka

http://www.krizka.net
kkrizka
 
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

Postby Acki » Thu Oct 23, 2008 1:48 pm

what Irrlicht version you are using ???
it works well for me with v1.4.2 !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
User avatar
Acki
 
Posts: 3474
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)

Postby kkrizka » Fri Oct 24, 2008 12:28 am

I'm using the latest SVN.
Cheers,
Karol Krizka

http://www.krizka.net
kkrizka
 
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

Postby pc0de » Fri Oct 24, 2008 4:59 am

I'm having a similar problem with the latest SVN. It appears that all of the "DirectX" generated pixel alpha values are 0.
pc0de
 
Posts: 300
Joined: Wed Dec 05, 2007 4:41 pm

Postby rogerborg » Fri Oct 24, 2008 10:55 am

Indeed, I'm getting a format of D3DFMT_X8R8G8B8, which doesn't promise to deliver an alpha, and the values are 0.

SVN 1641 adds a check for that format and the presented alpha in the first pixel, and if necessary, forces each pixel's alpha to 255 (ouch). Suggestions for a better solution would be gratefully received.

The other issue is that the D3D9 screenshot process is excruciatingly slow, and this fix certainly won't help.

Heh, it looks like Burning screenshots are spannered as well. The alpha on the background is fine, but it appears to be 0 for any rendered pixels. That'll need looking at independently.

Test app follows. Verification that this fixes it for D3D8 and D3D9 would be much appreciated. Thanks for the report and investigation.

Code: Select all
#include "irrlicht.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif


bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
    IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(640, 480));
    if (!device)
        return false;
   
    IVideoDriver* driver = device->getVideoDriver();
   ISceneManager * smgr = device->getSceneManager();

   IAnimatedMeshSceneNode * node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"));
   node->setMaterialFlag(EMF_LIGHTING, false);
   smgr->addCameraSceneNode(0, vector3df(0, 20, -30));

    driver->beginScene(true, true, SColor(255,100,101,140));
   smgr->drawAll();
    driver->endScene();

   IImage * screenshot = driver->createScreenShot();
   bool result = true;

   if(screenshot)
   {
      stringc filename(driver->getName());
      filename += ".png";
      result = driver->writeImageToFile(screenshot, filename.c_str());
      screenshot->drop();

      stringc openFile("\"");
      openFile += filename;
      openFile += "\"";
      (void)system(openFile.c_str());
   }

   device->drop();

   return result;
}


int main()
{
    bool passed = true;

    passed &= runTestWithDriver(EDT_NULL);
    passed &= runTestWithDriver(EDT_SOFTWARE);
    passed &= runTestWithDriver(EDT_BURNINGSVIDEO);
    passed &= runTestWithDriver(EDT_OPENGL);
    passed &= runTestWithDriver(EDT_DIRECT3D8);
    passed &= runTestWithDriver(EDT_DIRECT3D9);
   
    return passed ? 0 : 1;
}
Last edited by rogerborg on Fri Oct 24, 2008 7:41 pm, edited 1 time in total.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
User avatar
rogerborg
Admin
 
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh

Postby pc0de » Fri Oct 24, 2008 1:54 pm

1641 fixes the D3D9 output for me.

Looks like I missed the announcement regarding the new name appearing in the svn log :) Congratulations!
pc0de
 
Posts: 300
Joined: Wed Dec 05, 2007 4:41 pm


Return to Bug reports

Who is online

Users browsing this forum: No registered users and 0 guests