]> git.lizzy.rs Git - irrlicht.git/blob - tests/screenshot.cpp
Fix bug introduced in last merge from svn trunk
[irrlicht.git] / tests / screenshot.cpp
1 // Copyright (C) 2008-2012 Colin MacDonald\r
2 // No rights reserved: this software is in the public domain.\r
3 \r
4 #include "testUtils.h"\r
5 \r
6 using namespace irr;\r
7 \r
8 \r
9 \r
10 // Tests screenshots features\r
11 bool testShots(video::E_DRIVER_TYPE type)\r
12 {\r
13         IrrlichtDevice *device = createDevice(type, core::dimension2d<u32>(160, 120), 32);\r
14         if (!device)\r
15                 return true;\r
16 \r
17         video::IVideoDriver* driver = device->getVideoDriver();\r
18         scene::ISceneManager * smgr = device->getSceneManager();\r
19 \r
20         logTestString("Testing driver %ls\n", driver->getName());\r
21 \r
22         scene::IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");\r
23         scene::IAnimatedMeshSceneNode* node;\r
24 \r
25         if (!mesh)\r
26                 return false;\r
27         node = smgr->addAnimatedMeshSceneNode(mesh);\r
28         if (!node)\r
29                 return false;\r
30 \r
31         stabilizeScreenBackground(driver);\r
32 \r
33         node->setPosition(core::vector3df(20, 0, 30));\r
34         node->setMaterialFlag(video::EMF_LIGHTING, false);\r
35         node->setMaterialTexture(0, driver->getTexture("../media/sydney.bmp"));\r
36         node->setLoopMode(false);\r
37 \r
38         smgr->addCameraSceneNode();\r
39 \r
40         node->setMD2Animation(scene::EMAT_DEATH_FALLBACK);\r
41         node->setCurrentFrame((f32)(node->getEndFrame()));\r
42         node->setAnimationSpeed(0);\r
43 \r
44         device->run();\r
45         driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255, 255, 255, 0));\r
46         smgr->drawAll();\r
47         driver->endScene();\r
48 \r
49         for (s32 i=0; i<video::ECF_UNKNOWN; ++i)\r
50         {\r
51                 video::IImage* img = driver->createScreenShot((video::ECOLOR_FORMAT)i);\r
52                 logTestString("Color Format %d %ssupported\n", i, (img && img->getColorFormat() == i)?"":"un");\r
53 \r
54 #if 0   // Enable for a quick check while testing.\r
55                 // If someone adds comparison images please use another scene without animation\r
56                 // and maybe a texture using the full color spectrum.\r
57                 if ( img )\r
58                 {\r
59                         irr::core::stringc screenshotFilename = "results/";\r
60                         screenshotFilename += shortDriverName(driver);\r
61                         screenshotFilename += "screenshot";\r
62                         screenshotFilename += core::stringc(i);\r
63                         screenshotFilename += ".png";\r
64                         driver->writeImageToFile(img, screenshotFilename.c_str());\r
65                 }\r
66 #endif\r
67 \r
68                 if (img)\r
69                         img->drop();\r
70         }\r
71         device->closeDevice();\r
72         device->run();\r
73         device->drop();\r
74 \r
75         return true;\r
76 }\r
77 \r
78 bool screenshot()\r
79 {\r
80         bool result = true;\r
81         TestWithAllHWDrivers(testShots);\r
82         return result;\r
83 }\r