Skip to content

class_viewport

reduz edited this page Feb 23, 2014 · 13 revisions

Viewport

Inherits: Node\n\n

Brief Description

Creates a sub-view into the screen.

Member Functions

Signals

  • size_changed ( )

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|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.
  • RID get_viewport ( ) const \ Get the viewport RID from the visual server.

Clone this wiki locally