lightMaps.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright (C) 2008-2012 Christian Stehno, Colin MacDonald
  2. // No rights reserved: this software is in the public domain.
  3. #include "testUtils.h"
  4. using namespace irr;
  5. using namespace core;
  6. using namespace scene;
  7. using namespace video;
  8. using namespace io;
  9. using namespace gui;
  10. //! Tests lightmaps under all drivers that support them
  11. static bool runTestWithDriver(E_DRIVER_TYPE driverType)
  12. {
  13. IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
  14. if (!device)
  15. return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
  16. IVideoDriver* driver = device->getVideoDriver();
  17. ISceneManager * smgr = device->getSceneManager();
  18. logTestString("Testing driver %ls\n", driver->getName());
  19. if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2)
  20. {
  21. device->closeDevice();
  22. device->run();
  23. device->drop();
  24. return true;
  25. }
  26. stabilizeScreenBackground(driver);
  27. bool result = true;
  28. bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
  29. assert_log(added);
  30. if(added)
  31. {
  32. ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
  33. assert_log(node);
  34. if (node)
  35. {
  36. node->setMaterialFlag(EMF_LIGHTING, false);
  37. node->setPosition(core::vector3df(-1300,-820,-1249));
  38. node->setScale(core::vector3df(1, 5, 1));
  39. (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30));
  40. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,255,255,0));
  41. smgr->drawAll();
  42. driver->endScene();
  43. result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96);
  44. }
  45. }
  46. device->closeDevice();
  47. device->run();
  48. device->drop();
  49. return result;
  50. }
  51. bool lightMaps(void)
  52. {
  53. bool result = true;
  54. TestWithAllDrivers(runTestWithDriver);
  55. return result;
  56. }