Viewport.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "Ptr.h"
  25. #include "Rect.h"
  26. class Camera;
  27. class PostProcess;
  28. class Scene;
  29. /// %Viewport definition either for a render surface or the backbuffer.
  30. class Viewport : public RefCounted
  31. {
  32. public:
  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. /// Construct with a full rectangle and post-processing effects.
  40. Viewport(Scene* scene, Camera* camera, const Vector<SharedPtr<PostProcess> >& postProcesses);
  41. /// Construct with a specified rectangle and post-processing effects.
  42. Viewport(Scene* scene, Camera* camera, const IntRect& rect, const Vector<SharedPtr<PostProcess> >& postProcesses);
  43. /// Destruct.
  44. ~Viewport();
  45. /// %Set scene.
  46. void SetScene(Scene* scene);
  47. /// %Set camera.
  48. void SetCamera(Camera* camera);
  49. /// %Set rectangle.
  50. void SetRect(const IntRect& rect);
  51. /// Add a post-processing effect at the end of the chain.
  52. void AddPostProcess(PostProcess* effect);
  53. /// Insert a post-processing effect at position in the chain.
  54. void InsertPostProcess(unsigned index, PostProcess* effect);
  55. /// Remove a post-processing effect.
  56. void RemovePostProcess(PostProcess* effect);
  57. /// Remove a post-processing effect by index.
  58. void RemovePostProcess(unsigned index);
  59. /// Remove all post-processing effects.
  60. void RemoveAllPostProcesses();
  61. /// Return scene.
  62. Scene* GetScene() const;
  63. /// Return camera.
  64. Camera* GetCamera() const;
  65. /// Return rectangle.
  66. const IntRect& GetRect() const { return rect_; }
  67. /// Return number of post-processing effects.
  68. unsigned GetNumPostProcesses() const { return postProcesses_.Size(); }
  69. /// Return post-processing effect at index.
  70. PostProcess* GetPostProcess(unsigned index) const;
  71. /// Return all post-processing effects.
  72. const Vector<SharedPtr<PostProcess> >& GetPostProcesses() const { return postProcesses_; }
  73. private:
  74. /// Scene pointer.
  75. WeakPtr<Scene> scene_;
  76. /// Camera pointer.
  77. WeakPtr<Camera> camera_;
  78. /// Viewport rectangle.
  79. IntRect rect_;
  80. /// Post-processing effects.
  81. Vector<SharedPtr<PostProcess> > postProcesses_;
  82. };