BsD3D9TextureManager.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #include "BsD3D9TextureManager.h"
  5. #include "BsD3D9Texture.h"
  6. #include "BsD3D9RenderTexture.h"
  7. #include "BsException.h"
  8. #include "BsD3D9Mappings.h"
  9. #include "BsD3D9RenderSystem.h"
  10. #include "BsD3D9MultiRenderTexture.h"
  11. namespace BansheeEngine
  12. {
  13. D3D9TextureManager::D3D9TextureManager()
  14. :TextureManager()
  15. { }
  16. D3D9TextureManager::~D3D9TextureManager()
  17. { }
  18. TexturePtr D3D9TextureManager::createTextureImpl()
  19. {
  20. D3D9Texture* tex = new (bs_alloc<D3D9Texture, PoolAlloc>()) D3D9Texture();
  21. return bs_core_ptr<D3D9Texture, PoolAlloc>(tex);
  22. }
  23. RenderTexturePtr D3D9TextureManager::createRenderTextureImpl()
  24. {
  25. D3D9RenderTexture* tex = new (bs_alloc<D3D9RenderTexture, PoolAlloc>()) D3D9RenderTexture();
  26. return bs_core_ptr<D3D9RenderTexture, PoolAlloc>(tex);
  27. }
  28. MultiRenderTexturePtr D3D9TextureManager::createMultiRenderTextureImpl()
  29. {
  30. D3D9MultiRenderTexture* tex = new (bs_alloc<D3D9MultiRenderTexture, PoolAlloc>()) D3D9MultiRenderTexture();
  31. return bs_core_ptr<D3D9MultiRenderTexture, PoolAlloc>(tex);
  32. }
  33. PixelFormat D3D9TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
  34. {
  35. if((usage & TU_RENDERTARGET) != 0)
  36. {
  37. return D3D9Mappings::_getClosestSupportedRenderTargetPF(format);
  38. }
  39. else if((usage & TU_DEPTHSTENCIL) != 0)
  40. {
  41. return D3D9Mappings::_getClosestSupportedDepthStencilPF(format);
  42. }
  43. else
  44. {
  45. // Basic filtering
  46. return D3D9Mappings::_getClosestSupportedPF(format);
  47. }
  48. }
  49. }