class_subviewport.rst 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/SubViewport.xml.
  6. .. _class_SubViewport:
  7. SubViewport
  8. ===========
  9. **Inherits:** :ref:`Viewport<class_Viewport>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. An interface to a game world that doesn't create a window or draw to the screen directly.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **SubViewport** Isolates a rectangular region of a scene to be displayed independently. This can be used, for example, to display UI in 3D space.
  15. \ **Note:** **SubViewport** is a :ref:`Viewport<class_Viewport>` that isn't a :ref:`Window<class_Window>`, i.e. it doesn't draw anything by itself. To display anything, **SubViewport** must have a non-zero size and be either put inside a :ref:`SubViewportContainer<class_SubViewportContainer>` or assigned to a :ref:`ViewportTexture<class_ViewportTexture>`.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Using Viewports <../tutorials/rendering/viewports>`
  20. - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
  21. - `GUI in 3D Demo <https://godotengine.org/asset-library/asset/127>`__
  22. - `3D in 2D Demo <https://godotengine.org/asset-library/asset/128>`__
  23. - `2D in 3D Demo <https://godotengine.org/asset-library/asset/129>`__
  24. - `Screen Capture Demo <https://godotengine.org/asset-library/asset/130>`__
  25. - `Dynamic Split Screen Demo <https://godotengine.org/asset-library/asset/541>`__
  26. - `3D Viewport Scaling Demo <https://godotengine.org/asset-library/asset/586>`__
  27. .. rst-class:: classref-reftable-group
  28. Properties
  29. ----------
  30. .. table::
  31. :widths: auto
  32. +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+
  33. | :ref:`ClearMode<enum_SubViewport_ClearMode>` | :ref:`render_target_clear_mode<class_SubViewport_property_render_target_clear_mode>` | ``0`` |
  34. +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+
  35. | :ref:`UpdateMode<enum_SubViewport_UpdateMode>` | :ref:`render_target_update_mode<class_SubViewport_property_render_target_update_mode>` | ``2`` |
  36. +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+
  37. | :ref:`Vector2i<class_Vector2i>` | :ref:`size<class_SubViewport_property_size>` | ``Vector2i(512, 512)`` |
  38. +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+
  39. | :ref:`Vector2i<class_Vector2i>` | :ref:`size_2d_override<class_SubViewport_property_size_2d_override>` | ``Vector2i(0, 0)`` |
  40. +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`size_2d_override_stretch<class_SubViewport_property_size_2d_override_stretch>` | ``false`` |
  42. +------------------------------------------------+----------------------------------------------------------------------------------------+------------------------+
  43. .. rst-class:: classref-section-separator
  44. ----
  45. .. rst-class:: classref-descriptions-group
  46. Enumerations
  47. ------------
  48. .. _enum_SubViewport_ClearMode:
  49. .. rst-class:: classref-enumeration
  50. enum **ClearMode**:
  51. .. _class_SubViewport_constant_CLEAR_MODE_ALWAYS:
  52. .. rst-class:: classref-enumeration-constant
  53. :ref:`ClearMode<enum_SubViewport_ClearMode>` **CLEAR_MODE_ALWAYS** = ``0``
  54. Always clear the render target before drawing.
  55. .. _class_SubViewport_constant_CLEAR_MODE_NEVER:
  56. .. rst-class:: classref-enumeration-constant
  57. :ref:`ClearMode<enum_SubViewport_ClearMode>` **CLEAR_MODE_NEVER** = ``1``
  58. Never clear the render target.
  59. .. _class_SubViewport_constant_CLEAR_MODE_ONCE:
  60. .. rst-class:: classref-enumeration-constant
  61. :ref:`ClearMode<enum_SubViewport_ClearMode>` **CLEAR_MODE_ONCE** = ``2``
  62. Clear the render target on the next frame, then switch to :ref:`CLEAR_MODE_NEVER<class_SubViewport_constant_CLEAR_MODE_NEVER>`.
  63. .. rst-class:: classref-item-separator
  64. ----
  65. .. _enum_SubViewport_UpdateMode:
  66. .. rst-class:: classref-enumeration
  67. enum **UpdateMode**:
  68. .. _class_SubViewport_constant_UPDATE_DISABLED:
  69. .. rst-class:: classref-enumeration-constant
  70. :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **UPDATE_DISABLED** = ``0``
  71. Do not update the render target.
  72. .. _class_SubViewport_constant_UPDATE_ONCE:
  73. .. rst-class:: classref-enumeration-constant
  74. :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **UPDATE_ONCE** = ``1``
  75. Update the render target once, then switch to :ref:`UPDATE_DISABLED<class_SubViewport_constant_UPDATE_DISABLED>`.
  76. .. _class_SubViewport_constant_UPDATE_WHEN_VISIBLE:
  77. .. rst-class:: classref-enumeration-constant
  78. :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **UPDATE_WHEN_VISIBLE** = ``2``
  79. Update the render target only when it is visible. This is the default value.
  80. .. _class_SubViewport_constant_UPDATE_WHEN_PARENT_VISIBLE:
  81. .. rst-class:: classref-enumeration-constant
  82. :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **UPDATE_WHEN_PARENT_VISIBLE** = ``3``
  83. Update the render target only when its parent is visible.
  84. .. _class_SubViewport_constant_UPDATE_ALWAYS:
  85. .. rst-class:: classref-enumeration-constant
  86. :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **UPDATE_ALWAYS** = ``4``
  87. Always update the render target.
  88. .. rst-class:: classref-section-separator
  89. ----
  90. .. rst-class:: classref-descriptions-group
  91. Property Descriptions
  92. ---------------------
  93. .. _class_SubViewport_property_render_target_clear_mode:
  94. .. rst-class:: classref-property
  95. :ref:`ClearMode<enum_SubViewport_ClearMode>` **render_target_clear_mode** = ``0``
  96. .. rst-class:: classref-property-setget
  97. - void **set_clear_mode** **(** :ref:`ClearMode<enum_SubViewport_ClearMode>` value **)**
  98. - :ref:`ClearMode<enum_SubViewport_ClearMode>` **get_clear_mode** **(** **)**
  99. The clear mode when the sub-viewport is used as a render target.
  100. \ **Note:** This property is intended for 2D usage.
  101. .. rst-class:: classref-item-separator
  102. ----
  103. .. _class_SubViewport_property_render_target_update_mode:
  104. .. rst-class:: classref-property
  105. :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **render_target_update_mode** = ``2``
  106. .. rst-class:: classref-property-setget
  107. - void **set_update_mode** **(** :ref:`UpdateMode<enum_SubViewport_UpdateMode>` value **)**
  108. - :ref:`UpdateMode<enum_SubViewport_UpdateMode>` **get_update_mode** **(** **)**
  109. The update mode when the sub-viewport is used as a render target.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_SubViewport_property_size:
  113. .. rst-class:: classref-property
  114. :ref:`Vector2i<class_Vector2i>` **size** = ``Vector2i(512, 512)``
  115. .. rst-class:: classref-property-setget
  116. - void **set_size** **(** :ref:`Vector2i<class_Vector2i>` value **)**
  117. - :ref:`Vector2i<class_Vector2i>` **get_size** **(** **)**
  118. The width and height of the sub-viewport. Must be set to a value greater than or equal to 2 pixels on both dimensions. Otherwise, nothing will be displayed.
  119. \ **Note:** If the parent node is a :ref:`SubViewportContainer<class_SubViewportContainer>` and its :ref:`SubViewportContainer.stretch<class_SubViewportContainer_property_stretch>` is ``true``, the viewport size cannot be changed manually.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_SubViewport_property_size_2d_override:
  123. .. rst-class:: classref-property
  124. :ref:`Vector2i<class_Vector2i>` **size_2d_override** = ``Vector2i(0, 0)``
  125. .. rst-class:: classref-property-setget
  126. - void **set_size_2d_override** **(** :ref:`Vector2i<class_Vector2i>` value **)**
  127. - :ref:`Vector2i<class_Vector2i>` **get_size_2d_override** **(** **)**
  128. The 2D size override of the sub-viewport. If either the width or height is ``0``, the override is disabled.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_SubViewport_property_size_2d_override_stretch:
  132. .. rst-class:: classref-property
  133. :ref:`bool<class_bool>` **size_2d_override_stretch** = ``false``
  134. .. rst-class:: classref-property-setget
  135. - void **set_size_2d_override_stretch** **(** :ref:`bool<class_bool>` value **)**
  136. - :ref:`bool<class_bool>` **is_size_2d_override_stretch_enabled** **(** **)**
  137. If ``true``, the 2D size override affects stretch as well.
  138. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  139. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  140. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  141. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  142. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  143. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  144. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`