Commit 2fb61c69 authored by hybrid's avatar hybrid

Add a test case for correctly aligned pixel rendering. Not yet working for Direct3d

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3690 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7b4ef0e4
...@@ -15,7 +15,7 @@ using namespace gui; ...@@ -15,7 +15,7 @@ using namespace gui;
One line should run from green at the top left to red at the bottom right. One line should run from green at the top left to red at the bottom right.
The other should run from cyan 100% transparent at the bottom left to The other should run from cyan 100% transparent at the bottom left to
cyan 100% opaque at the top right. */ cyan 100% opaque at the top right. */
static bool runTestWithDriver(E_DRIVER_TYPE driverType) static bool lineRender(E_DRIVER_TYPE driverType)
{ {
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32); IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device) if (!device)
...@@ -53,21 +53,84 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType) ...@@ -53,21 +53,84 @@ static bool runTestWithDriver(E_DRIVER_TYPE driverType)
return result; return result;
} }
// this test draws alternating white and black borders with
// increasing thickness. Intended use of this test is to ensure
// the corect pixel alignment within the render window.
static bool pixelAccuracy(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
device->getSceneManager()->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
u32 start=0;
for (u32 count=1; count<10; ++count)
{
for (u32 j=0; j<count; ++j)
{
for (u32 x=0; x<100-start; ++x)
{
driver->drawPixel(start+x, start, (count%2==1)?0xffffffff:0xff000000);
}
++start;
}
}
start=0;
for (u32 count=1; count<10; ++count)
{
for (u32 j=0; j<count; ++j)
{
for (u32 x=0; x<100-start; ++x)
{
driver->drawPixel(start, start+x, (count%2==1)?0xffffffff:0xff000000);
}
++start;
}
}
for (u32 x=0; x<100; ++x)
{
driver->drawPixel(x, x, 0xffff0000);
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-pixelAccuracy.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool drawPixel(void) bool drawPixel(void)
{ {
bool passed = true; bool passed = true;
logTestString("Check OpenGL driver\n"); logTestString("Check OpenGL driver\n");
passed &= runTestWithDriver(EDT_OPENGL); passed &= lineRender(EDT_OPENGL);
logTestString("Check Software driver\n");
passed &= lineRender(EDT_SOFTWARE);
logTestString("Check Burning's Video driver\n");
passed &= lineRender(EDT_BURNINGSVIDEO);
logTestString("Check Direct3D9 driver\n");
passed &= lineRender(EDT_DIRECT3D9);
logTestString("Check Direct3D8 driver\n");
passed &= lineRender(EDT_DIRECT3D8);
logTestString("Check OpenGL driver\n");
passed &= pixelAccuracy(EDT_OPENGL);
logTestString("Check Software driver\n"); logTestString("Check Software driver\n");
passed &= runTestWithDriver(EDT_SOFTWARE); passed &= pixelAccuracy(EDT_SOFTWARE);
logTestString("Check Burning's Video driver\n"); logTestString("Check Burning's Video driver\n");
passed &= runTestWithDriver(EDT_BURNINGSVIDEO); passed &= pixelAccuracy(EDT_BURNINGSVIDEO);
logTestString("Check Direct3D9 driver\n"); logTestString("Check Direct3D9 driver\n");
passed &= runTestWithDriver(EDT_DIRECT3D9); passed &= pixelAccuracy(EDT_DIRECT3D9);
logTestString("Check Direct3D8 driver\n"); logTestString("Check Direct3D8 driver\n");
passed &= runTestWithDriver(EDT_DIRECT3D8); passed &= pixelAccuracy(EDT_DIRECT3D8);
return passed; return passed;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment