Skip to content
reduz edited this page Feb 23, 2014 · 14 revisions

Viewport

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

Brief Description

Creates a sub-view into the screen.

Member Functions

Signals

  • size&#95changed ( )

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&#95rect ( Rect2 rect )

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

  • Rect2 get&#95rect ( ) 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&#95visible&#95rect ( ) const

Return the final, visuble rect in global screen coordinates.

  • void set&#95transparent&#95background ( bool enable )

Keep whathver the parent viewport has drawn

  • bool has&#95transparent&#95background ( ) const

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

  • RID get&#95viewport ( ) const

Get the viewport RID from the visual server.

Clone this wiki locally