OGLRenderSurface.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 Camera;
  27. class Scene;
  28. class Texture;
  29. /// %Color or depth-stencil surface that can be rendered into.
  30. class RenderSurface : public RefCounted
  31. {
  32. friend class Texture2D;
  33. friend class TextureCube;
  34. public:
  35. /// Construct with parent texture and target.
  36. RenderSurface(Texture* parentTexture, unsigned target);
  37. /// Destruct.
  38. ~RenderSurface();
  39. /// %Set viewport for auxiliary view rendering.
  40. void SetViewport(Viewport* viewport);
  41. /// %Set linked color rendertarget.
  42. void SetLinkedRenderTarget(RenderSurface* renderTarget);
  43. /// %Set linked depth-stencil surface.
  44. void SetLinkedDepthStencil(RenderSurface* depthStencil);
  45. /// Create a renderbuffer. Return true if successful.
  46. bool CreateRenderBuffer(unsigned width, unsigned height, unsigned format);
  47. /// Release renderbuffer if any.
  48. void Release();
  49. /// Return parent texture.
  50. Texture* GetParentTexture() const { return parentTexture_; }
  51. /// Return surface's OpenGL target.
  52. unsigned GetTarget() const { return target_; }
  53. /// Return renderbuffer if created.
  54. unsigned GetRenderBuffer() const { return renderBuffer_; }
  55. /// Return width.
  56. int GetWidth() const;
  57. /// Return height.
  58. int GetHeight() const;
  59. /// Return usage.
  60. TextureUsage GetUsage() const;
  61. /// Return auxiliary view rendering viewport.
  62. Viewport* GetViewport() const { return viewport_; }
  63. /// Return linked color buffer.
  64. RenderSurface* GetLinkedRenderTarget() const { return linkedRenderTarget_; }
  65. /// Return linked depth buffer.
  66. RenderSurface* GetLinkedDepthStencil() const { return linkedDepthStencil_; }
  67. private:
  68. /// Parent texture.
  69. Texture* parentTexture_;
  70. /// OpenGL target.
  71. unsigned target_;
  72. /// OpenGL renderbuffer.
  73. unsigned renderBuffer_;
  74. /// Viewport.
  75. SharedPtr<Viewport> viewport_;
  76. /// Linked color buffer.
  77. WeakPtr<RenderSurface> linkedRenderTarget_;
  78. /// Linked depth buffer.
  79. WeakPtr<RenderSurface> linkedDepthStencil_;
  80. };