Viewport

Creates a sub-view into the screen.

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. Optionally, a viewport can have its own 2D or 3D world, so they don't share what they draw with other viewports. If a viewport is a child of a ViewportContainer, it will automatically take up its size, otherwise it 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 case the devices have multiple screens. Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.

@GodotBaseClass
struct Viewport {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

ClearMode
enum ClearMode
Constants
enum Constants
DebugDraw
enum DebugDraw
MSAA
enum MSAA
RenderInfo
enum RenderInfo
ShadowAtlasQuadrantSubdiv
enum ShadowAtlasQuadrantSubdiv
UpdateMode
enum UpdateMode
Usage
enum Usage

Functions

_guiRemoveFocus
void _guiRemoveFocus()
_guiShowTooltip
void _guiShowTooltip()
_postGuiGrabClickFocus
void _postGuiGrabClickFocus()
_subwindowVisibilityChanged
void _subwindowVisibilityChanged()
_vpInput
void _vpInput(InputEvent arg0)
_vpInputText
void _vpInputText(StringArg0 text)
_vpUnhandledInput
void _vpUnhandledInput(InputEvent arg0)
findWorld
Ref!World findWorld()

Returns the 3D world of the viewport, or if none the world of the parent viewport.

findWorld2d
Ref!World2D findWorld2d()

Returns the 2D world of the viewport.

getCamera
Camera getCamera()

Returns the active 3D camera.

getCanvasTransform
Transform2D getCanvasTransform()
getClearMode
Viewport.ClearMode getClearMode()
getDebugDraw
Viewport.DebugDraw getDebugDraw()
getFinalTransform
Transform2D getFinalTransform()

Returns the total transform of the viewport.

getGlobalCanvasTransform
Transform2D getGlobalCanvasTransform()
getHdr
bool getHdr()
getKeep3dLinear
bool getKeep3dLinear()
getModalStackTop
Control getModalStackTop()

Returns the topmost modal in the stack.

getMousePosition
Vector2 getMousePosition()

Returns the mouse position relative to the viewport.

getMsaa
Viewport.MSAA getMsaa()
getPhysicsObjectPicking
bool getPhysicsObjectPicking()
getRenderInfo
long getRenderInfo(long info)

Returns information about the viewport from the rendering pipeline.

getShadowAtlasQuadrantSubdiv
Viewport.ShadowAtlasQuadrantSubdiv getShadowAtlasQuadrantSubdiv(long quadrant)
getShadowAtlasSize
long getShadowAtlasSize()
getSize
Vector2 getSize()
getSizeOverride
Vector2 getSizeOverride()

Returns the size override set with setSizeOverride.

getTexture
Ref!ViewportTexture getTexture()

Returns the viewport's texture.

getUpdateMode
Viewport.UpdateMode getUpdateMode()
getUsage
Viewport.Usage getUsage()
getVflip
bool getVflip()
getViewportRid
RID getViewportRid()

Returns the viewport's RID from the VisualServer.

getVisibleRect
Rect2 getVisibleRect()

Returns the visible rectangle in global screen coordinates.

getWorld
Ref!World getWorld()
getWorld2d
Ref!World2D getWorld2d()
guiGetDragData
Variant guiGetDragData()

Returns the drag data from the GUI, that was previously returned by Control.getDragData.

guiHasModalStack
bool guiHasModalStack()

Returns true if there are visible modals on-screen.

guiIsDragging
bool guiIsDragging()
hasTransparentBackground
bool hasTransparentBackground()
input
void input(InputEvent local_event)
is3dDisabled
bool is3dDisabled()
isAudioListener
bool isAudioListener()
isAudioListener2d
bool isAudioListener2d()
isInputDisabled
bool isInputDisabled()
isSizeOverrideEnabled
bool isSizeOverrideEnabled()

Returns true if the size override is enabled. See setSizeOverride.

isSizeOverrideStretchEnabled
bool isSizeOverrideStretchEnabled()

Returns true if the size stretch override is enabled. See setSizeOverrideStretch.

isSnapControlsToPixelsEnabled
bool isSnapControlsToPixelsEnabled()
isUsingOwnWorld
bool isUsingOwnWorld()
opAssign
Viewport opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Viewport other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
setAsAudioListener
void setAsAudioListener(bool enable)
setAsAudioListener2d
void setAsAudioListener2d(bool enable)
setAttachToScreenRect
void setAttachToScreenRect(Rect2 rect)
setCanvasTransform
void setCanvasTransform(Transform2D xform)
setClearMode
void setClearMode(long mode)
setDebugDraw
void setDebugDraw(long debug_draw)
setDisable3d
void setDisable3d(bool disable)
setDisableInput
void setDisableInput(bool disable)
setGlobalCanvasTransform
void setGlobalCanvasTransform(Transform2D xform)
setHdr
void setHdr(bool enable)
setKeep3dLinear
void setKeep3dLinear(bool keep_3d_linear)
setMsaa
void setMsaa(long msaa)
setPhysicsObjectPicking
void setPhysicsObjectPicking(bool enable)
setShadowAtlasQuadrantSubdiv
void setShadowAtlasQuadrantSubdiv(long quadrant, long subdiv)
setShadowAtlasSize
void setShadowAtlasSize(long size)
setSize
void setSize(Vector2 size)
setSizeOverride
void setSizeOverride(bool enable, Vector2 size, Vector2 margin)

Sets the size override of the viewport. If the enable parameter is true the override is used, otherwise it uses the default size. If the size parameter is (-1, -1), it won't update the size.

setSizeOverrideStretch
void setSizeOverrideStretch(bool enabled)

If true the size override affects stretch as well.

setSnapControlsToPixels
void setSnapControlsToPixels(bool enabled)
setTransparentBackground
void setTransparentBackground(bool enable)
setUpdateMode
void setUpdateMode(long mode)
setUsage
void setUsage(long usage)
setUseArvr
void setUseArvr(bool use)
setUseOwnWorld
void setUseOwnWorld(bool enable)
setVflip
void setVflip(bool enable)
setWorld
void setWorld(World world)
setWorld2d
void setWorld2d(World2D world_2d)
unhandledInput
void unhandledInput(InputEvent local_event)
updateWorlds
void updateWorlds()

Forces update of the 2D and 3D worlds.

useArvr
bool useArvr()
warpMouse
void warpMouse(Vector2 to_position)

Warps the mouse to a position relative to the viewport.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

arvr
bool arvr [@property getter]
bool arvr [@property setter]

If true the viewport will be used in AR/VR process. Default value: false.

audioListenerEnable2d
bool audioListenerEnable2d [@property setter]

If true the viewport will process 2D audio streams. Default value: false.

audioListenerEnable2d
bool audioListenerEnable2d [@property getter]

If true the viewport will process 2D audio streams. Default value: false.

audioListenerEnable3d
bool audioListenerEnable3d [@property setter]

If true the viewport will process 3D audio streams. Default value: false.

audioListenerEnable3d
bool audioListenerEnable3d [@property getter]

If true the viewport will process 3D audio streams. Default value: false.

canvasTransform
Transform2D canvasTransform [@property setter]

The canvas transform of the viewport, useful for changing the on-screen positions of all child CanvasItems. This is relative to the global canvas transform of the viewport.

canvasTransform
Transform2D canvasTransform [@property getter]

The canvas transform of the viewport, useful for changing the on-screen positions of all child CanvasItems. This is relative to the global canvas transform of the viewport.

debugDraw
long debugDraw [@property setter]

The overlay mode for test rendered geometry in debug purposes. Default value: DEBUG_DRAW_DISABLED.

debugDraw
Viewport.DebugDraw debugDraw [@property getter]

The overlay mode for test rendered geometry in debug purposes. Default value: DEBUG_DRAW_DISABLED.

disable3d
bool disable3d [@property setter]

If true the viewport will disable 3D rendering. For actual disabling use usage. Default value: false.

disable3d
bool disable3d [@property getter]

If true the viewport will disable 3D rendering. For actual disabling use usage. Default value: false.

globalCanvasTransform
Transform2D globalCanvasTransform [@property getter]
Transform2D globalCanvasTransform [@property setter]

The global canvas transform of the viewport. The canvas transform is relative to this.

guiDisableInput
bool guiDisableInput [@property getter]
bool guiDisableInput [@property setter]

If true the viewport will not receive input event. Default value: false.

guiSnapControlsToPixels
bool guiSnapControlsToPixels [@property getter]
bool guiSnapControlsToPixels [@property setter]

If true the GUI controls on the viewport will lay pixel perfectly. Default value: true.

hdr
bool hdr [@property getter]
bool hdr [@property setter]

If true the viewport rendering will receive benefits from High Dynamic Range algorithm. Default value: true.

keep3dLinear
bool keep3dLinear [@property getter]
bool keep3dLinear [@property setter]

If true the result after 3D rendering will not have a linear to sRGB color conversion applied. This is important when the viewport is used as a render target where the result is used as a texture on a 3D object rendered in another viewport. It is also important if the viewport is used to create data that is not color based (noise, heightmaps, pickmaps, etc.). Do not enable this when the viewport is used as a texture on a 2D object or if the viewport is your final output.

msaa
Viewport.MSAA msaa [@property getter]
long msaa [@property setter]

The multisample anti-aliasing mode. Default value: MSAA_DISABLED.

ownWorld
bool ownWorld [@property setter]

If true the viewport will use World defined in world property. Default value: false.

ownWorld
bool ownWorld [@property getter]

If true the viewport will use World defined in world property. Default value: false.

physicsObjectPicking
bool physicsObjectPicking [@property getter]
bool physicsObjectPicking [@property setter]

If true the objects rendered by viewport become subjects of mouse picking process. Default value: false.

renderTargetClearMode
Viewport.ClearMode renderTargetClearMode [@property getter]
long renderTargetClearMode [@property setter]

The clear mode when viewport used as a render target. Default value: CLEAR_MODE_ALWAYS.

renderTargetUpdateMode
Viewport.UpdateMode renderTargetUpdateMode [@property getter]
long renderTargetUpdateMode [@property setter]

The update mode when viewport used as a render target. Default value: UPDATE_WHEN_VISIBLE.

renderTargetVFlip
bool renderTargetVFlip [@property getter]
bool renderTargetVFlip [@property setter]

If true the result of rendering will be flipped vertically. Default value: false.

shadowAtlasQuad0
Viewport.ShadowAtlasQuadrantSubdiv shadowAtlasQuad0 [@property getter]
long shadowAtlasQuad0 [@property setter]

The subdivision amount of first quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_4.

shadowAtlasQuad1
Viewport.ShadowAtlasQuadrantSubdiv shadowAtlasQuad1 [@property getter]
long shadowAtlasQuad1 [@property setter]

The subdivision amount of second quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_4.

shadowAtlasQuad2
Viewport.ShadowAtlasQuadrantSubdiv shadowAtlasQuad2 [@property getter]
long shadowAtlasQuad2 [@property setter]

The subdivision amount of third quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_16.

shadowAtlasQuad3
Viewport.ShadowAtlasQuadrantSubdiv shadowAtlasQuad3 [@property getter]
long shadowAtlasQuad3 [@property setter]

The subdivision amount of fourth quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_64.

shadowAtlasSize
long shadowAtlasSize [@property getter]
long shadowAtlasSize [@property setter]

The resolution of shadow atlas. Both width and height is equal to one value.

size
Vector2 size [@property setter]

The width and height of viewport.

size
Vector2 size [@property getter]

The width and height of viewport.

transparentBg
bool transparentBg [@property getter]
bool transparentBg [@property setter]

If true the viewport should render its background as transparent. Default value: false.

usage
Viewport.Usage usage [@property getter]
long usage [@property setter]

The rendering mode of viewport. Default value: USAGE_3D.

world
World world [@property setter]

The custom World which can be used as 3D environment source.

world
World world [@property getter]

The custom World which can be used as 3D environment source.

world2d
World2D world2d [@property setter]

The custom World2D which can be used as 2D environment source.

world2d
World2D world2d [@property getter]

The custom World2D which can be used as 2D environment source.

Static functions

_new
Viewport _new()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
ToRef as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta