Viewport.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "Object.h"
  24. #include "Ptr.h"
  25. #include "Rect.h"
  26. namespace Urho3D
  27. {
  28. class Camera;
  29. class RenderPath;
  30. class Scene;
  31. class XMLFile;
  32. /// %Viewport definition either for a render surface or the backbuffer.
  33. class URHO3D_API Viewport : public Object
  34. {
  35. OBJECT(Viewport);
  36. public:
  37. /// Construct with defaults.
  38. Viewport(Context* context);
  39. /// Construct with a full rectangle.
  40. Viewport(Context* context, Scene* scene, Camera* camera, RenderPath* renderPath = 0);
  41. /// Construct with a specified rectangle.
  42. Viewport(Context* context, Scene* scene, Camera* camera, const IntRect& rect, RenderPath* renderPath = 0);
  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. /// Set rendering path.
  52. void SetRenderPath(RenderPath* path);
  53. /// Set rendering path from an XML file.
  54. void SetRenderPath(XMLFile* file);
  55. /// Return scene.
  56. Scene* GetScene() const;
  57. /// Return camera.
  58. Camera* GetCamera() const;
  59. /// Return rectangle.
  60. const IntRect& GetRect() const { return rect_; }
  61. /// Return rendering path.
  62. RenderPath* GetRenderPath() const;
  63. private:
  64. /// Scene pointer.
  65. WeakPtr<Scene> scene_;
  66. /// Camera pointer.
  67. WeakPtr<Camera> camera_;
  68. /// Viewport rectangle.
  69. IntRect rect_;
  70. /// Rendering path.
  71. SharedPtr<RenderPath> renderPath_;
  72. };
  73. }