Skip to content
Lukas Sägesser edited this page Jun 22, 2015 · 14 revisions

Viewport

####Inherits: Node ####Category: Core

Brief Description

Creates a sub-view into the screen.

Member Functions

Signals

  • size_changed ( )

Numeric Constants

  • RENDER_TARGET_UPDATE_DISABLED = 0
  • RENDER_TARGET_UPDATE_ONCE = 1
  • RENDER_TARGET_UPDATE_WHEN_VISIBLE = 2
  • RENDER_TARGET_UPDATE_ALWAYS = 3

Description

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 renderon it too.

Optionally, a viewport can have it's own 2D or 3D world, so they don't share what they draw with other viewports.

If a viewport is a child of a [Control](class_control), it will automatically take up it's same rect and position, otherwise they must be set manually.

Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it.

Also, viewports can be assigned to different screens in the situation while devices have multiple screens.

Finaly, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.

Member Function Description

  • void set_rect ( Rect2 rect )

Set the viewport rect. If the viewport is child of a control, it will use the same as the parent.

  • Rect2 get_rect ( ) const

Return the viewport rect. If the viewport is child of a control, it will use the same as the parent, otherwise if the rect is empty, the viewport will use all the allowed space.

  • Rect2 get_visible_rect ( ) const

Return the final, visuble rect in global screen coordinates.

  • void set_transparent_background ( bool enable )

Keep whathver the parent viewport has drawn

  • bool has_transparent_background ( ) const

If this viewport is a child of another viewport, keep the previously drawn background visible.

  • RID get_viewport ( ) const

Get the viewport RID from the visual server.

Clone this wiki locally