BsD3D9TextureManager.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "BsD3D9TextureManager.h"
  2. #include "BsD3D9Texture.h"
  3. #include "BsD3D9RenderTexture.h"
  4. #include "BsException.h"
  5. #include "BsD3D9Mappings.h"
  6. #include "BsD3D9RenderSystem.h"
  7. #include "BsD3D9MultiRenderTexture.h"
  8. namespace BansheeEngine
  9. {
  10. D3D9TextureManager::D3D9TextureManager()
  11. :TextureManager()
  12. { }
  13. D3D9TextureManager::~D3D9TextureManager()
  14. { }
  15. TexturePtr D3D9TextureManager::createTextureImpl()
  16. {
  17. D3D9Texture* tex = new (bs_alloc<D3D9Texture, PoolAlloc>()) D3D9Texture();
  18. return bs_core_ptr<D3D9Texture, PoolAlloc>(tex);
  19. }
  20. RenderTexturePtr D3D9TextureManager::createRenderTextureImpl()
  21. {
  22. D3D9RenderTexture* tex = new (bs_alloc<D3D9RenderTexture, PoolAlloc>()) D3D9RenderTexture();
  23. return bs_core_ptr<D3D9RenderTexture, PoolAlloc>(tex);
  24. }
  25. MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTextureImpl()
  26. {
  27. D3D9MultiRenderTexture* tex = new (bs_alloc<D3D9MultiRenderTexture, PoolAlloc>()) D3D9MultiRenderTexture();
  28. return bs_core_ptr<D3D9MultiRenderTexture, PoolAlloc>(tex);
  29. }
  30. PixelFormat D3D9TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
  31. {
  32. if((usage & TU_RENDERTARGET) != 0)
  33. {
  34. return D3D9Mappings::_getClosestSupportedRenderTargetPF(format);
  35. }
  36. else if((usage & TU_DEPTHSTENCIL) != 0)
  37. {
  38. return D3D9Mappings::_getClosestSupportedDepthStencilPF(format);
  39. }
  40. else
  41. {
  42. // Basic filtering
  43. return D3D9Mappings::_getClosestSupportedPF(format);
  44. }
  45. }
  46. }