BsD3D9MultiRenderTexture.cpp 2.3 KB

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