irrlicht/tests/makeColorKeyTexture.cpp

75 lines
2.2 KiB
C++
Raw Normal View History

// 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)
{
Changes in 1.6 TA - PixelBlend16 and PixelBlend16_simd are working for the new rules. - bugfix. CLightSceneNode didn't correctly update it's attributes Lighting Linear Attenuation. = 1.f / radius The Example loadirr files set the lightscene radius to 1000.f but stays on the previous default attentuation with the older radius 100 -> 1.f / 100 so the examples looks golden-brown. Now the radius is correctly!! set to the attenuation of 1.f/1000.f because the file doesn't have special attenuation. and now it looks more yellow. can anybody show me a correct screenshot for this file;-)? Niko? Or is this behavior the default lighting?. then it would be a fixed constant linear attenuation of 0.01f;-). Please clearify For now i didn't fixed it I encountered this behavior because i ( burning video ) used the original radius for calculations and so i've found that radius != 1.f / linearAttenuation but in the LightSceneNode this formula was used.. confused;-) - vector template and equals tests as working with the test suits i cleaned the template behavior (mixed types are used in the templates) and added all missing special math function with their coressponding type I also set the equal test for s32 to behave like the f32 routine. The function equals always implements a weak test. that means a tolerance MUST always be used if you use the equal function. default is 1. you can set it to zero a==b-> equals ( a, b, 0 ) but do it explicit like you have to for floating compare. This is important when irrlicht is going to use special hardware math acceleration on a per function base, like sse2, or the other way round fixpoint. - VideoDriver drawPixel The HW renderes are using the alpha components for blending. The Software Renderes and image loaders are using CImage::setPixel copy. so setPixel is engaged to either blends or copy the pixel default: false - Burningvideo added RenderMaterial EMT_SPHERE_MAP pushed burningsvideo to 0.43 added RenderMaterial EMT_REFLECTION_2_LAYER pushed burningsvideo to 0.44 set EMT_TRANSPARENT_ALPHA_CHANNEL_REF to use AlphaRef 0.5 like Direct3D One Note: in OpenGL there is know difference between sphere_map and reflection layer both using GL_TEXTURE_GEN_MODE GL_SPHERE_MAP, whereas in d3d one time using camera_normal on sphere and reflection on refletcion_layer. The visual difference is that on sphere map the "image is not moving" when you rotate the viewer. For Buring i took the opengl visual. always moving - rename quake3 SEntity to IEntity to be confom with IShader even IShader and IEntity are none pure virtual interfaces like most irrlicht objects git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2207 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-10 07:08:23 -08:00
bool result = true;
result &= doTestWith(EDT_BURNINGSVIDEO, false);
Changes in 1.6 TA - PixelBlend16 and PixelBlend16_simd are working for the new rules. - bugfix. CLightSceneNode didn't correctly update it's attributes Lighting Linear Attenuation. = 1.f / radius The Example loadirr files set the lightscene radius to 1000.f but stays on the previous default attentuation with the older radius 100 -> 1.f / 100 so the examples looks golden-brown. Now the radius is correctly!! set to the attenuation of 1.f/1000.f because the file doesn't have special attenuation. and now it looks more yellow. can anybody show me a correct screenshot for this file;-)? Niko? Or is this behavior the default lighting?. then it would be a fixed constant linear attenuation of 0.01f;-). Please clearify For now i didn't fixed it I encountered this behavior because i ( burning video ) used the original radius for calculations and so i've found that radius != 1.f / linearAttenuation but in the LightSceneNode this formula was used.. confused;-) - vector template and equals tests as working with the test suits i cleaned the template behavior (mixed types are used in the templates) and added all missing special math function with their coressponding type I also set the equal test for s32 to behave like the f32 routine. The function equals always implements a weak test. that means a tolerance MUST always be used if you use the equal function. default is 1. you can set it to zero a==b-> equals ( a, b, 0 ) but do it explicit like you have to for floating compare. This is important when irrlicht is going to use special hardware math acceleration on a per function base, like sse2, or the other way round fixpoint. - VideoDriver drawPixel The HW renderes are using the alpha components for blending. The Software Renderes and image loaders are using CImage::setPixel copy. so setPixel is engaged to either blends or copy the pixel default: false - Burningvideo added RenderMaterial EMT_SPHERE_MAP pushed burningsvideo to 0.43 added RenderMaterial EMT_REFLECTION_2_LAYER pushed burningsvideo to 0.44 set EMT_TRANSPARENT_ALPHA_CHANNEL_REF to use AlphaRef 0.5 like Direct3D One Note: in OpenGL there is know difference between sphere_map and reflection layer both using GL_TEXTURE_GEN_MODE GL_SPHERE_MAP, whereas in d3d one time using camera_normal on sphere and reflection on refletcion_layer. The visual difference is that on sphere map the "image is not moving" when you rotate the viewer. For Buring i took the opengl visual. always moving - rename quake3 SEntity to IEntity to be confom with IShader even IShader and IEntity are none pure virtual interfaces like most irrlicht objects git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2207 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-10 07:08:23 -08:00
result &= doTestWith(EDT_SOFTWARE, false);
result &= doTestWith(EDT_BURNINGSVIDEO, true);
Changes in 1.6 TA - PixelBlend16 and PixelBlend16_simd are working for the new rules. - bugfix. CLightSceneNode didn't correctly update it's attributes Lighting Linear Attenuation. = 1.f / radius The Example loadirr files set the lightscene radius to 1000.f but stays on the previous default attentuation with the older radius 100 -> 1.f / 100 so the examples looks golden-brown. Now the radius is correctly!! set to the attenuation of 1.f/1000.f because the file doesn't have special attenuation. and now it looks more yellow. can anybody show me a correct screenshot for this file;-)? Niko? Or is this behavior the default lighting?. then it would be a fixed constant linear attenuation of 0.01f;-). Please clearify For now i didn't fixed it I encountered this behavior because i ( burning video ) used the original radius for calculations and so i've found that radius != 1.f / linearAttenuation but in the LightSceneNode this formula was used.. confused;-) - vector template and equals tests as working with the test suits i cleaned the template behavior (mixed types are used in the templates) and added all missing special math function with their coressponding type I also set the equal test for s32 to behave like the f32 routine. The function equals always implements a weak test. that means a tolerance MUST always be used if you use the equal function. default is 1. you can set it to zero a==b-> equals ( a, b, 0 ) but do it explicit like you have to for floating compare. This is important when irrlicht is going to use special hardware math acceleration on a per function base, like sse2, or the other way round fixpoint. - VideoDriver drawPixel The HW renderes are using the alpha components for blending. The Software Renderes and image loaders are using CImage::setPixel copy. so setPixel is engaged to either blends or copy the pixel default: false - Burningvideo added RenderMaterial EMT_SPHERE_MAP pushed burningsvideo to 0.43 added RenderMaterial EMT_REFLECTION_2_LAYER pushed burningsvideo to 0.44 set EMT_TRANSPARENT_ALPHA_CHANNEL_REF to use AlphaRef 0.5 like Direct3D One Note: in OpenGL there is know difference between sphere_map and reflection layer both using GL_TEXTURE_GEN_MODE GL_SPHERE_MAP, whereas in d3d one time using camera_normal on sphere and reflection on refletcion_layer. The visual difference is that on sphere map the "image is not moving" when you rotate the viewer. For Buring i took the opengl visual. always moving - rename quake3 SEntity to IEntity to be confom with IShader even IShader and IEntity are none pure virtual interfaces like most irrlicht objects git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2207 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-10 07:08:23 -08:00
result &= doTestWith(EDT_SOFTWARE, true);
return result;
}