BsD3D9DriverList.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #include "BsD3D9DriverList.h"
  5. #include "BsD3D9VideoModeInfo.h"
  6. #include "BsException.h"
  7. #include "BsD3D9RenderSystem.h"
  8. namespace BansheeEngine
  9. {
  10. D3D9DriverList::D3D9DriverList()
  11. {
  12. IDirect3D9* lpD3D9 = D3D9RenderSystem::getDirect3D9();
  13. for (UINT32 i = 0; i < lpD3D9->GetAdapterCount(); i++)
  14. {
  15. D3DADAPTER_IDENTIFIER9 adapterIdentifier;
  16. D3DCAPS9 d3dcaps9;
  17. lpD3D9->GetAdapterIdentifier(i, 0, &adapterIdentifier);
  18. lpD3D9->GetDeviceCaps(i, D3DDEVTYPE_HAL, &d3dcaps9);
  19. mDriverList.push_back(D3D9Driver(i, d3dcaps9, adapterIdentifier));
  20. }
  21. mVideoModeInfo = bs_shared_ptr<D3D9VideoModeInfo>(lpD3D9);
  22. }
  23. D3D9DriverList::~D3D9DriverList()
  24. {
  25. mDriverList.clear();
  26. }
  27. UINT32 D3D9DriverList::count() const
  28. {
  29. return (UINT32)mDriverList.size();
  30. }
  31. D3D9Driver* D3D9DriverList::item(UINT32 index)
  32. {
  33. return &mDriverList.at(index);
  34. }
  35. D3D9Driver* D3D9DriverList::item(const String &name)
  36. {
  37. Vector<D3D9Driver>::iterator it = mDriverList.begin();
  38. if (it == mDriverList.end())
  39. return nullptr;
  40. for (;it != mDriverList.end(); ++it)
  41. {
  42. if (it->getDriverDescription() == name)
  43. return &(*it);
  44. }
  45. return nullptr;
  46. }
  47. }