OgreD3D9DriverList.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #include "OgreD3D9DriverList.h"
  25. #include "OgreException.h"
  26. #include "OgreD3D9RenderSystem.h"
  27. namespace Ogre
  28. {
  29. D3D9DriverList::D3D9DriverList()
  30. {
  31. enumerate();
  32. }
  33. D3D9DriverList::~D3D9DriverList(void)
  34. {
  35. mDriverList.clear();
  36. }
  37. BOOL D3D9DriverList::enumerate()
  38. {
  39. IDirect3D9* lpD3D9 = D3D9RenderSystem::getDirect3D9();
  40. for( UINT iAdapter=0; iAdapter < lpD3D9->GetAdapterCount(); ++iAdapter )
  41. {
  42. D3DADAPTER_IDENTIFIER9 adapterIdentifier;
  43. D3DDISPLAYMODE d3ddm;
  44. D3DCAPS9 d3dcaps9;
  45. lpD3D9->GetAdapterIdentifier( iAdapter, 0, &adapterIdentifier );
  46. lpD3D9->GetAdapterDisplayMode( iAdapter, &d3ddm );
  47. lpD3D9->GetDeviceCaps( iAdapter, D3DDEVTYPE_HAL, &d3dcaps9 );
  48. mDriverList.push_back( D3D9Driver( iAdapter, d3dcaps9, adapterIdentifier, d3ddm ) );
  49. }
  50. return TRUE;
  51. }
  52. size_t D3D9DriverList::count() const
  53. {
  54. return mDriverList.size();
  55. }
  56. D3D9Driver* D3D9DriverList::item( size_t index )
  57. {
  58. return &mDriverList.at( index );
  59. }
  60. D3D9Driver* D3D9DriverList::item( const String &name )
  61. {
  62. vector<D3D9Driver>::type::iterator it = mDriverList.begin();
  63. if (it == mDriverList.end())
  64. return NULL;
  65. for (;it != mDriverList.end(); ++it)
  66. {
  67. if (it->DriverDescription() == name)
  68. return &(*it);
  69. }
  70. return NULL;
  71. }
  72. }