BsD3D9TextureManager.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsD3D9TextureManager.h"
  4. #include "BsD3D9Texture.h"
  5. #include "BsD3D9RenderTexture.h"
  6. #include "BsException.h"
  7. #include "BsD3D9Mappings.h"
  8. #include "BsD3D9RenderAPI.h"
  9. #include "BsD3D9MultiRenderTexture.h"
  10. namespace BansheeEngine
  11. {
  12. D3D9TextureManager::D3D9TextureManager()
  13. :TextureManager()
  14. { }
  15. D3D9TextureManager::~D3D9TextureManager()
  16. { }
  17. RenderTexturePtr D3D9TextureManager::createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc)
  18. {
  19. D3D9RenderTexture* tex = new (bs_alloc<D3D9RenderTexture>()) D3D9RenderTexture(desc);
  20. return bs_core_ptr<D3D9RenderTexture>(tex);
  21. }
  22. MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc)
  23. {
  24. D3D9MultiRenderTexture* tex = new (bs_alloc<D3D9MultiRenderTexture>()) D3D9MultiRenderTexture(desc);
  25. return bs_core_ptr<D3D9MultiRenderTexture>(tex);
  26. }
  27. PixelFormat D3D9TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
  28. {
  29. if((usage & TU_RENDERTARGET) != 0)
  30. {
  31. return D3D9Mappings::_getClosestSupportedRenderTargetPF(format);
  32. }
  33. else if((usage & TU_DEPTHSTENCIL) != 0)
  34. {
  35. return D3D9Mappings::_getClosestSupportedDepthStencilPF(format);
  36. }
  37. else
  38. {
  39. // Basic filtering
  40. return D3D9Mappings::_getClosestSupportedPF(format);
  41. }
  42. }
  43. SPtr<TextureCore> D3D9TextureCoreManager::createTextureInternal(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
  44. int numMips, PixelFormat format, int usage, bool hwGammaCorrection, UINT32 multisampleCount, const PixelDataPtr& initialData)
  45. {
  46. D3D9TextureCore* tex = new (bs_alloc<D3D9TextureCore>()) D3D9TextureCore(texType,
  47. width, height, depth, numMips, format, usage, hwGammaCorrection, multisampleCount, initialData);
  48. SPtr<D3D9TextureCore> texPtr = bs_shared_ptr<D3D9TextureCore>(tex);
  49. texPtr->_setThisPtr(texPtr);
  50. return texPtr;
  51. }
  52. SPtr<RenderTextureCore> D3D9TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc)
  53. {
  54. SPtr<D3D9RenderTextureCore> texPtr = bs_shared_ptr_new<D3D9RenderTextureCore>(desc);
  55. texPtr->_setThisPtr(texPtr);
  56. return texPtr;
  57. }
  58. SPtr<MultiRenderTextureCore> D3D9TextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
  59. {
  60. SPtr<D3D9MultiRenderTextureCore> texPtr = bs_shared_ptr_new<D3D9MultiRenderTextureCore>(desc);
  61. texPtr->_setThisPtr(texPtr);
  62. return texPtr;
  63. }
  64. }