BsD3D9TextureManager.cpp 2.4 KB

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