BsD3D9MultiRenderTexture.cpp 2.0 KB

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