D3D9RenderSurface.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // Copyright (c) 2008-2014 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "GraphicsDefs.h"
  24. #include "Viewport.h"
  25. namespace Urho3D
  26. {
  27. class Texture;
  28. /// %Color or depth-stencil surface that can be rendered into.
  29. class URHO3D_API RenderSurface : public RefCounted
  30. {
  31. friend class Texture2D;
  32. friend class TextureCube;
  33. public:
  34. /// Construct with parent texture.
  35. RenderSurface(Texture* parentTexture);
  36. /// Destruct.
  37. ~RenderSurface();
  38. /// Set number of viewports.
  39. void SetNumViewports(unsigned num);
  40. /// Set viewport.
  41. void SetViewport(unsigned index, Viewport* viewport);
  42. /// Set viewport update mode. Default is to update when visible.
  43. void SetUpdateMode(RenderSurfaceUpdateMode mode);
  44. /// Set linked color rendertarget.
  45. void SetLinkedRenderTarget(RenderSurface* renderTarget);
  46. /// Set linked depth-stencil surface.
  47. void SetLinkedDepthStencil(RenderSurface* depthStencil);
  48. /// Queue manual update of the viewport(s).
  49. void QueueUpdate();
  50. /// Release surface.
  51. void Release();
  52. /// Return parent texture.
  53. Texture* GetParentTexture() const { return parentTexture_; }
  54. /// Return Direct3D surface.
  55. void* GetSurface() const { return surface_; }
  56. /// Return width.
  57. int GetWidth() const;
  58. /// Return height.
  59. int GetHeight() const;
  60. /// Return usage.
  61. TextureUsage GetUsage() const;
  62. /// Return number of viewports.
  63. unsigned GetNumViewports() const { return viewports_.Size(); }
  64. /// Return viewport by index.
  65. Viewport* GetViewport(unsigned index) const;
  66. /// Return viewport update mode.
  67. RenderSurfaceUpdateMode GetUpdateMode() const { return updateMode_; }
  68. /// Return linked color rendertarget.
  69. RenderSurface* GetLinkedRenderTarget() const { return linkedRenderTarget_; }
  70. /// Return linked depth-stencil surface.
  71. RenderSurface* GetLinkedDepthStencil() const { return linkedDepthStencil_; }
  72. /// Clear update flag. Called by Renderer.
  73. void WasUpdated();
  74. private:
  75. /// Parent texture.
  76. Texture* parentTexture_;
  77. /// Direct3D surface.
  78. void* surface_;
  79. /// Viewports.
  80. Vector<SharedPtr<Viewport> > viewports_;
  81. /// Linked color buffer.
  82. WeakPtr<RenderSurface> linkedRenderTarget_;
  83. /// Linked depth buffer.
  84. WeakPtr<RenderSurface> linkedDepthStencil_;
  85. /// Update mode for viewports.
  86. RenderSurfaceUpdateMode updateMode_;
  87. /// Update queued flag.
  88. bool updateQueued_;
  89. };
  90. }