bool testTransparentVertexAlphaMore(E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice(driverType, dimension2d<u32>(160, 120)); if (!device) return true; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); if (driver->getColorFormat() != video::ECF_A8R8G8B8) { device->closeDevice(); device->run(); device->drop(); return true; } logTestString("Testing driver %ls\n", driver->getName()); IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2"); IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); IMeshSceneNode* cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(-5,3,-15)); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setFrameLoop(0, 310); node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") ); } if (cube) { cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA; cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); cube->setMaterialFlag(EMF_LIGHTING, false); smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128); } // second cube without texture cube = smgr->addCubeSceneNode(10.0f,0,-1,vector3df(5,3,-15)); if (cube) { cube->getMaterial(0).MaterialType = EMT_TRANSPARENT_VERTEX_ALPHA; cube->setMaterialFlag(EMF_LIGHTING, false); smgr->getMeshManipulator()->setVertexColorAlpha(cube->getMesh(),128); } smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); driver->beginScene(true, true, SColor(0,200,200,200)); smgr->drawAll(); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentVertexAlphaChannelMore.png", 99.18f); device->closeDevice(); device->run(); device->drop(); return result; }
//! Check that EMT_TRANSPARENT_REFLECTION_2_LAYER works as expected bool testTransparentReflection2Layer(video::E_DRIVER_TYPE driverType) { IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32); if (!device) return true; video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); if (driver->getColorFormat() != video::ECF_A8R8G8B8) { device->closeDevice(); device->run(); device->drop(); return true; } stabilizeScreenBackground(driver); logTestString("Testing driver %ls\n", driver->getName()); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); ISceneNode * backCube = smgr->addCubeSceneNode(); backCube->setPosition(vector3df(0, 0, 10)); backCube->setScale(vector3df(5, 5, 1)); backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); backCube->setMaterialTexture(1, driver->getTexture("../media/water.jpg")); // vertex color has alpha 255, hence solid backCube->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER); backCube->setMaterialFlag(video::EMF_LIGHTING, false); IMeshSceneNode * frontCube = smgr->addCubeSceneNode(10,0,-1,core::vector3df(-10,0,0)); frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png")); frontCube->setMaterialTexture(1, driver->getTexture("../media/water.jpg")); frontCube->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER); frontCube->setMaterialFlag(video::EMF_LIGHTING, false); driver->getMeshManipulator()->setVertexColorAlpha(frontCube->getMesh(), 128); frontCube = smgr->addCubeSceneNode(10,0,-1,core::vector3df(10,0,0)); frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png")); frontCube->setMaterialTexture(1, driver->getTexture("../media/water.jpg")); frontCube->setMaterialType(video::EMT_TRANSPARENT_REFLECTION_2_LAYER); frontCube->setMaterialFlag(video::EMF_LIGHTING, false); driver->getMeshManipulator()->setVertexColorAlpha(frontCube->getMesh(), 45); (void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15)); driver->beginScene(true, true, video::SColor(255,113,113,133)); smgr->drawAll(); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentReflection2Layer.png"); device->closeDevice(); device->run(); device->drop(); return result; }
static bool testLightTypes(video::E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(128,128)); if (!device) return true; // No error if device does not exist video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); if (!driver->getDriverAttributes().getAttributeAsInt("MaxLights")) { device->closeDevice(); device->run(); device->drop(); return true; } stabilizeScreenBackground(driver); logTestString("Testing driver %ls\n", driver->getName()); // smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f)); scene::ICameraSceneNode* cam = smgr->addCameraSceneNode(); cam->setPosition(core::vector3df(0,200,0)); cam->setTarget(core::vector3df()); smgr->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(4,4), core::dimension2du(128,128))); scene::ILightSceneNode* light1 = smgr->addLightSceneNode(0, core::vector3df(-100,30,-100)); light1->setLightType(video::ELT_POINT); light1->setRadius(100.f); light1->getLightData().DiffuseColor.set(0,1,1); // smgr->addCubeSceneNode(10, light1)->setMaterialFlag(video::EMF_LIGHTING, false); scene::ILightSceneNode* light2 = smgr->addLightSceneNode(0, core::vector3df(100,30,100)); light2->setRotation(core::vector3df(90,0,0)); light2->setLightType(video::ELT_SPOT); light2->setRadius(100.f); light2->getLightData().DiffuseColor.set(1,0,0); light2->getLightData().InnerCone=10.f; light2->getLightData().OuterCone=30.f; // smgr->addCubeSceneNode(10, light2)->setMaterialFlag(video::EMF_LIGHTING, false); scene::ILightSceneNode* light3 = smgr->addLightSceneNode(); light3->setRotation(core::vector3df(15,0,0)); light3->setLightType(video::ELT_DIRECTIONAL); light1->getLightData().DiffuseColor.set(0,1,0); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(0)); smgr->drawAll(); driver->endScene(); const bool result = takeScreenshotAndCompareAgainstReference(driver, "-lightType.png", 99.91f); device->closeDevice(); device->run(); device->drop(); return result; }
//! Tests lightmaps under all drivers that support them static bool runTestWithDriver(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(); ISceneManager * smgr = device->getSceneManager(); logTestString("Testing driver %ls\n", driver->getName()); if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2) { device->closeDevice(); device->run(); device->drop(); return true; } stabilizeScreenBackground(driver); bool result = true; bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3"); assert_log(added); if(added) { ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); assert_log(node); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setPosition(core::vector3df(-1300,-820,-1249)); node->setScale(core::vector3df(1, 5, 1)); (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,255,0)); smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96); } } device->closeDevice(); device->run(); device->drop(); return result; }
//! Check that EMT_TRANSPARENT_ALPHA_CHANNEL_REF works as expected bool testTransparentAlphaChannelRef(video::E_DRIVER_TYPE driverType) { IrrlichtDevice* device = createDevice(driverType, core::dimension2d<u32>(160, 120), 32); if (!device) return true; video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); if (driver->getColorFormat() != video::ECF_A8R8G8B8) { device->closeDevice(); device->run(); device->drop(); return true; } stabilizeScreenBackground(driver); logTestString("Testing driver %ls\n", driver->getName()); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); ISceneNode * backCube = smgr->addCubeSceneNode(); backCube->setPosition(vector3df(0, 0, 10)); backCube->setScale(vector3df(5, 5, 1)); backCube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp")); backCube->setMaterialType(video::EMT_SOLID); backCube->setMaterialFlag(video::EMF_LIGHTING, false); ISceneNode * frontCube = smgr->addCubeSceneNode(); frontCube->setMaterialTexture(0, driver->getTexture("../media/help.png")); frontCube->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); frontCube->setMaterialFlag(video::EMF_LIGHTING, false); (void)smgr->addCameraSceneNode(0, vector3df(0, 0, -15)); driver->beginScene(true, true, video::SColor(255,113,113,133)); smgr->drawAll(); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-transparentAlphaChannelRef.png", 99.18f); device->closeDevice(); device->run(); device->drop(); return result; }
/** Test various things in video drivers. */ bool testVideoDriver(video::E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice(driverType, dimension2d<u32>(160, 120)); if (!device) return true; video::IVideoDriver* driver = device->getVideoDriver(); logTestString("Testing driver %ls\n", driver->getName()); logTestString("MaxTextures: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxTextures")); logTestString("MaxSupportedTextures: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxSupportedTextures")); logTestString("MaxLights: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxLights")); logTestString("MaxAnisotropy: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxAnisotropy")); logTestString("MaxUserClipPlanes: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxUserClipPlanes")); logTestString("MaxAuxBuffers: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxAuxBuffers")); logTestString("MaxMultipleRenderTargets: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxMultipleRenderTargets")); logTestString("MaxIndices: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxIndices")); logTestString("MaxTextureSize: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxTextureSize")); logTestString("MaxGeometryVerticesOut: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxGeometryVerticesOut")); logTestString("Version: %d\n", driver->getDriverAttributes().getAttributeAsInt("Version")); logTestString("ShaderLanguageVersion: %d\n\n", driver->getDriverAttributes().getAttributeAsInt("ShaderLanguageVersion")); device->closeDevice(); device->run(); device->drop(); return true; }
virtual bool OnEvent(const SEvent& event) { if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown){ switch(event.KeyInput.Key) { case 'O': device_->getGUIEnvironment()->addFileOpenDialog( L"Please select a model file to open"); break; case 27: // ESCAPE case 'Q': // fall through device_->closeDevice(); break; default: std::cout << event.KeyInput.Key << std::endl; } } else if (event.EventType == EET_GUI_EVENT){ if(event.GUIEvent.EventType==gui::EGET_FILE_SELECTED){ // load the model file, selected in the file open dialog gui::IGUIFileOpenDialog* dialog = (gui::IGUIFileOpenDialog*)event.GUIEvent.Caller; scene::IAnimatedMesh *m=loadMesh(dialog->getFileName()); if(m){ setMesh(m); } } } return false; }
/** This won't test render results. Currently, not all mesh loaders are tested. */ bool meshLoaders(void) { IrrlichtDevice *device = createDevice(video::EDT_NULL, core::dimension2d<u32>(160, 120), 32); assert(device); if (!device) return false; scene::ISceneManager * smgr = device->getSceneManager(); scene::IAnimatedMesh* mesh = smgr->getMesh("../media/ninja.b3d"); assert(mesh); bool result = (mesh != 0); if (mesh) { if (mesh != smgr->getMesh("../media/ninja.b3d")) { logTestString("Loading from same file results in different meshes!"); result=false; } } device->closeDevice(); device->run(); device->drop(); return result; }
/** Test functionality of the sceneCollisionManager */ bool sceneCollisionManager(void) { IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120)); assert(device); if(!device) return false; ISceneManager * smgr = device->getSceneManager(); ISceneCollisionManager * collMgr = smgr->getSceneCollisionManager(); bool result = testGetCollisionResultPosition(device, smgr, collMgr); smgr->clear(); result &= testGetSceneNodeFromScreenCoordinatesBB(device, smgr, collMgr); result &= getScaledPickedNodeBB(device, smgr, collMgr); result &= getCollisionPoint_ignoreTriangleVertices(device, smgr, collMgr); result &= checkBBoxIntersection(device, smgr); result &= compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(device, smgr, collMgr); device->closeDevice(); device->run(); device->drop(); return result; }
/** Tests the Burning Video driver */ bool burningsVideo(void) { IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2du(160,120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); smgr->addCubeSceneNode(10.f, 0, -1, core::vector3df(0.f, 0.f, 20.f)); smgr->addCameraSceneNode(); // Test that ambient lighting works when there are no other lights in the scene smgr->setAmbientLight(video::SColorf(.7f, .1f, .1f, 1.f)); bool result = false; device->run(); if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80))) { smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-ambient-lighting.png", 100); } device->closeDevice(); device->run(); device->drop(); return result; }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& params) { IrrlichtDevice* dev = 0; #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ if (params.DeviceType == EIDT_WIN32 || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceWin32(params); #endif #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ if (params.DeviceType == EIDT_OSX || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceMacOSX(params); #endif #ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_ if (params.DeviceType == EIDT_IPHONE || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceIPhone(params); #endif #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceAndroid(params); #endif #ifdef _IRR_COMPILE_WITH_WINDOWS_CE_DEVICE_ if (params.DeviceType == EIDT_WINCE || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceWinCE(params); #endif #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceLinux(params); #endif #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceSDL(params); #endif #ifdef _IRR_COMPILE_WITH_FB_DEVICE_ if (params.DeviceType == EIDT_FRAMEBUFFER || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceFB(params); #endif #ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_ if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceConsole(params); #endif if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL) { dev->closeDevice(); // destroy window dev->run(); // consume quit message dev->drop(); dev = 0; } return dev; }
extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& params) { IrrlichtDevice* dev = 0; SIrrlichtCreationParameters creation_params = params; overrideDeviceType(creation_params.DeviceType); #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ if (creation_params.DeviceType == EIDT_WIN32 || (!dev && creation_params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceWin32(creation_params); #endif #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ if (creation_params.DeviceType == EIDT_OSX || (!dev && creation_params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceMacOSX(creation_params); #endif #ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_ if (creation_params.DeviceType == EIDT_WAYLAND || (!dev && creation_params.DeviceType == EIDT_BEST)) { if (CIrrDeviceWayland::isWaylandDeviceWorking()) { dev = new CIrrDeviceWayland(creation_params); if (!dev->getVideoDriver()) { delete dev; dev = NULL; } } } #endif #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ if (creation_params.DeviceType == EIDT_X11 || (!dev && creation_params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceLinux(creation_params); #endif #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ if (creation_params.DeviceType == EIDT_SDL || (!dev && creation_params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceSDL(creation_params); #endif #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ if (creation_params.DeviceType == EIDT_ANDROID || (!dev && creation_params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceAndroid(creation_params); #endif if (dev && !dev->getVideoDriver() && creation_params.DriverType != video::EDT_NULL) { dev->closeDevice(); // destroy window dev->run(); // consume quit message dev->drop(); dev = 0; } return dev; }
static bool withSphere(video::E_DRIVER_TYPE type) { IrrlichtDevice* device = createDevice(type, core::dimension2d<u32>(160, 120)); if (device == 0) return true; video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); stabilizeScreenBackground(driver); driver->setClipPlane(0, core::plane3df(core::vector3df(0,18,0), core::vector3df(0,-1,0)), true); smgr->addLightSceneNode(0, core::vector3df(30,30,50)); // create first sphere scene::ISceneNode* sphere = smgr->addMeshSceneNode(smgr->addSphereMesh("sphere", 10, 64, 64)); if (sphere) { sphere->setPosition(core::vector3df(0,10,0)); sphere->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false); } sphere = smgr->addMeshSceneNode(smgr->addHillPlaneMesh("mesh", core::dimension2df(10,10), core::dimension2du(10,10))); sphere->setPosition(core::vector3df(0,10,0)); smgr->addCameraSceneNode(0, core::vector3df(-25,30,20), core::vector3df()); driver->setClipPlane(1, core::plane3df(core::vector3df(0,2,0), core::vector3df(0,1,0)), true); driver->setClipPlane(2, core::plane3df(core::vector3df(8,0,0), core::vector3df(-1,0,0))); device->run(); // while(device->run()) { driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,113,113,133)); driver->setClipPlane(3, core::plane3df(core::vector3df(-8,0,0), core::vector3df(1,0,0)), true); driver->setClipPlane(4, core::plane3df(core::vector3df(0,0,8), core::vector3df(0,0,-1))); driver->setClipPlane(5, core::plane3df(core::vector3df(0,0,-8), core::vector3df(0,0,1))); driver->enableClipPlane(2, true); driver->enableClipPlane(4, true); driver->enableClipPlane(5, true); smgr->drawAll(); driver->enableClipPlane(1, false); driver->enableClipPlane(2, false); driver->enableClipPlane(4, false); driver->enableClipPlane(5, false); driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); driver->setMaterial(video::IdentityMaterial); driver->draw3DLine(core::vector3df(), core::vector3df(0,0,50)); driver->endScene(); } bool result = takeScreenshotAndCompareAgainstReference(driver, "-ucpsphere.png"); device->closeDevice(); device->run(); device->drop(); return result; }
// this test draws lines of different lengths and compares // them with pixel placement // grey pixels denote start and end of the white drawn lines // black pixels only make those grey points better visible // yellow and magenta lines should start and end next toa black pixel, // yellow one right to the last black pixel down, magenta below the last // black pixel to the right // white lines are always double drawn, lines back and forth. static bool drawLine(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(); stabilizeScreenBackground(driver); logTestString("Testing driver %ls\n", driver->getName()); device->getSceneManager()->addCameraSceneNode(); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140)); // horizontal lines for (u32 i=0; i<20; ++i) { driver->draw2DLine(core::vector2di(10,10+3*i), core::vector2di(10+2*i,10+3*i)); // mark start point driver->drawPixel(9,10+3*i+1, video::SColor(0xff000000)); driver->drawPixel(10,10+3*i+1, video::SColor(0xff888888)); driver->drawPixel(11,10+3*i+1, video::SColor(0xff000000)); // mark end point driver->drawPixel(9+2*i,10+3*i+1, video::SColor(0xff000000)); driver->drawPixel(10+2*i,10+3*i+1, video::SColor(0xff888888)); driver->drawPixel(11+2*i,10+3*i+1, video::SColor(0xff000000)); driver->draw2DLine(core::vector2di(10+2*i,10+3*i+2), core::vector2di(10,10+3*i+2)); } // vertical lines for (u32 i=0; i<20; ++i) { driver->draw2DLine(core::vector2di(11+3*i,10), core::vector2di(11+3*i,10+2*i)); // mark start point driver->drawPixel(11+3*i+1,9, video::SColor(0xff000000)); driver->drawPixel(11+3*i+1,10, video::SColor(0xff888888)); driver->drawPixel(11+3*i+1,11, video::SColor(0xff000000)); // mark end point driver->drawPixel(11+3*i+1,9+2*i, video::SColor(0xff000000)); driver->drawPixel(11+3*i+1,10+2*i, video::SColor(0xff888888)); driver->drawPixel(11+3*i+1,11+2*i, video::SColor(0xff000000)); driver->draw2DLine(core::vector2di(11+3*i+2,10+2*i), core::vector2di(11+3*i+2, 10)); } // diagonal lines driver->draw2DLine(core::vector2di(14,14),core::vector2di(50,68), video::SColor(0xffffff00)); driver->draw2DLine(core::vector2di(15,14),core::vector2di(69,50), video::SColor(0xffff00ff)); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawLine.png"); device->closeDevice(); device->run(); device->drop(); return result; }
static bool shadows(video::E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(160,120), 16, false, true); if (!device) return true; // No error if device does not exist stabilizeScreenBackground(device->getVideoDriver()); scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNodeFPS(); cam->setPosition(core::vector3df(-15,55,10)); cam->setTarget(core::vector3df(-5,-5,-15)); device->getSceneManager()->setAmbientLight(video::SColorf(.5f,.5f,.5f)); scene::IMeshSceneNode* cube = device->getSceneManager()->addCubeSceneNode(100, 0, -1, core::vector3df(0,50,0)); cube->setScale(core::vector3df(-1,-1,-1)); scene::IAnimatedMeshSceneNode* node = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh("../media/ninja.b3d"), 0, -1, core::vector3df(0,2,0), core::vector3df(),core::vector3df(5,5,5)); node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); node->addShadowVolumeSceneNode(); node->setAnimationSpeed(0.f); scene::ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, core::vector3df(10,10,10)); light->setLightType(video::ELT_POINT); light->setRadius(500.f); light->getLightData().DiffuseColor.set(0,1,1); device->getVideoDriver()->beginScene (true, true, 0); device->getSceneManager()->drawAll(); device->getVideoDriver()->endScene(); bool result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-stencilShadow.png", 99.91f); node->remove(); cube->remove(); // test self-shadowing node = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh("../media/dwarf.x")); node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); node->addShadowVolumeSceneNode(); node->setAnimationSpeed(0.f); cam->setPosition(core::vector3df(0,55,-30)); cam->setTarget(core::vector3df(60,45,150)); device->getVideoDriver()->beginScene (true, true, 0); device->getSceneManager()->drawAll(); device->getVideoDriver()->endScene(); result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-stencilSelfShadow.png", 99.41f); device->closeDevice(); device->run(); device->drop(); 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(); stabilizeScreenBackground(driver); logTestString("Testing driver %ls\n", driver->getName()); device->getSceneManager()->addCameraSceneNode(); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 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; }
static bool loadScene(void) { IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2du(160,120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); // load scene from example, with correct relative path device->getFileSystem()->changeWorkingDirectoryTo("results"); smgr->loadScene("../../media/example.irr"); smgr->addCameraSceneNode(0, core::vector3df(0,0,-50)); device->getFileSystem()->changeWorkingDirectoryTo(".."); bool result = false; device->run(); device->getTimer()->setTime(666); // scene has animations and current scene seems to be saved at that time ... really - best result with just that number :-) if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80))) { smgr->drawAll(); driver->endScene(); // we need to be very sloppy, because the animators will produce a different // start depending on the actual loading time. 97% seems to be safe, as removing // an object produces values around 95% result = takeScreenshotAndCompareAgainstReference(driver, "-loadScene.png", 97.4f); if (!result) logTestString("Rendering the loaded scene failed.\n"); } ISceneNode* node = smgr->getSceneNodeFromId(128); if (!node) result=false; else if (result) // only check if scene was correctly loaded { result &= (node->getChildren().size()==0); if (!result) logTestString("Node has an illegal child node.\n"); device->getSceneManager()->loadScene("results/scene2.irr", 0, node); result &= (node->getChildren().size()!=0); if (!result) logTestString("Loading second scene as child failed.\n"); } device->closeDevice(); device->run(); device->drop(); return result; }
/** 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; }
/** Tests the offset capability of the fly circle animator */ bool flyCircleAnimator(void) { IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2du(160,120), 32); if (!device) return false; IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f }; for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i) { IBillboardSceneNode * node = smgr->addBillboardSceneNode(); // Have the animator rotate around the Z axis plane, rather than the default Y axis ISceneNodeAnimator * animator = smgr->createFlyCircleAnimator( vector3df(0, 0, 0), 30.f, 0.001f, vector3df(0, 0, 1), (offsetDegrees[i] / 360.f)); if(!node || !animator) return false; node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR ); node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp")); node->setMaterialFlag(video::EMF_LIGHTING, false); node->addAnimator(animator); animator->drop(); } (void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0)); bool result = false; // Don't do device->run() since I need the time to remain at 0. if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80))) { smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100); } device->closeDevice(); device->run(); device->drop(); return result; }
//! Tests the basic functionality of the software device. bool softwareDevice(void) { IrrlichtDevice *device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(160, 120), 32); if (!device) return false; video::IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); // Test a particular rotation that highlighted a clipping issue from matrix::transformPlane() video::S3DVertex vertices[3]; vertices[0] = video::S3DVertex(10,0,-10, 1,0,0, video::SColor(255,255,0,255), 1, 1); vertices[1] = video::S3DVertex(0,20,0, 0,1,1, video::SColor(255,255,255,0), 1, 0); vertices[2] = video::S3DVertex(-10,0,-10, 0,0,1, video::SColor(255,0,255,0), 0, 0); video::SMaterial material; material.Lighting = false; material.Wireframe = false; const u16 indices[] = { 1,0,2, }; matrix4 transform(matrix4::EM4CONST_IDENTITY); vector3df rotations(290, 0, 290); // <-- This rotation used to clip the triangle incorrectly transform.setRotationDegrees(rotations); (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,-40), core::vector3df(0,0,0)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,255,0)); smgr->drawAll(); driver->setMaterial(material); driver->setTransform(video::ETS_WORLD, transform); driver->drawIndexedTriangleList(&vertices[0], 3, &indices[0], 1); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-softwareDevice-rotatedClip.png"); device->closeDevice(); device->run(); device->drop(); return result; }
virtual bool OnEvent(const SEvent& event) { if (event.EventType == EET_GUI_EVENT) { s32 id = event.GUIEvent.Caller->getID(); switch (event.GUIEvent.EventType) { case EGET_BUTTON_CLICKED: if (id == 2) { Device->closeDevice(); return true; } break; } } return false; }
/** The result should be as follows: We have three times the same image, a billboard with a cube and the text in front. They are replicated three times, one centered in the screen without viewport, one in the upper left (qurter screen) and one on the right (half screen). The latter is stretched due to the changed aspect ratio. The two viewport scenes get the texture drawn over the center as well, using draw2dimage. This should mark the proper image position with the top left corner of the texture. Finally, each scene has a checkbox drawn at the left side, vertically centered. This will show whether GUI elements adhere to viewports as well. */ static bool viewPortText(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(); ISceneManager * smgr = device->getSceneManager(); IGUIEnvironment* env = smgr->getGUIEnvironment(); stabilizeScreenBackground(driver); env->addCheckBox(true, core::recti(10,60,28,82)); logTestString("Testing driver %ls\n", driver->getName()); IBillboardSceneNode * bnode = smgr->addBillboardSceneNode(0,dimension2d<f32>(32,32),core::vector3df(0,0,10)); bnode->setMaterialFlag(video::EMF_LIGHTING, false); bnode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); bnode->setMaterialTexture(0, driver->getTexture("../media/fire.bmp")); smgr->addTextSceneNode(device->getGUIEnvironment()->getBuiltInFont(), L"TEST", video::SColor(255,255,255,255), 0); smgr->addCubeSceneNode(); smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140)); smgr->drawAll(); env->drawAll(); driver->setViewPort(rect<s32>(0,0,160/2,120/2)); smgr->drawAll(); env->drawAll(); driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2)); driver->setViewPort(rect<s32>(160/2,0,160,120)); smgr->drawAll(); env->drawAll(); driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2)); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-viewPortText.png", 98.71f); device->closeDevice(); device->run(); device->drop(); return result; }
static bool testOrthoCam(video::E_DRIVER_TYPE driverType) { IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(160,120)); if (!device) return true; // No error if device does not exist stabilizeScreenBackground(device->getVideoDriver()); scene::ICameraSceneNode* cam = device->getSceneManager()->addCameraSceneNode(); cam->setPosition(core::vector3df(500,200,-500)); cam->setTarget(core::vector3df()); cam->setProjectionMatrix(core::matrix4().buildProjectionMatrixOrthoLH(240,180,0.9f,2000.f,driverType != video::EDT_OPENGL), true); device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(32,32), core::dimension2du(16,16)));//->setMaterialFlag(video::EMF_WIREFRAME, true); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,50)); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,20,-50)); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(50,50,0)); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(-50,10,0)); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(100,10,-100)); device->getSceneManager()->addCubeSceneNode(20.f)->setPosition(core::vector3df(150,10,0)); scene::IAnimatedMeshSceneNode* node = device->getSceneManager()->addAnimatedMeshSceneNode(device->getSceneManager()->getMesh("../media/ninja.b3d"), 0, -1, core::vector3df(-50,2,-50), core::vector3df(),core::vector3df(5,5,5)); node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); node->setAnimationSpeed(0.f); scene::ILightSceneNode* light = device->getSceneManager()->addLightSceneNode(0, core::vector3df(0,100,0)); light->setLightType(video::ELT_POINT); light->setRadius(500.f); light->getLightData().DiffuseColor.set(0,1,1); device->getVideoDriver()->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(0,0,0,0)); device->getSceneManager()->drawAll(); device->getVideoDriver()->endScene(); const bool result = takeScreenshotAndCompareAgainstReference(device->getVideoDriver(), "-orthoCam.png", 99.91f); device->closeDevice(); device->run(); device->drop(); return result; }
/** This test verifies that setting the cursor visibility only generates a mouse message when it actually changes */ bool cursorSetVisible(void) { IrrlichtDevice * device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(1, 1)); TrapMouseMoves moveTrapper; device->setEventReceiver(&moveTrapper); device->run(); gui::ICursorControl * cursor = device->getCursorControl(); // Move the cursor inside the Irrlicht window so that we get messages for it. cursor->setPosition(0, 0); device->run(); // Receive any messages cursor->setVisible(false); // Should generate a mouse move device->run(); // Receive any messages cursor->setVisible(false); // Should not generate a mouse move device->run(); // Receive any messages cursor->setVisible(true); // Should generate a mouse move device->run(); // Receive any messages cursor->setVisible(true); // Should not generate a mouse move device->run(); // Receive any messages // We should get at most 3 messages: one for the setPosition(), and one for // each actual change of visibility. bool result = (moveTrapper.MouseMovesReceived <= 3); device->closeDevice(); device->run(); device->drop(); if(!result) { logTestString("ERROR: cursorSetVisible received %d events.\n", moveTrapper.MouseMovesReceived); assert_log(false); } return result; }
bool guiDisabledMenu(void) { IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO, dimension2d<u32>(160, 40), 32); assert_log(device); if (!device) return false; video::IVideoDriver* driver = device->getVideoDriver(); gui::IGUIEnvironment* env = device->getGUIEnvironment(); gui::IGUIContextMenu* menu = env->addMenu(); menu->addItem(L"Menu", -1, true, true); gui::IGUIContextMenu* subMenu = menu->getSubMenu(0); subMenu->addItem(L"Submenu 1", -1, false, true); gui::IGUIContextMenu* subSubMenu = subMenu->getSubMenu(0); subSubMenu->addItem(L"Final item"); SEvent event; event.EventType = EET_MOUSE_INPUT_EVENT; event.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN; event.MouseInput.X = menu->getAbsolutePosition().UpperLeftCorner.X + 1; event.MouseInput.Y = menu->getAbsolutePosition().UpperLeftCorner.Y + 1; (void)menu->OnEvent(event); // Hovering over the disabled submenu shouldn't cause the "Final item" to appear. event.MouseInput.Event = EMIE_MOUSE_MOVED; event.MouseInput.X = subMenu->getAbsolutePosition().UpperLeftCorner.X + 40; event.MouseInput.Y = subMenu->getAbsolutePosition().UpperLeftCorner.Y + 10; (void)menu->OnEvent(event); device->run(); driver->beginScene(true, true, video::SColor(150,50,50,50)); env->drawAll(); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-guiDisabledMenu.png", 98.77f); device->closeDevice(); device->run(); device->drop(); return result; }
bool serializeAttributes() { bool result = true; IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1)); assert(device); if(!device) { logTestString("device creation failed in %s:%d\n", __FILE__, __LINE__ ); return false; } io::IFileSystem * fs = device->getFileSystem (); if ( !fs ) { return false; } result &= MemorySerialization(fs); if ( !result ) { logTestString("MemorySerialization failed in %s:%d\n", __FILE__, __LINE__ ); } result &= XmlSerialization(fs, device->getVideoDriver()); if ( !result ) { logTestString("XmlSerialization failed in %s:%d\n", __FILE__, __LINE__ ); } result &= stringSerialization(fs); if ( !result ) { logTestString("stringSerialization failed in %s:%d\n", __FILE__, __LINE__ ); } device->closeDevice(); device->run(); device->drop(); return result; }
/** Expect to see two diagonal lines overlaying a wall texture cube. 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 cyan 100% opaque at the top right. */ static bool lineRender(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(); ISceneManager * smgr = device->getSceneManager(); stabilizeScreenBackground(driver); logTestString("Testing driver %ls\n", driver->getName()); // Draw a cube background so that we can check that the pixels' alpha 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); (void)smgr->addCameraSceneNode(); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140)); smgr->drawAll(); // Test for benign handling of offscreen pixel values as well as onscreen ones. for(s32 x = -10; x < 170; ++x) { s32 y = 120 * x / 160; driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0)); y = 120 - y; driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255)); } driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.png", 98.81f); device->closeDevice(); device->run(); device->drop(); return result; }
static bool drawScaledOctree(void) { bool result = false; IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32); if (!device) return false; video::IVideoDriver* driver = device->getVideoDriver(); ISceneManager * smgr = device->getSceneManager(); bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3"); assert_log(added); if(added) { ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); assert_log(node); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); node->setPosition(core::vector3df(-1300,-820,-1249)); node->setScale(core::vector3df(1, 5, 1)); (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30)); driver->beginScene(true, true, video::SColor(255,255,255,0)); smgr->drawAll(); driver->endScene(); result = takeScreenshotAndCompareAgainstReference(driver, "-planeMatrix-scaledClip.png"); } } device->closeDevice(); device->run(); device->drop(); return result; }
bool archiveReader() { IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1)); assert(device); if(!device) return false; io::IFileSystem * fs = device->getFileSystem (); if ( !fs ) return false; bool ret = true; logTestString("Testing mount file.\n"); ret &= testArchive(fs, "media/file_with_path"); logTestString("Testing mount file.\n"); ret &= testArchive(fs, "media/file_with_path/"); logTestString("Testing zip files.\n"); ret &= testArchive(fs, "media/file_with_path.zip"); logTestString("Testing pak files.\n"); ret &= testArchive(fs, "media/sample_pakfile.pak"); logTestString("Testing npk files.\n"); ret &= testArchive(fs, "media/file_with_path.npk"); logTestString("Testing encrypted zip files.\n"); ret &= testEncryptedZip(fs); logTestString("Testing special zip files.\n"); ret &= testSpecialZip(fs, "media/Monty.zip", "monty/license.txt", "Monty"); logTestString("Testing special zip files lzma.\n"); const u8 buf[] = {0xff, 0xfe, 0x3c, 0x00, 0x3f}; ret &= testSpecialZip(fs, "media/lzmadata.zip", "tahoma10_.xml", buf); // logTestString("Testing complex mount file.\n"); // ret &= testMountFile(fs); logTestString("Testing add/remove with filenames.\n"); testAddRemove(fs, "media/file_with_path.zip"); device->closeDevice(); device->run(); device->drop(); return ret; }
static bool testLineRendering(video::E_DRIVER_TYPE type) { SIrrlichtCreationParameters params; params.AntiAlias = 2; params.Bits = 16; params.WindowSize = core::dimension2d<u32>(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(); // if no AntiAliasing supported, skip this test if (driver->getDriverAttributes().getAttributeAsInt("AntiAlias")<2) { device->closeDevice(); device->run(); device->drop(); return true; } logTestString("Testing driver %ls\n", driver->getName()); scene::ISceneManager* smgr = device->getSceneManager(); scene::IAnimatedMesh* mesh = smgr->getMesh("./media/sydney.md2"); if (!mesh) { device->closeDevice(); device->run(); device->drop(); return false; } stabilizeScreenBackground(driver); scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); if (node) { node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMD2Animation(scene::EMAT_STAND); node->setMaterialTexture( 0, driver->getTexture("./media/sydney.bmp") ); } smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0)); device->getTimer()->setTime(0); // scene has animations and current scene seems to be saved at that time driver->beginScene(true, true, video::SColor(255,100,101,140)); smgr->drawAll(); driver->draw3DBox(node->getBoundingBox(), video::SColor(0,255,0,0)); driver->draw2DLine(core::position2di(10,10), core::position2di(100,100), video::SColor(255,0,0,0)); driver->endScene(); bool result = takeScreenshotAndCompareAgainstReference(driver, "-lineAntiAliasing.png", 99.4f ); device->closeDevice(); device->run(); device->drop(); return result; }