D3D9RenderSurface.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 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 "Rect.h"
  25. #include "GraphicsDefs.h"
  26. #include "Ptr.h"
  27. class Camera;
  28. class Scene;
  29. class Texture;
  30. /// %Viewport definition either for a render surface or the backbuffer.
  31. struct Viewport
  32. {
  33. /// Construct with defaults.
  34. Viewport();
  35. /// Construct with a full rectangle.
  36. Viewport(Scene* scene, Camera* camera);
  37. /// Construct with a specified rectangle.
  38. Viewport(Scene* scene, Camera* camera, const IntRect& rect);
  39. /// Scene pointer.
  40. WeakPtr<Scene> scene_;
  41. /// Camera pointer.
  42. WeakPtr<Camera> camera_;
  43. /// Viewport rectangle.
  44. IntRect rect_;
  45. };
  46. /// %Color or depth stencil surface that can be rendered into.
  47. class RenderSurface : public RefCounted
  48. {
  49. friend class Texture2D;
  50. friend class TextureCube;
  51. public:
  52. /// Construct with parent texture.
  53. RenderSurface(Texture* parentTexture);
  54. /// Destruct.
  55. ~RenderSurface();
  56. /// %Set viewport for auxiliary view rendering.
  57. void SetViewport(const Viewport& viewport);
  58. /// %Set linked color buffer.
  59. void SetLinkedRenderTarget(RenderSurface* renderTarget);
  60. /// %Set linked depth buffer.
  61. void SetLinkedDepthBuffer(RenderSurface* depthBuffer);
  62. /// Release surface.
  63. void Release();
  64. /// Return parent texture.
  65. Texture* GetParentTexture() const { return parentTexture_; }
  66. /// Return Direct3D surface.
  67. void* GetSurface() const { return surface_; }
  68. /// Return width.
  69. int GetWidth() const;
  70. /// Return height.
  71. int GetHeight() const;
  72. /// Return usage.
  73. TextureUsage GetUsage() const;
  74. /// Return auxiliary view rendering viewport.
  75. const Viewport& GetViewport() const { return viewport_; }
  76. /// Return linked color buffer.
  77. RenderSurface* GetLinkedRenderTarget() const { return linkedRenderTarget_; }
  78. /// Return linked depth buffer.
  79. RenderSurface* GetLinkedDepthBuffer() const { return linkedDepthBuffer_; }
  80. private:
  81. /// Parent texture.
  82. Texture* parentTexture_;
  83. /// Direct3D surface.
  84. void* surface_;
  85. /// Viewport.
  86. Viewport viewport_;
  87. /// Linked color buffer.
  88. WeakPtr<RenderSurface> linkedRenderTarget_;
  89. /// Linked depth buffer.
  90. WeakPtr<RenderSurface> linkedDepthBuffer_;
  91. };