CmD3D9MultiRenderTexture.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "CmD3D9MultiRenderTexture.h"
  2. #include "CmD3D9Texture.h"
  3. #include "CmD3D9RenderSystem.h"
  4. namespace CamelotEngine
  5. {
  6. D3D9MultiRenderTexture::D3D9MultiRenderTexture()
  7. :MultiRenderTexture(), mDX9DepthStencilSurface(nullptr)
  8. {
  9. }
  10. D3D9MultiRenderTexture::~D3D9MultiRenderTexture()
  11. {
  12. }
  13. void D3D9MultiRenderTexture::setColorSurfaceImpl(UINT32 surfaceIdx, TexturePtr texture, UINT32 face, UINT32 numFaces, UINT32 mipLevel)
  14. {
  15. if(texture != nullptr)
  16. {
  17. D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(texture.get());
  18. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9texture->getBuffer(face, mipLevel).get());
  19. mDX9ColorSurfaces[surfaceIdx] = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  20. }
  21. else
  22. {
  23. mDX9ColorSurfaces[surfaceIdx] = nullptr;
  24. }
  25. }
  26. void D3D9MultiRenderTexture::setDepthStencilImpl(TexturePtr depthStencilSurface)
  27. {
  28. if(depthStencilSurface != nullptr)
  29. {
  30. D3D9Texture* d3d9DepthStencil = static_cast<D3D9Texture*>(mDepthStencilSurface.get());
  31. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(d3d9DepthStencil->getBuffer(0, 0).get());
  32. mDX9DepthStencilSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  33. }
  34. else
  35. {
  36. mDX9DepthStencilSurface = nullptr;
  37. }
  38. }
  39. void D3D9MultiRenderTexture::getCustomAttribute(const String& name, void* pData)
  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. void D3D9MultiRenderTexture::initialize()
  62. {
  63. mDX9ColorSurfaces.resize(CM_MAX_MULTIPLE_RENDER_TARGETS);
  64. }
  65. }