D3D11RenderSurface.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #include "../../Precompiled.h"
  4. #include "../../Graphics/Camera.h"
  5. #include "../../Graphics/Graphics.h"
  6. #include "../../Graphics/Renderer.h"
  7. #include "../../GraphicsAPI/GraphicsImpl.h"
  8. #include "../../GraphicsAPI/RenderSurface.h"
  9. #include "../../GraphicsAPI/Texture.h"
  10. #include "../../DebugNew.h"
  11. namespace Urho3D
  12. {
  13. void RenderSurface::Constructor_D3D11(Texture* parentTexture)
  14. {
  15. parentTexture_ = parentTexture;
  16. renderTargetView_ = nullptr;
  17. readOnlyView_ = nullptr;
  18. }
  19. void RenderSurface::Release_D3D11()
  20. {
  21. Graphics* graphics = parentTexture_->GetGraphics();
  22. if (graphics && renderTargetView_)
  23. {
  24. for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
  25. {
  26. if (graphics->GetRenderTarget(i) == this)
  27. graphics->ResetRenderTarget(i);
  28. }
  29. if (graphics->GetDepthStencil() == this)
  30. graphics->ResetDepthStencil();
  31. }
  32. URHO3D_SAFE_RELEASE(renderTargetView_);
  33. URHO3D_SAFE_RELEASE(readOnlyView_);
  34. }
  35. bool RenderSurface::CreateRenderBuffer_D3D11(unsigned width, unsigned height, unsigned format, int multiSample)
  36. {
  37. // Not used on Direct3D
  38. return false;
  39. }
  40. void RenderSurface::OnDeviceLost_D3D11()
  41. {
  42. // No-op on Direct3D
  43. }
  44. }