View3D.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "Window.h"
  24. namespace Urho3D
  25. {
  26. class Camera;
  27. class Node;
  28. class Scene;
  29. class Texture2D;
  30. class Viewport;
  31. /// %UI element which renders a 3D scene.
  32. class URHO3D_API View3D : public Window
  33. {
  34. OBJECT(View3D);
  35. public:
  36. /// Construct.
  37. View3D(Context* context);
  38. /// Destruct.
  39. ~View3D();
  40. /// Register object factory.
  41. static void RegisterObject(Context* context);
  42. /// React to resize.
  43. virtual void OnResize();
  44. /// Define the scene and camera to use in rendering. The View3D will take ownership of them with shared pointers.
  45. void SetView(Scene* scene, Camera* camera);
  46. /// Set render texture pixel format. Default is RGB.
  47. void SetFormat(unsigned format);
  48. /// Set render target auto update mode. Default is true.
  49. void SetAutoUpdate(bool enable);
  50. /// Queue manual update on the render texture.
  51. void QueueUpdate();
  52. /// Return render texture pixel format.
  53. unsigned GetFormat() const { return rttFormat_; }
  54. /// Return whether render target updates automatically.
  55. bool GetAutoUpdate() const { return autoUpdate_; }
  56. /// Return scene.
  57. Scene* GetScene() const;
  58. /// Return camera scene node.
  59. Node* GetCameraNode() const;
  60. /// Return render texture.
  61. Texture2D* GetRenderTexture() const;
  62. /// Return depth stencil texture.
  63. Texture2D* GetDepthTexture() const;
  64. /// Return viewport.
  65. Viewport* GetViewport() const;
  66. /// Renderable texture.
  67. SharedPtr<Texture2D> renderTexture_;
  68. /// Depth stencil texture.
  69. SharedPtr<Texture2D> depthTexture_;
  70. /// Viewport.
  71. SharedPtr<Viewport> viewport_;
  72. /// Scene.
  73. SharedPtr<Scene> scene_;
  74. /// Camera scene node.
  75. SharedPtr<Node> cameraNode_;
  76. /// Render texture format.
  77. unsigned rttFormat_;
  78. /// Render texture auto update mode.
  79. bool autoUpdate_;
  80. };
  81. }