class_viewport.rst 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Viewport.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Viewport:
  5. Viewport
  6. ========
  7. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Creates a sub-view into the screen.
  12. Member Functions
  13. ----------------
  14. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`World<class_world>` | :ref:`find_world<class_Viewport_find_world>` **(** **)** const |
  16. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`World2D<class_world2d>` | :ref:`find_world_2d<class_Viewport_find_world_2d>` **(** **)** const |
  18. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Camera<class_camera>` | :ref:`get_camera<class_Viewport_get_camera>` **(** **)** const |
  20. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Transform2D<class_transform2d>` | :ref:`get_canvas_transform<class_Viewport_get_canvas_transform>` **(** **)** const |
  22. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_clear_mode<class_Viewport_get_clear_mode>` **(** **)** const |
  24. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`get_debug_draw<class_Viewport_get_debug_draw>` **(** **)** const |
  26. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Transform2D<class_transform2d>` | :ref:`get_final_transform<class_Viewport_get_final_transform>` **(** **)** const |
  28. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Transform2D<class_transform2d>` | :ref:`get_global_canvas_transform<class_Viewport_get_global_canvas_transform>` **(** **)** const |
  30. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`get_hdr<class_Viewport_get_hdr>` **(** **)** const |
  32. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Vector2<class_vector2>` | :ref:`get_mouse_position<class_Viewport_get_mouse_position>` **(** **)** const |
  34. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`int<class_int>` | :ref:`get_msaa<class_Viewport_get_msaa>` **(** **)** const |
  36. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`get_physics_object_picking<class_Viewport_get_physics_object_picking>` **(** **)** |
  38. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`get_render_info<class_Viewport_get_render_info>` **(** :ref:`int<class_int>` info **)** |
  40. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_shadow_atlas_quadrant_subdiv<class_Viewport_get_shadow_atlas_quadrant_subdiv>` **(** :ref:`int<class_int>` quadrant **)** const |
  42. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_shadow_atlas_size<class_Viewport_get_shadow_atlas_size>` **(** **)** const |
  44. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector2<class_vector2>` | :ref:`get_size<class_Viewport_get_size>` **(** **)** const |
  46. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Vector2<class_vector2>` | :ref:`get_size_override<class_Viewport_get_size_override>` **(** **)** const |
  48. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`ViewportTexture<class_viewporttexture>` | :ref:`get_texture<class_Viewport_get_texture>` **(** **)** const |
  50. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_update_mode<class_Viewport_get_update_mode>` **(** **)** const |
  52. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`get_usage<class_Viewport_get_usage>` **(** **)** const |
  54. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`get_vflip<class_Viewport_get_vflip>` **(** **)** const |
  56. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`RID<class_rid>` | :ref:`get_viewport_rid<class_Viewport_get_viewport_rid>` **(** **)** const |
  58. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Rect2<class_rect2>` | :ref:`get_visible_rect<class_Viewport_get_visible_rect>` **(** **)** const |
  60. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`World<class_world>` | :ref:`get_world<class_Viewport_get_world>` **(** **)** const |
  62. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`World2D<class_world2d>` | :ref:`get_world_2d<class_Viewport_get_world_2d>` **(** **)** const |
  64. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Variant<class_variant>` | :ref:`gui_get_drag_data<class_Viewport_gui_get_drag_data>` **(** **)** const |
  66. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`bool<class_bool>` | :ref:`gui_has_modal_stack<class_Viewport_gui_has_modal_stack>` **(** **)** const |
  68. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`has_transparent_background<class_Viewport_has_transparent_background>` **(** **)** const |
  70. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`input<class_Viewport_input>` **(** :ref:`InputEvent<class_inputevent>` local_event **)** |
  72. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_3d_disabled<class_Viewport_is_3d_disabled>` **(** **)** const |
  74. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_audio_listener<class_Viewport_is_audio_listener>` **(** **)** const |
  76. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_audio_listener_2d<class_Viewport_is_audio_listener_2d>` **(** **)** const |
  78. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_input_disabled<class_Viewport_is_input_disabled>` **(** **)** const |
  80. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`is_size_override_enabled<class_Viewport_is_size_override_enabled>` **(** **)** const |
  82. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`is_size_override_stretch_enabled<class_Viewport_is_size_override_stretch_enabled>` **(** **)** const |
  84. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_snap_controls_to_pixels_enabled<class_Viewport_is_snap_controls_to_pixels_enabled>` **(** **)** const |
  86. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`bool<class_bool>` | :ref:`is_using_own_world<class_Viewport_is_using_own_world>` **(** **)** const |
  88. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`set_as_audio_listener<class_Viewport_set_as_audio_listener>` **(** :ref:`bool<class_bool>` enable **)** |
  90. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`set_as_audio_listener_2d<class_Viewport_set_as_audio_listener_2d>` **(** :ref:`bool<class_bool>` enable **)** |
  92. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`set_attach_to_screen_rect<class_Viewport_set_attach_to_screen_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** |
  94. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`set_canvas_transform<class_Viewport_set_canvas_transform>` **(** :ref:`Transform2D<class_transform2d>` xform **)** |
  96. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`set_clear_mode<class_Viewport_set_clear_mode>` **(** :ref:`int<class_int>` mode **)** |
  98. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`set_debug_draw<class_Viewport_set_debug_draw>` **(** :ref:`int<class_int>` debug_draw **)** |
  100. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`set_disable_3d<class_Viewport_set_disable_3d>` **(** :ref:`bool<class_bool>` disable **)** |
  102. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`set_disable_input<class_Viewport_set_disable_input>` **(** :ref:`bool<class_bool>` disable **)** |
  104. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`set_global_canvas_transform<class_Viewport_set_global_canvas_transform>` **(** :ref:`Transform2D<class_transform2d>` xform **)** |
  106. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`set_hdr<class_Viewport_set_hdr>` **(** :ref:`bool<class_bool>` enable **)** |
  108. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`set_msaa<class_Viewport_set_msaa>` **(** :ref:`int<class_int>` msaa **)** |
  110. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`set_physics_object_picking<class_Viewport_set_physics_object_picking>` **(** :ref:`bool<class_bool>` enable **)** |
  112. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_shadow_atlas_quadrant_subdiv<class_Viewport_set_shadow_atlas_quadrant_subdiv>` **(** :ref:`int<class_int>` quadrant, :ref:`int<class_int>` subdiv **)** |
  114. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_shadow_atlas_size<class_Viewport_set_shadow_atlas_size>` **(** :ref:`int<class_int>` size **)** |
  116. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`set_size<class_Viewport_set_size>` **(** :ref:`Vector2<class_vector2>` size **)** |
  118. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`set_size_override<class_Viewport_set_size_override>` **(** :ref:`bool<class_bool>` enable, :ref:`Vector2<class_vector2>` size=Vector2( -1, -1 ), :ref:`Vector2<class_vector2>` margin=Vector2( 0, 0 ) **)** |
  120. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`set_size_override_stretch<class_Viewport_set_size_override_stretch>` **(** :ref:`bool<class_bool>` enabled **)** |
  122. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`set_snap_controls_to_pixels<class_Viewport_set_snap_controls_to_pixels>` **(** :ref:`bool<class_bool>` enabled **)** |
  124. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`set_transparent_background<class_Viewport_set_transparent_background>` **(** :ref:`bool<class_bool>` enable **)** |
  126. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`set_update_mode<class_Viewport_set_update_mode>` **(** :ref:`int<class_int>` mode **)** |
  128. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`set_usage<class_Viewport_set_usage>` **(** :ref:`int<class_int>` usage **)** |
  130. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | void | :ref:`set_use_arvr<class_Viewport_set_use_arvr>` **(** :ref:`bool<class_bool>` use **)** |
  132. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | void | :ref:`set_use_own_world<class_Viewport_set_use_own_world>` **(** :ref:`bool<class_bool>` enable **)** |
  134. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | void | :ref:`set_vflip<class_Viewport_set_vflip>` **(** :ref:`bool<class_bool>` enable **)** |
  136. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | void | :ref:`set_world<class_Viewport_set_world>` **(** :ref:`World<class_world>` world **)** |
  138. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | void | :ref:`set_world_2d<class_Viewport_set_world_2d>` **(** :ref:`World2D<class_world2d>` world_2d **)** |
  140. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | void | :ref:`unhandled_input<class_Viewport_unhandled_input>` **(** :ref:`InputEvent<class_inputevent>` local_event **)** |
  142. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | void | :ref:`update_worlds<class_Viewport_update_worlds>` **(** **)** |
  144. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`bool<class_bool>` | :ref:`use_arvr<class_Viewport_use_arvr>` **(** **)** |
  146. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | void | :ref:`warp_mouse<class_Viewport_warp_mouse>` **(** :ref:`Vector2<class_vector2>` to_position **)** |
  148. +------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. Signals
  150. -------
  151. - **size_changed** **(** **)**
  152. Emitted when the size of the viewport is changed, whether by :ref:`set_size_override<class_Viewport_set_size_override>`, resize of window, or some other means.
  153. Member Variables
  154. ----------------
  155. - :ref:`bool<class_bool>` **arvr**
  156. - :ref:`bool<class_bool>` **audio_listener_enable_2d**
  157. - :ref:`bool<class_bool>` **audio_listener_enable_3d**
  158. - :ref:`int<class_int>` **debug_draw**
  159. - :ref:`bool<class_bool>` **disable_3d**
  160. - :ref:`bool<class_bool>` **gui_disable_input**
  161. - :ref:`bool<class_bool>` **gui_snap_controls_to_pixels**
  162. - :ref:`bool<class_bool>` **hdr**
  163. - :ref:`int<class_int>` **msaa**
  164. - :ref:`bool<class_bool>` **own_world**
  165. - :ref:`bool<class_bool>` **physics_object_picking**
  166. - :ref:`int<class_int>` **render_target_clear_mode**
  167. - :ref:`int<class_int>` **render_target_update_mode**
  168. - :ref:`bool<class_bool>` **render_target_v_flip**
  169. - :ref:`int<class_int>` **shadow_atlas_quad_0**
  170. - :ref:`int<class_int>` **shadow_atlas_quad_1**
  171. - :ref:`int<class_int>` **shadow_atlas_quad_2**
  172. - :ref:`int<class_int>` **shadow_atlas_quad_3**
  173. - :ref:`int<class_int>` **shadow_atlas_size**
  174. - :ref:`Vector2<class_vector2>` **size**
  175. - :ref:`bool<class_bool>` **transparent_bg**
  176. - :ref:`int<class_int>` **usage**
  177. - :ref:`World<class_world>` **world**
  178. Numeric Constants
  179. -----------------
  180. - **UPDATE_DISABLED** = **0** --- Do not update the render target.
  181. - **UPDATE_ONCE** = **1** --- Update the render target once, then switch to ``UPDATE_DISABLED``
  182. - **UPDATE_WHEN_VISIBLE** = **2** --- Update the render target only when it is visible. This is the default value.
  183. - **UPDATE_ALWAYS** = **3**
  184. - **SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED** = **0**
  185. - **SHADOW_ATLAS_QUADRANT_SUBDIV_1** = **1**
  186. - **SHADOW_ATLAS_QUADRANT_SUBDIV_4** = **2**
  187. - **SHADOW_ATLAS_QUADRANT_SUBDIV_16** = **3**
  188. - **SHADOW_ATLAS_QUADRANT_SUBDIV_64** = **4**
  189. - **SHADOW_ATLAS_QUADRANT_SUBDIV_256** = **5**
  190. - **SHADOW_ATLAS_QUADRANT_SUBDIV_1024** = **6**
  191. - **SHADOW_ATLAS_QUADRANT_SUBDIV_MAX** = **7**
  192. - **RENDER_INFO_OBJECTS_IN_FRAME** = **0**
  193. - **RENDER_INFO_VERTICES_IN_FRAME** = **1**
  194. - **RENDER_INFO_MATERIAL_CHANGES_IN_FRAME** = **2**
  195. - **RENDER_INFO_SHADER_CHANGES_IN_FRAME** = **3**
  196. - **RENDER_INFO_SURFACE_CHANGES_IN_FRAME** = **4**
  197. - **RENDER_INFO_DRAW_CALLS_IN_FRAME** = **5**
  198. - **RENDER_INFO_MAX** = **6**
  199. - **DEBUG_DRAW_DISABLED** = **0**
  200. - **DEBUG_DRAW_UNSHADED** = **1**
  201. - **DEBUG_DRAW_OVERDRAW** = **2**
  202. - **DEBUG_DRAW_WIREFRAME** = **3**
  203. - **MSAA_DISABLED** = **0**
  204. - **MSAA_2X** = **1**
  205. - **MSAA_4X** = **2**
  206. - **MSAA_8X** = **3**
  207. - **MSAA_16X** = **4**
  208. - **USAGE_2D** = **0**
  209. - **USAGE_2D_NO_SAMPLING** = **1**
  210. - **USAGE_3D** = **2**
  211. - **USAGE_3D_NO_EFFECTS** = **3**
  212. - **CLEAR_MODE_ALWAYS** = **0**
  213. - **CLEAR_MODE_NEVER** = **1**
  214. - **CLEAR_MODE_ONLY_NEXT_FRAME** = **2**
  215. Description
  216. -----------
  217. A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera 3D nodes will render on it too.
  218. Optionally, a viewport can have its own 2D or 3D world, so they don't share what they draw with other viewports.
  219. If a viewport is a child of a :ref:`Control<class_control>`, it will automatically take up its same rect and position, otherwise they must be set manually.
  220. Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it.
  221. Also, viewports can be assigned to different screens in case the devices have multiple screens.
  222. Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.
  223. Member Function Description
  224. ---------------------------
  225. .. _class_Viewport_find_world:
  226. - :ref:`World<class_world>` **find_world** **(** **)** const
  227. Return the 3D world of the viewport, or if no such present, the one of the parent viewport.
  228. .. _class_Viewport_find_world_2d:
  229. - :ref:`World2D<class_world2d>` **find_world_2d** **(** **)** const
  230. Return the 2D world of the viewport.
  231. .. _class_Viewport_get_camera:
  232. - :ref:`Camera<class_camera>` **get_camera** **(** **)** const
  233. Return the active 3D camera.
  234. .. _class_Viewport_get_canvas_transform:
  235. - :ref:`Transform2D<class_transform2d>` **get_canvas_transform** **(** **)** const
  236. Get the canvas transform of the viewport.
  237. .. _class_Viewport_get_clear_mode:
  238. - :ref:`int<class_int>` **get_clear_mode** **(** **)** const
  239. .. _class_Viewport_get_debug_draw:
  240. - :ref:`int<class_int>` **get_debug_draw** **(** **)** const
  241. .. _class_Viewport_get_final_transform:
  242. - :ref:`Transform2D<class_transform2d>` **get_final_transform** **(** **)** const
  243. Get the total transform of the viewport.
  244. .. _class_Viewport_get_global_canvas_transform:
  245. - :ref:`Transform2D<class_transform2d>` **get_global_canvas_transform** **(** **)** const
  246. Get the global canvas transform of the viewport.
  247. .. _class_Viewport_get_hdr:
  248. - :ref:`bool<class_bool>` **get_hdr** **(** **)** const
  249. Get whether the rendered texture has filters enabled.
  250. .. _class_Viewport_get_mouse_position:
  251. - :ref:`Vector2<class_vector2>` **get_mouse_position** **(** **)** const
  252. Get the mouse position, relative to the viewport.
  253. .. _class_Viewport_get_msaa:
  254. - :ref:`int<class_int>` **get_msaa** **(** **)** const
  255. .. _class_Viewport_get_physics_object_picking:
  256. - :ref:`bool<class_bool>` **get_physics_object_picking** **(** **)**
  257. Get whether picking for all physics objects inside the viewport is enabled.
  258. .. _class_Viewport_get_render_info:
  259. - :ref:`int<class_int>` **get_render_info** **(** :ref:`int<class_int>` info **)**
  260. .. _class_Viewport_get_shadow_atlas_quadrant_subdiv:
  261. - :ref:`int<class_int>` **get_shadow_atlas_quadrant_subdiv** **(** :ref:`int<class_int>` quadrant **)** const
  262. .. _class_Viewport_get_shadow_atlas_size:
  263. - :ref:`int<class_int>` **get_shadow_atlas_size** **(** **)** const
  264. .. _class_Viewport_get_size:
  265. - :ref:`Vector2<class_vector2>` **get_size** **(** **)** const
  266. Return the viewport rect. If the viewport is child of a control, it will use the same rect as the parent. Otherwise, if the rect is empty, the viewport will use all the allowed space.
  267. .. _class_Viewport_get_size_override:
  268. - :ref:`Vector2<class_vector2>` **get_size_override** **(** **)** const
  269. Get the size override set with :ref:`set_size_override<class_Viewport_set_size_override>`.
  270. .. _class_Viewport_get_texture:
  271. - :ref:`ViewportTexture<class_viewporttexture>` **get_texture** **(** **)** const
  272. Get the viewport's texture, for use with various objects that you want to texture with the viewport.
  273. .. _class_Viewport_get_update_mode:
  274. - :ref:`int<class_int>` **get_update_mode** **(** **)** const
  275. Get when the viewport would be updated, will be one of the ``UPDATE\_\*`` constants.
  276. .. _class_Viewport_get_usage:
  277. - :ref:`int<class_int>` **get_usage** **(** **)** const
  278. .. _class_Viewport_get_vflip:
  279. - :ref:`bool<class_bool>` **get_vflip** **(** **)** const
  280. Set whether the render target is flipped on the Y axis.
  281. .. _class_Viewport_get_viewport_rid:
  282. - :ref:`RID<class_rid>` **get_viewport_rid** **(** **)** const
  283. Get the viewport RID from the :ref:`VisualServer<class_visualserver>`.
  284. .. _class_Viewport_get_visible_rect:
  285. - :ref:`Rect2<class_rect2>` **get_visible_rect** **(** **)** const
  286. Return the final, visible rect in global screen coordinates.
  287. .. _class_Viewport_get_world:
  288. - :ref:`World<class_world>` **get_world** **(** **)** const
  289. Return the 3D world of the viewport.
  290. .. _class_Viewport_get_world_2d:
  291. - :ref:`World2D<class_world2d>` **get_world_2d** **(** **)** const
  292. Return the 2D world of the viewport.
  293. .. _class_Viewport_gui_get_drag_data:
  294. - :ref:`Variant<class_variant>` **gui_get_drag_data** **(** **)** const
  295. Returs the drag data from the GUI, that was previously returned by :ref:`Control.get_drag_data<class_Control_get_drag_data>`.
  296. .. _class_Viewport_gui_has_modal_stack:
  297. - :ref:`bool<class_bool>` **gui_has_modal_stack** **(** **)** const
  298. Returs whether there are shown modals on-screen.
  299. .. _class_Viewport_has_transparent_background:
  300. - :ref:`bool<class_bool>` **has_transparent_background** **(** **)** const
  301. Return whether the viewport lets whatever is behind it to show.
  302. .. _class_Viewport_input:
  303. - void **input** **(** :ref:`InputEvent<class_inputevent>` local_event **)**
  304. .. _class_Viewport_is_3d_disabled:
  305. - :ref:`bool<class_bool>` **is_3d_disabled** **(** **)** const
  306. .. _class_Viewport_is_audio_listener:
  307. - :ref:`bool<class_bool>` **is_audio_listener** **(** **)** const
  308. Returns whether the viewport sends sounds to the speakers.
  309. .. _class_Viewport_is_audio_listener_2d:
  310. - :ref:`bool<class_bool>` **is_audio_listener_2d** **(** **)** const
  311. Returns whether the viewport sends soundsfrom 2D emitters to the speakers.
  312. .. _class_Viewport_is_input_disabled:
  313. - :ref:`bool<class_bool>` **is_input_disabled** **(** **)** const
  314. Return whether input to the viewport is disabled.
  315. .. _class_Viewport_is_size_override_enabled:
  316. - :ref:`bool<class_bool>` **is_size_override_enabled** **(** **)** const
  317. Get the enabled status of the size override set with :ref:`set_size_override<class_Viewport_set_size_override>`.
  318. .. _class_Viewport_is_size_override_stretch_enabled:
  319. - :ref:`bool<class_bool>` **is_size_override_stretch_enabled** **(** **)** const
  320. Get the enabled status of the size strech override set with :ref:`set_size_override_stretch<class_Viewport_set_size_override_stretch>`.
  321. .. _class_Viewport_is_snap_controls_to_pixels_enabled:
  322. - :ref:`bool<class_bool>` **is_snap_controls_to_pixels_enabled** **(** **)** const
  323. .. _class_Viewport_is_using_own_world:
  324. - :ref:`bool<class_bool>` **is_using_own_world** **(** **)** const
  325. Return whether the viewport is using a world separate from the parent viewport's world.
  326. .. _class_Viewport_set_as_audio_listener:
  327. - void **set_as_audio_listener** **(** :ref:`bool<class_bool>` enable **)**
  328. Makes the viewport send sounds to the speakers.
  329. .. _class_Viewport_set_as_audio_listener_2d:
  330. - void **set_as_audio_listener_2d** **(** :ref:`bool<class_bool>` enable **)**
  331. Makes the viewport send sounds from 2D emitters to the speakers.
  332. .. _class_Viewport_set_attach_to_screen_rect:
  333. - void **set_attach_to_screen_rect** **(** :ref:`Rect2<class_rect2>` rect **)**
  334. .. _class_Viewport_set_canvas_transform:
  335. - void **set_canvas_transform** **(** :ref:`Transform2D<class_transform2d>` xform **)**
  336. Set the canvas transform of the viewport, useful for changing the on-screen positions of all child :ref:`CanvasItem<class_canvasitem>`\ s. This is relative to the global canvas transform of the viewport.
  337. .. _class_Viewport_set_clear_mode:
  338. - void **set_clear_mode** **(** :ref:`int<class_int>` mode **)**
  339. .. _class_Viewport_set_debug_draw:
  340. - void **set_debug_draw** **(** :ref:`int<class_int>` debug_draw **)**
  341. .. _class_Viewport_set_disable_3d:
  342. - void **set_disable_3d** **(** :ref:`bool<class_bool>` disable **)**
  343. .. _class_Viewport_set_disable_input:
  344. - void **set_disable_input** **(** :ref:`bool<class_bool>` disable **)**
  345. Set whether input to the viewport is disabled.
  346. .. _class_Viewport_set_global_canvas_transform:
  347. - void **set_global_canvas_transform** **(** :ref:`Transform2D<class_transform2d>` xform **)**
  348. Set the global canvas transform of the viewport. The canvas transform is relative to this.
  349. .. _class_Viewport_set_hdr:
  350. - void **set_hdr** **(** :ref:`bool<class_bool>` enable **)**
  351. .. _class_Viewport_set_msaa:
  352. - void **set_msaa** **(** :ref:`int<class_int>` msaa **)**
  353. .. _class_Viewport_set_physics_object_picking:
  354. - void **set_physics_object_picking** **(** :ref:`bool<class_bool>` enable **)**
  355. Enable/disable picking for all physics objects inside the viewport.
  356. .. _class_Viewport_set_shadow_atlas_quadrant_subdiv:
  357. - void **set_shadow_atlas_quadrant_subdiv** **(** :ref:`int<class_int>` quadrant, :ref:`int<class_int>` subdiv **)**
  358. .. _class_Viewport_set_shadow_atlas_size:
  359. - void **set_shadow_atlas_size** **(** :ref:`int<class_int>` size **)**
  360. .. _class_Viewport_set_size:
  361. - void **set_size** **(** :ref:`Vector2<class_vector2>` size **)**
  362. Set the size of the viewport.
  363. .. _class_Viewport_set_size_override:
  364. - void **set_size_override** **(** :ref:`bool<class_bool>` enable, :ref:`Vector2<class_vector2>` size=Vector2( -1, -1 ), :ref:`Vector2<class_vector2>` margin=Vector2( 0, 0 ) **)**
  365. Set the size override of the viewport. If the enable parameter is true, it would use the override, otherwise it would use the default size. If the size parameter is equal to ``(-1, -1)``, it won't update the size.
  366. .. _class_Viewport_set_size_override_stretch:
  367. - void **set_size_override_stretch** **(** :ref:`bool<class_bool>` enabled **)**
  368. Set whether the size override affects stretch as well.
  369. .. _class_Viewport_set_snap_controls_to_pixels:
  370. - void **set_snap_controls_to_pixels** **(** :ref:`bool<class_bool>` enabled **)**
  371. .. _class_Viewport_set_transparent_background:
  372. - void **set_transparent_background** **(** :ref:`bool<class_bool>` enable **)**
  373. If this viewport is a child of another viewport, keep the previously drawn background visible.
  374. .. _class_Viewport_set_update_mode:
  375. - void **set_update_mode** **(** :ref:`int<class_int>` mode **)**
  376. Set when the render target would be updated, using the ``UPDATE\_\*`` constants
  377. .. _class_Viewport_set_usage:
  378. - void **set_usage** **(** :ref:`int<class_int>` usage **)**
  379. .. _class_Viewport_set_use_arvr:
  380. - void **set_use_arvr** **(** :ref:`bool<class_bool>` use **)**
  381. If true this viewport will be bound to our ARVR Server.
  382. If this is our main Godot viewport our AR/VR output will be displayed on screen.
  383. If output is redirected to an HMD we'll see the output of just one of the eyes without any distortion applied else we'll see the stereo buffer with distortion applied if applicable
  384. If this is an extra viewport output will only work if redirection to an HMD is supported by the interface. The render target will allow you to use the undistorted output for the right eye in the display.
  385. .. _class_Viewport_set_use_own_world:
  386. - void **set_use_own_world** **(** :ref:`bool<class_bool>` enable **)**
  387. Make the viewport use a world separate from the parent viewport's world.
  388. .. _class_Viewport_set_vflip:
  389. - void **set_vflip** **(** :ref:`bool<class_bool>` enable **)**
  390. Set whether the viewport is flipped on the Y axis.
  391. .. _class_Viewport_set_world:
  392. - void **set_world** **(** :ref:`World<class_world>` world **)**
  393. Change the 3D world of the viewport.
  394. .. _class_Viewport_set_world_2d:
  395. - void **set_world_2d** **(** :ref:`World2D<class_world2d>` world_2d **)**
  396. .. _class_Viewport_unhandled_input:
  397. - void **unhandled_input** **(** :ref:`InputEvent<class_inputevent>` local_event **)**
  398. .. _class_Viewport_update_worlds:
  399. - void **update_worlds** **(** **)**
  400. Force update of the 2D and 3D worlds.
  401. .. _class_Viewport_use_arvr:
  402. - :ref:`bool<class_bool>` **use_arvr** **(** **)**
  403. Returns whether this viewport is using our ARVR Server
  404. .. _class_Viewport_warp_mouse:
  405. - void **warp_mouse** **(** :ref:`Vector2<class_vector2>` to_position **)**
  406. Warp the mouse to a position, relative to the viewport.