CmD3D9RenderTexture.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "CmD3D9RenderTexture.h"
  2. #include "CmD3D9Texture.h"
  3. #include "CmD3D9PixelBuffer.h"
  4. #include "CmD3D9RenderSystem.h"
  5. #include "CmTextureView.h"
  6. namespace CamelotFramework
  7. {
  8. D3D9RenderTexture::D3D9RenderTexture()
  9. :mDX9ColorSurface(nullptr), mDX9DepthStencilSurface(nullptr), mIsBindableToShader(false)
  10. {
  11. }
  12. D3D9RenderTexture::~D3D9RenderTexture()
  13. {
  14. }
  15. void D3D9RenderTexture::getCustomAttribute(const String& name, void* pData) const
  16. {
  17. if(name == "DDBACKBUFFER")
  18. {
  19. IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
  20. *pSurf = mDX9ColorSurface;
  21. return;
  22. }
  23. else if(name == "D3DZBUFFER")
  24. {
  25. IDirect3DSurface9 ** pSurf = (IDirect3DSurface9 **)pData;
  26. *pSurf = mDX9DepthStencilSurface;
  27. return;
  28. }
  29. else if(name == "HWND")
  30. {
  31. HWND *pHwnd = (HWND*)pData;
  32. *pHwnd = NULL;
  33. return;
  34. }
  35. }
  36. void D3D9RenderTexture::initialize_internal()
  37. {
  38. D3D9Texture* d3d9texture = static_cast<D3D9Texture*>(mColorSurface->getTexture().get());
  39. D3D9PixelBuffer* pixelBuffer = static_cast<D3D9PixelBuffer*>(
  40. d3d9texture->getBuffer(mColorSurface->getFirstArraySlice(), mColorSurface->getMostDetailedMip()).get());
  41. mDX9ColorSurface = pixelBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  42. D3D9Texture* d3d9DepthStencil = static_cast<D3D9Texture*>(mDepthStencilSurface->getTexture().get());
  43. D3D9PixelBuffer* depthStencilBuffer = static_cast<D3D9PixelBuffer*>(
  44. d3d9DepthStencil->getBuffer(mDepthStencilSurface->getFirstArraySlice(), mDepthStencilSurface->getMostDetailedMip()).get());
  45. mDX9DepthStencilSurface = depthStencilBuffer->getSurface(D3D9RenderSystem::getActiveD3D9Device());
  46. RenderTexture::initialize_internal();
  47. }
  48. }