Merging r6288 through r6336 from trunk to ogl-es branch
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6337 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@@ -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,82 @@ 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->getOriginalSize()), 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());
|
||||
if ( !result )
|
||||
{
|
||||
logTestString("driver color format: %s\n", video::ColorFormatNames[driver->getColorFormat()]);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user