BsD3D9DeviceManager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /** @addtogroup D3D9
  8. * @{
  9. */
  10. /** Handles creation of DirectX 9 devices. Also links the devices with created render targets. */
  11. class BS_D3D9_EXPORT D3D9DeviceManager
  12. {
  13. public:
  14. D3D9DeviceManager();
  15. ~D3D9DeviceManager();
  16. /** Changes the active device to the provided device. Must be not null. */
  17. void setActiveDevice(D3D9Device* device);
  18. /** Retrieves the currently active device. */
  19. D3D9Device* getActiveDevice();
  20. /** Sets the device used by the currently active render target. */
  21. void setActiveRenderTargetDevice(D3D9Device* device);
  22. /** Retrieves the device used by the currently active render target. */
  23. D3D9Device* getActiveRenderTargetDevice();
  24. /** Returns the total number of devices available. */
  25. UINT getDeviceCount();
  26. /** Returns the device under the specified index. */
  27. D3D9Device* getDevice(UINT index);
  28. /**
  29. * Links the provided render window with a device. The window will be assigned an existing device if a match one
  30. * can be found, otherwise a new device will be created.
  31. */
  32. void linkRenderWindow(D3D9RenderWindowCore* renderWindow);
  33. /** Called by the devices when they're are being destroyed. */
  34. void notifyOnDeviceDestroy(D3D9Device* device);
  35. /** Retrieves engine device from DX9 device. */
  36. D3D9Device* getDeviceFromD3D9Device(IDirect3DDevice9* d3d9Device);
  37. protected:
  38. /**
  39. * Attempts to find a matching device for the provided render window. If one cannot be found a new device is
  40. * created. Found/created device is returned, as well as a list of all render windows using that device.
  41. */
  42. D3D9Device* selectDevice(D3D9RenderWindowCore* renderWindow, Vector<D3D9RenderWindowCore*>& renderWindowsGroup);
  43. /** Finds the driver the render window belongs to. */
  44. D3D9Driver* findDriver(D3D9RenderWindowCore* renderWindow);
  45. Vector<D3D9Device*> mRenderDevices;
  46. D3D9Device* mActiveDevice;
  47. D3D9Device* mActiveRenderWindowDevice;
  48. };
  49. /** @} */
  50. }