aboutsummaryrefslogtreecommitdiff
path: root/tests/makeColorKeyTexture.cpp
diff options
context:
space:
mode:
authorcutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>2020-01-03 19:05:16 +0000
committercutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>2020-01-03 19:05:16 +0000
commit2ae2a551a6290f46734307bbfdafea4b1a2cf2ba (patch)
treeba2f0b468640e44899fed3df2d4cc58795f4a003 /tests/makeColorKeyTexture.cpp
downloadirrlicht-2ae2a551a6290f46734307bbfdafea4b1a2cf2ba.tar.xz
Merging r5975 through r6036 from trunk to ogl-es branch.
GLES drivers adapted, but only did make compile-tests. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6038 dfc29bdd-3216-0410-991c-e03cc46cb475
Diffstat (limited to 'tests/makeColorKeyTexture.cpp')
-rw-r--r--tests/makeColorKeyTexture.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/makeColorKeyTexture.cpp b/tests/makeColorKeyTexture.cpp
new file mode 100644
index 0000000..288a426
--- /dev/null
+++ b/tests/makeColorKeyTexture.cpp
@@ -0,0 +1,74 @@
+// Copyright (C) 2008-2012 Colin MacDonald
+// No rights reserved: this software is in the public domain.
+
+#include "testUtils.h"
+
+using namespace irr;
+using namespace core;
+using namespace scene;
+using namespace video;
+
+/** Test the behaviour of makeColorKeyTexture() using both 16 bit (software)
+ and 32 bit (Burning) textures, with the new behaviour and the legacy
+ behaviour. */
+static bool doTestWith(E_DRIVER_TYPE driverType,
+ bool zeroTexels)
+{
+ IrrlichtDevice *device = createDevice( driverType,
+ dimension2d<u32>(160, 120), 32);
+ if (!device)
+ return false;
+
+ IVideoDriver* driver = device->getVideoDriver();
+ ISceneManager * smgr = device->getSceneManager();
+
+ // Draw a cube background so that we can check that the keying is working.
+ ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
+ cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
+ cube->setMaterialFlag(video::EMF_LIGHTING, false);
+
+ ITexture * Texture = device->getVideoDriver()->getTexture("../media/portal2.bmp");
+
+ device->getVideoDriver()->makeColorKeyTexture(Texture,
+ position2d<s32>(64,64),
+ zeroTexels);
+ device->getVideoDriver()->makeColorKeyTexture(Texture,
+ position2d<s32>(64,64),
+ zeroTexels);
+ (void)smgr->addCameraSceneNode();
+
+ driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
+ smgr->drawAll();
+
+ driver->draw2DImage(Texture,
+ position2di(40, 40),
+ rect<s32>(0, 0, Texture->getSize().Width, Texture->getSize().Height),
+ 0,
+ SColor(255,255,255,255),
+ true);
+ driver->endScene();
+
+ char screenshotName[256];
+ (void)snprintf_irr(screenshotName, 256, "-makeColorKeyTexture-%s.png",
+ zeroTexels? "old" : "new");
+
+ bool result = takeScreenshotAndCompareAgainstReference(driver, screenshotName);
+
+ device->closeDevice();
+ device->run();
+ device->drop();
+
+ return result;
+}
+
+bool makeColorKeyTexture(void)
+{
+ bool result = true;
+
+ result &= doTestWith(EDT_BURNINGSVIDEO, false);
+ result &= doTestWith(EDT_SOFTWARE, false);
+ result &= doTestWith(EDT_BURNINGSVIDEO, true);
+ result &= doTestWith(EDT_SOFTWARE, true);
+
+ return result;
+}