D3D9RenderSurface.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2012 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "GraphicsDefs.h"
  25. #include "Viewport.h"
  26. class Texture;
  27. /// %Color or depth-stencil surface that can be rendered into.
  28. class RenderSurface : public RefCounted
  29. {
  30. friend class Texture2D;
  31. friend class TextureCube;
  32. public:
  33. /// Construct with parent texture.
  34. RenderSurface(Texture* parentTexture);
  35. /// Destruct.
  36. ~RenderSurface();
  37. /// %Set viewport for auxiliary view rendering.
  38. void SetViewport(Viewport* viewport);
  39. /// %Set linked color rendertarget.
  40. void SetLinkedRenderTarget(RenderSurface* renderTarget);
  41. /// %Set linked depth-stencil surface.
  42. void SetLinkedDepthStencil(RenderSurface* depthStencil);
  43. /// Release surface.
  44. void Release();
  45. /// Return parent texture.
  46. Texture* GetParentTexture() const { return parentTexture_; }
  47. /// Return Direct3D surface.
  48. void* GetSurface() const { return surface_; }
  49. /// Return width.
  50. int GetWidth() const;
  51. /// Return height.
  52. int GetHeight() const;
  53. /// Return usage.
  54. TextureUsage GetUsage() const;
  55. /// Return auxiliary view rendering viewport.
  56. Viewport* GetViewport() const { return viewport_; }
  57. /// Return linked color rendertarget.
  58. RenderSurface* GetLinkedRenderTarget() const { return linkedRenderTarget_; }
  59. /// Return linked depth-stencil surface.
  60. RenderSurface* GetLinkedDepthStencil() const { return linkedDepthStencil_; }
  61. private:
  62. /// Parent texture.
  63. Texture* parentTexture_;
  64. /// Direct3D surface.
  65. void* surface_;
  66. /// Viewport.
  67. SharedPtr<Viewport> viewport_;
  68. /// Linked color buffer.
  69. WeakPtr<RenderSurface> linkedRenderTarget_;
  70. /// Linked depth buffer.
  71. WeakPtr<RenderSurface> linkedDepthStencil_;
  72. };