BsD3D9MultiRenderTexture.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(
  16. d3d9texture->getBuffer(mColorSurfaces[i]->getDesc().firstArraySlice, mColorSurfaces[i]->getDesc().mostDetailMip).get());
  17. mDX9ColorSurfaces[i] = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  18. }
  19. else
  20. {
  21. mDX9ColorSurfaces[i] = nullptr;
  22. }
  23. }
  24. if (mDepthStencilSurface != nullptr)
  25. {
  26. D3D9Texture* d3d9DepthStencil = static_cast<D3D9Texture*>(mDepthStencilSurface->getTexture().get());
  27. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(
  28. d3d9DepthStencil->getBuffer(mDepthStencilSurface->getDesc().firstArraySlice, mDepthStencilSurface->getDesc().mostDetailMip).get());
  29. mDX9DepthStencilSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  30. }
  31. else
  32. {
  33. mDX9DepthStencilSurface = nullptr;
  34. }
  35. }
  36. D3D9MultiRenderTextureCore::~D3D9MultiRenderTextureCore()
  37. {
  38. }
  39. void D3D9MultiRenderTextureCore::getCustomAttribute(const String& name, void* pData) const
  40. {
  41. if(name == "DDBACKBUFFER")
  42. {
  43. IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
  44. for(size_t x = 0; x < mDX9ColorSurfaces.size(); ++x)
  45. pSurf[x] = mDX9ColorSurfaces[x];
  46. return;
  47. }
  48. else if(name == "D3DZBUFFER")
  49. {
  50. IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
  51. *pSurf = mDX9DepthStencilSurface;
  52. return;
  53. }
  54. else if(name == "HWND")
  55. {
  56. HWND *pHwnd = (HWND*)pData;
  57. *pHwnd = NULL;
  58. return;
  59. }
  60. }
  61. RenderTargetProperties* D3D9MultiRenderTexture::createProperties() const
  62. {
  63. return bs_new<MultiRenderTextureProperties>();
  64. }
  65. MultiRenderTextureCore* D3D9MultiRenderTexture::createCore(MultiRenderTextureProperties* properties, const MULTI_RENDER_TEXTURE_DESC& desc)
  66. {
  67. return bs_new<D3D9MultiRenderTextureCore>(this, properties, desc);
  68. }
  69. }