BsD3D9DriverList.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "BsD3D9DriverList.h"
  2. #include "BsD3D9VideoModeInfo.h"
  3. #include "BsException.h"
  4. #include "BsD3D9RenderAPI.h"
  5. namespace BansheeEngine
  6. {
  7. D3D9DriverList::D3D9DriverList()
  8. {
  9. IDirect3D9* lpD3D9 = D3D9RenderAPI::getDirect3D9();
  10. for (UINT32 i = 0; i < lpD3D9->GetAdapterCount(); i++)
  11. {
  12. D3DADAPTER_IDENTIFIER9 adapterIdentifier;
  13. D3DCAPS9 d3dcaps9;
  14. lpD3D9->GetAdapterIdentifier(i, 0, &adapterIdentifier);
  15. lpD3D9->GetDeviceCaps(i, D3DDEVTYPE_HAL, &d3dcaps9);
  16. mDriverList.push_back(D3D9Driver(i, d3dcaps9, adapterIdentifier));
  17. }
  18. mVideoModeInfo = bs_shared_ptr_new<D3D9VideoModeInfo>(lpD3D9);
  19. }
  20. D3D9DriverList::~D3D9DriverList()
  21. {
  22. mDriverList.clear();
  23. }
  24. UINT32 D3D9DriverList::count() const
  25. {
  26. return (UINT32)mDriverList.size();
  27. }
  28. D3D9Driver* D3D9DriverList::item(UINT32 index)
  29. {
  30. return &mDriverList.at(index);
  31. }
  32. D3D9Driver* D3D9DriverList::item(const String &name)
  33. {
  34. Vector<D3D9Driver>::iterator it = mDriverList.begin();
  35. if (it == mDriverList.end())
  36. return nullptr;
  37. for (;it != mDriverList.end(); ++it)
  38. {
  39. if (it->getDriverDescription() == name)
  40. return &(*it);
  41. }
  42. return nullptr;
  43. }
  44. }