BsD3D9DeviceManager.h 2.4 KB

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