BsD3D9MultiRenderTexture.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include "BsD3D9MultiRenderTexture.h"
  2. #include "BsD3D9Texture.h"
  3. #include "BsD3D9RenderSystem.h"
  4. namespace BansheeEngine
  5. {
  6. D3D9MultiRenderTextureCore::D3D9MultiRenderTextureCore(D3D9MultiRenderTexture* parent, MultiRenderTextureProperties* properties, const MULTI_RENDER_TEXTURE_DESC& desc)
  7. :MultiRenderTextureCore(parent, properties, desc), mDX9DepthStencilSurface(nullptr)
  8. {
  9. mDX9ColorSurfaces.resize(mColorSurfaces.size());
  10. for (size_t i = 0; i < mColorSurfaces.size(); i++)
  11. {
  12. if (mColorSurfaces[i] != nullptr)
  13. {
  14. D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(mColorSurfaces[i]->getTexture().get());
  15. if (d3d9texture->getTextureType() != TEX_TYPE_3D)
  16. {
  17. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(
  18. d3d9texture->getBuffer(mColorSurfaces[i]->getDesc().firstArraySlice, mColorSurfaces[i]->getDesc().mostDetailMip).get());
  19. mDX9ColorSurfaces[i] = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  20. }
  21. else
  22. mDX9ColorSurfaces[i] = nullptr;
  23. }
  24. else
  25. {
  26. mDX9ColorSurfaces[i] = nullptr;
  27. }
  28. }
  29. if (mDepthStencilSurface != nullptr)
  30. {
  31. D3D9Texture* d3d9DepthStencil = static_cast<D3D9Texture*>(mDepthStencilSurface->getTexture().get());
  32. if (d3d9DepthStencil->getTextureType() != TEX_TYPE_3D)
  33. {
  34. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(
  35. d3d9DepthStencil->getBuffer(mDepthStencilSurface->getDesc().firstArraySlice, mDepthStencilSurface->getDesc().mostDetailMip).get());
  36. mDX9DepthStencilSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  37. }
  38. else
  39. mDX9DepthStencilSurface = nullptr;
  40. }
  41. else
  42. {
  43. mDX9DepthStencilSurface = nullptr;
  44. }
  45. }
  46. D3D9MultiRenderTextureCore::~D3D9MultiRenderTextureCore()
  47. {
  48. }
  49. void D3D9MultiRenderTextureCore::getCustomAttribute(const String& name, void* pData) const
  50. {
  51. if(name == "DDBACKBUFFER")
  52. {
  53. IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
  54. for(size_t x = 0; x < mDX9ColorSurfaces.size(); ++x)
  55. pSurf[x] = mDX9ColorSurfaces[x];
  56. return;
  57. }
  58. else if(name == "D3DZBUFFER")
  59. {
  60. IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
  61. *pSurf = mDX9DepthStencilSurface;
  62. return;
  63. }
  64. else if(name == "HWND")
  65. {
  66. HWND *pHwnd = (HWND*)pData;
  67. *pHwnd = NULL;
  68. return;
  69. }
  70. }
  71. RenderTargetProperties* D3D9MultiRenderTexture::createProperties() const
  72. {
  73. return bs_new<MultiRenderTextureProperties>();
  74. }
  75. MultiRenderTextureCore* D3D9MultiRenderTexture::createCore(MultiRenderTextureProperties* properties, const MULTI_RENDER_TEXTURE_DESC& desc)
  76. {
  77. return bs_new<D3D9MultiRenderTextureCore>(this, properties, desc);
  78. }
  79. }