diff --git a/tests/media/Burning's Video-shotsInShots0.png b/tests/media/Burning's Video-shotsInShots0.png new file mode 100644 index 00000000..4f535724 Binary files /dev/null and b/tests/media/Burning's Video-shotsInShots0.png differ diff --git a/tests/media/Burning's Video-shotsInShots2.png b/tests/media/Burning's Video-shotsInShots2.png new file mode 100644 index 00000000..4f535724 Binary files /dev/null and b/tests/media/Burning's Video-shotsInShots2.png differ diff --git a/tests/media/Direct3D 9.0-shotsInShots0.png b/tests/media/Direct3D 9.0-shotsInShots0.png new file mode 100644 index 00000000..b118965c Binary files /dev/null and b/tests/media/Direct3D 9.0-shotsInShots0.png differ diff --git a/tests/media/Direct3D 9.0-shotsInShots2.png b/tests/media/Direct3D 9.0-shotsInShots2.png new file mode 100644 index 00000000..b118965c Binary files /dev/null and b/tests/media/Direct3D 9.0-shotsInShots2.png differ diff --git a/tests/media/Irrlicht Software Driver 1.0-shotsInShots0.png b/tests/media/Irrlicht Software Driver 1.0-shotsInShots0.png new file mode 100644 index 00000000..70d2d497 Binary files /dev/null and b/tests/media/Irrlicht Software Driver 1.0-shotsInShots0.png differ diff --git a/tests/media/Irrlicht Software Driver 1.0-shotsInShots2.png b/tests/media/Irrlicht Software Driver 1.0-shotsInShots2.png new file mode 100644 index 00000000..70d2d497 Binary files /dev/null and b/tests/media/Irrlicht Software Driver 1.0-shotsInShots2.png differ diff --git a/tests/media/OpenGL-shotsInShots0.png b/tests/media/OpenGL-shotsInShots0.png new file mode 100644 index 00000000..e8339353 Binary files /dev/null and b/tests/media/OpenGL-shotsInShots0.png differ diff --git a/tests/media/OpenGL-shotsInShots2.png b/tests/media/OpenGL-shotsInShots2.png new file mode 100644 index 00000000..e8339353 Binary files /dev/null and b/tests/media/OpenGL-shotsInShots2.png differ diff --git a/tests/screenshot.cpp b/tests/screenshot.cpp index 51f31489..42d5a691 100644 --- a/tests/screenshot.cpp +++ b/tests/screenshot.cpp @@ -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(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; } diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 0183f9bd..13f82e62 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -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 +