BsD3D9DeviceManager.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "BsD3D9Prerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Handles creation of DirectX 9 devices. Also links the devices
  7. * with created render targets.
  8. */
  9. class BS_D3D9_EXPORT D3D9DeviceManager
  10. {
  11. public:
  12. D3D9DeviceManager();
  13. ~D3D9DeviceManager();
  14. /**
  15. * @brief Changes the active device to the provided device. Must be not null.
  16. */
  17. void setActiveDevice(D3D9Device* device);
  18. /**
  19. * @brief Retrieves the currently active device.
  20. */
  21. D3D9Device* getActiveDevice();
  22. /**
  23. * @brief Sets the device used by the currently active render target.
  24. */
  25. void setActiveRenderTargetDevice(D3D9Device* device);
  26. /**
  27. * @brief Retrieves the device used by the currently active render target.
  28. */
  29. D3D9Device* getActiveRenderTargetDevice();
  30. /**
  31. * @brief Returns the total number of devices available.
  32. */
  33. UINT getDeviceCount();
  34. /**
  35. * @brief Returns the device under the specified index.
  36. */
  37. D3D9Device* getDevice(UINT index);
  38. /**
  39. * @brief Links the provided render window with a device. The window will be
  40. * assigned an existing device if a match one can be found, otherwise
  41. * a new device will be created.
  42. */
  43. void linkRenderWindow(D3D9RenderWindowCore* renderWindow);
  44. /**
  45. * @brief Called by the devices when they're are being destroyed.
  46. */
  47. void notifyOnDeviceDestroy(D3D9Device* device);
  48. /**
  49. * @brief Retrieves engine device from DX9 device.
  50. */
  51. D3D9Device* getDeviceFromD3D9Device(IDirect3DDevice9* d3d9Device);
  52. protected:
  53. /**
  54. * @brief Attempts to find a matching device for the provided render window. If one cannot be found a
  55. * new device is created. Found/created device is returned, as well as a list of all render windows
  56. * using that device.
  57. */
  58. D3D9Device* selectDevice(D3D9RenderWindowCore* renderWindow, Vector<D3D9RenderWindowCore*>& renderWindowsGroup);
  59. /**
  60. * @brief Finds the driver the render window belongs to.
  61. */
  62. D3D9Driver* findDriver(D3D9RenderWindowCore* renderWindow);
  63. Vector<D3D9Device*> mRenderDevices;
  64. D3D9Device* mActiveDevice;
  65. D3D9Device* mActiveRenderWindowDevice;
  66. };
  67. }