Add another screenshot test

Drawing the screenshot itself before taking final result to see if the problem is in the render or the screenshot
Note: Test-images for software-drivers show some other problems there which this test wasn't about.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6322 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2022-03-29 20:24:24 +00:00
parent aa839d45a1
commit ddb2028231
10 changed files with 75 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

@ -5,10 +5,10 @@
using namespace irr;
static irr::u8 aa = 0; // AntiAlias used in testShotsInShots
// Tests screenshots features
bool testShots(video::E_DRIVER_TYPE type)
static bool testShots(video::E_DRIVER_TYPE type)
{
IrrlichtDevice *device = createDevice(type, core::dimension2d<u32>(160, 120), 32);
if (!device)
@ -75,9 +75,78 @@ bool testShots(video::E_DRIVER_TYPE type)
return true;
}
// render some recognizable stuff
static void drawSomeStuff(video::IVideoDriver* driver)
{
driver->draw2DRectangle(core::recti(5,5,155,115),
video::SColor(255, 100, 0, 0),
video::SColor(255, 0, 200, 0),
video::SColor(255, 0, 0, 200),
video::SColor(255, 20, 150, 150));
driver->draw2DLine(core::position2di(10,10), core::position2di(150,110), video::SColor(255,250,50,0));
driver->draw2DLine(core::position2di(0,120), core::position2di(80,60), video::SColor(255,50,50,250));
}
// Make a screenshot, then draw it again (scaled down) together with the stuff the screenshot was made from
static bool testShotsOfShots(video::E_DRIVER_TYPE type)
{
SIrrlichtCreationParameters params;
params.AntiAlias = aa;
params.WindowSize = core::dimension2du(160, 120);
params.DriverType = type;
IrrlichtDevice *device = createDeviceEx(params);
if (!device)
return true; // in case the driver type does not exist
video::IVideoDriver* driver = device->getVideoDriver();
logTestString("Testing driver %ls\n", driver->getName());
stabilizeScreenBackground(driver);
device->run();
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,100,101,140));
drawSomeStuff(driver);
driver->endScene();
video::IImage* img = driver->createScreenShot();
bool result = true;
if ( img )
{
video::ITexture * screenshot = driver->addTexture(io::path("firstScreenshot"), img);
driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,100,101,140));
drawSomeStuff(driver);
driver->draw2DImage(screenshot, core::recti(0, 30, 80, 90), core::recti(screenshot->getSize()), 0, 0, 0);
driver->endScene();
img->drop();
irr::core::stringc name("-shotsInShots");
name += irr::core::stringc((int)aa);
name += ".png";
result = takeScreenshotAndCompareAgainstReference(driver, name.c_str());
}
else
{
logTestString("Failed to create a screenshot");
result = false;
}
device->closeDevice();
device->run();
device->drop();
return result;
}
bool screenshot()
{
bool result = true;
TestWithAllHWDrivers(testShots);
aa = 0;
TestWithAllDrivers(testShotsOfShots);
aa = 2; // testing something that might cause troubles with Nouveau on some systems
TestWithAllDrivers(testShotsOfShots);
return result;
}

@ -1,4 +1,4 @@
Tests finished. 72 tests of 72 passed.
Compiled as DEBUG
Test suite pass at GMT Mon Mar 28 22:09:50 2022
Tests finished. 72 tests of 72 passed.
Compiled as DEBUG
Test suite pass at GMT Tue Mar 29 20:20:24 2022