本文整理汇总了C++中IrrlichtDevice::closeDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ IrrlichtDevice::closeDevice方法的具体用法?C++ IrrlichtDevice::closeDevice怎么用?C++ IrrlichtDevice::closeDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IrrlichtDevice
的用法示例。
在下文中一共展示了IrrlichtDevice::closeDevice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testTransparentVertexAlphaMore
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;
}
示例2: testTransparentReflection2Layer
//! 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;
}
示例3: testLightTypes
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;
}
示例4: runTestWithDriver
//! 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;
}
示例5: testTransparentAlphaChannelRef
//! 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;
}
示例6: OnEvent
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;
}
示例7: sceneCollisionManager
/** 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;
}
示例8: burningsVideo
/** 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;
}
示例9: createDeviceEx
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;
}
示例10: createDeviceEx
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;
}
示例11: withSphere
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;
}
示例12: drawLine
// 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;
}
示例13: shadows
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;
}
示例14: pixelAccuracy
// 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;
}
示例15: loadScene
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;
}