anti-aliasing.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "testUtils.h"
  2. using namespace irr;
  3. static bool testLineRendering(video::E_DRIVER_TYPE type)
  4. {
  5. SIrrlichtCreationParameters params;
  6. params.AntiAlias = 2;
  7. params.Bits = 16;
  8. params.WindowSize = core::dimension2d<u32>(160, 120);
  9. params.DriverType = type;
  10. IrrlichtDevice *device = createDeviceEx(params);
  11. if (!device)
  12. return true; // in case the driver type does not exist
  13. video::IVideoDriver* driver = device->getVideoDriver();
  14. // if no AntiAliasing supported, skip this test
  15. if (driver->getDriverAttributes().getAttributeAsInt("AntiAlias")<2)
  16. {
  17. device->closeDevice();
  18. device->run();
  19. device->drop();
  20. return true;
  21. }
  22. logTestString("Testing driver %ls\n", driver->getName());
  23. scene::ISceneManager* smgr = device->getSceneManager();
  24. scene::IAnimatedMesh* mesh = smgr->getMesh("./media/sydney.md2");
  25. if (!mesh)
  26. {
  27. device->closeDevice();
  28. device->run();
  29. device->drop();
  30. return false;
  31. }
  32. stabilizeScreenBackground(driver);
  33. scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
  34. if (node)
  35. {
  36. node->setMaterialFlag(video::EMF_LIGHTING, false);
  37. node->setMD2Animation(scene::EMAT_STAND);
  38. node->setMaterialTexture( 0, driver->getTexture("./media/sydney.bmp") );
  39. }
  40. smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0));
  41. device->getTimer()->setTime(0); // scene has animations and current scene seems to be saved at that time
  42. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,100,101,140));
  43. smgr->drawAll();
  44. driver->draw3DBox(node->getBoundingBox(), video::SColor(0,255,0,0));
  45. driver->draw2DLine(core::position2di(10,10), core::position2di(100,100), video::SColor(255,0,0,0));
  46. driver->endScene();
  47. bool result = takeScreenshotAndCompareAgainstReference(driver, "-lineAntiAliasing.png", 99.4f );
  48. device->closeDevice();
  49. device->run();
  50. device->drop();
  51. return result;
  52. }
  53. bool antiAliasing()
  54. {
  55. bool result = true;
  56. TestWithAllHWDrivers(testLineRendering);
  57. return result;
  58. }