FViewport

Encapsulates the I/O of a viewport.

Windows
MacOS
Linux

Inheritance Hierarchy

Syntax

class FViewport :
    public FRenderTarget,
    protected FRenderResource

Remarks

Encapsulates the I/O of a viewport. The viewport display is implemented using the platform independent RHI.

Variables

Name Description

Public variable

FString

 

AppVersionString

The current version of the running instance

Protected variable

uint32: 1

 

bHasRequestedToggleFreeze

If a toggle freeze request has been made

Protected variable

uint32: 1

 

bHitProxiesCached

True if the hit proxy buffer buffer has up to date hit proxies for this viewport.

Protected variable

uint32: 1

 

bIsPlayInEditorViewport

If true this viewport is for play in editor

Protected variable

uint32: 1

 

bIsSlateViewport

If true this viewport is an FSlateSceneViewport

Protected variable

uint32: 1

 

bRequiresHitProxyStorage

True if the viewport client requires hit proxy storage.

Protected variable

bool

 

bTakeHighResScreenShot

Triggers the taking of a high res screen shot for this viewport.

Protected variable

TArray< FColor ...

 

CachedHitProxyData

Cached hit proxy data.

Protected variable

FHitProxyMap

 

HitProxyMap

The viewport's hit proxy map.

Protected variable

uint32

 

HitProxySize

The size of the region to check hit proxies

Protected variable

uint32

 

InitialPositionX

The initial position of the viewport.

Protected variable

uint32

 

InitialPositionY

The initial position of the viewport.

Protected variable

uint32

 

SizeX

The width of the viewport.

Protected variable

uint32

 

SizeY

The height of the viewport.

Protected variable

FViewportClient...

 

ViewportClient

The viewport's client.

Protected variable

FViewportRHIRef

 

ViewportRHI

The RHI viewport.

Protected variable

EWindowMode::Ty...

 

WindowMode

What is the current window mode.

Constructors

Name Description

Public function

FViewport

(
    FViewportClient* InViewportCli...
)

Constructor.

Destructors

Name Description

Public function Virtual

~FViewport()

Destructor.

Functions

Name Description

Public function Virtual

void

 

BeginRenderFrame

(
    FRHICommandListImmediate& RHICmdLi...
)

Starts a new rendering frame. Called from the rendering thread.

Public function

FIntRect

 

CalculateViewExtents

(
    float AspectRatio,
    const FIntRect& ViewRect
)

Calculates the view inside the viewport when the aspect ratio is locked.

Public function Virtual

void

 

CaptureMouse

(
    bool bCapture
)

Public function Virtual

void

 

DeferInvalidateHitProxy()

Invalidates the viewport's cached hit proxies at the end of the frame.

Public function

void

 

Destroy()

Public function

void

 

Draw

(
    bool bShouldPresent
)

Updates the viewport's displayed pixels with the results of calling ViewportClient->Draw.

Public function Virtual

int32

 

DrawStatsHUD

(
    FCanvas* InCanvas,
    const int32 InX,
    const int32 InY
)

First chance for viewports to render custom stats text

Public function Virtual

void

 

EndRenderFrame

(
    FRHICommandListImmediate& RHICmdLi...,
    bool bPresent,
    bool bLockToVsync
)

Ends a rendering frame. Called from the rendering thread.

Public function Virtual

void

 

EnqueueBeginRenderFrame

(
    const bool bShouldPresent
)

Starts a new rendering frame.

Public function Virtual

void

 

EnqueueEndRenderFrame

(
    const bool bLockToVsync,
    const bool bShouldPresent
)

Ends a rendering frame. Called from the game thread.

Public function

void

 

GetActorsAndModelsInHitProxy

(
    FIntRect InRect,
    TSet< AActor* >& OutActors,
    TSet< UModel* >& OutModels
)

Returns all actors and models found in the hit proxy within a specified region.

Public function Const

FViewportCli...

 

GetClient()

Accessors.

Public function Virtual

FCanvas *...

 

GetDebugCanvas()

Public function Virtual Const

float

 

GetDesiredAspectRatio()

Public function

HHitProxy &#...

 

GetHitProxy

(
    int32 X,
    int32 Y
)

Returns the dominant hit proxy at a given point.

Public function

void

 

GetHitProxyMap

(
    FIntRect InRect,
    TArray< HHitProxy* >& OutMap
)

Copies the hit proxies from an area of the screen into a buffer.

Public function Const

FIntPoint

 

GetInitialPositionXY()

Public function

void

 

GetMousePos

(
    FIntPoint& MousePosition,
    const bool bLocalPosition
)

Public function Const

int32

 

GetMouseX()

Public function Const

int32

 

GetMouseY()

Public function

const TArray...

 

GetRawHitProxyData

(
    FIntRect InRect
)

Public function Virtual Const

FIntPoint

 

GetRenderTargetTextureSizeXY()

Returns dimensions of RenderTarget texture. Can be called on a game thread.

Public function Virtual

float

 

GetTabletPressure()

Public function

FViewportFra...

 

GetViewportFrame()

Retrieves the interface to the viewport's frame, if it has one.

Public function Const

const FViewp...

 

GetViewportRHI()

Accessors for RHI resources

Public function

void *

 

GetWindow()

Public function Virtual Const

EWindowMode:...

 

GetWindowMode()

Public function Virtual Const

bool

 

HasFocus()

Public function Virtual Const

bool

 

HasMouseCapture()

New MouseCapture/MouseLock API.

Protected function

void

 

HighResScreenshot()

Take a high-resolution screenshot and save to disk.

Public function

void

 

Invalidate()

Invalidates cached hit proxies and the display.

Public function

void

 

InvalidateDisplay()

Invalidates the viewport's displayed pixels.

Public function

void

 

InvalidateHitProxy()

Invalidates cached hit proxies

Public function Virtual Const

bool

 

IsCursorVisible()

Returns true if the mouse cursor is currently visible

Public function Virtual Const

bool

 

IsExclusiveFullscreen()

Public function Virtual Const

bool

 

IsForegroundWindow()

Public function Virtual Const

bool

 

IsFullscreen()

Public function Static

bool

 

IsGameRenderingEnabled()

Returns whether rendering is globally enabled or disabled.

Public function Virtual Const

bool

 

IsKeyboardAvailable

(
    int32 ControllerID
)

Public function Virtual Const

bool

 

IsMouseAvailable

(
    int32 ControllerID
)

Public function Virtual

bool

 

IsPenActive()

Public function Const

bool

 

IsPlayInEditorViewport()

Returns true if the viewport is for play in editor

Public function Const

bool

 

IsSlateViewport()

Returns true if this is an FSlateSceneViewport

Public function Virtual Const

bool

 

IsSoftwareCursorVisible()

Public function Virtual Const

bool

 

IsStereoRenderingAllowed()

Should return true, if stereo rendering is allowed in this viewport

Public function Const

bool

 

KeyState

(
    FKey Key
)

Public function Virtual

void

 

LockMouseToViewport

(
    bool bLock
)

Public function

void

 

MoveWindow

(
    int32 NewPosX,
    int32 NewPosY,
    int32 NewSizeX,
    int32 NewSizeY
)

Public function

void

 

ProcessInput

(
    float DeltaTime
)

Public function Static

void

 

SetGameRenderingEnabled

(
    bool bIsEnabled,
    int32 PresentAndStopMovieDelay
)

Globally enables/disables rendering

Public function

void

 

SetInitialSize

(
    FIntPoint InitialSizeXY
)

Sets the initial size of this viewport. Will do nothing if the viewport has already been sized

Public function

void

 

SetMouse

(
    int32 x,
    int32 y
)

Public function

void

 

SetPlayInEditorViewport

(
    bool bInPlayInEditorViewport
)

Sets this viewport as a play in editor viewport

Public function Virtual

void

 

SetPreCaptureMousePosFromSlateCursor()

Sets PreCapture coordinates from the current position of the slate cursor.

Public function Virtual

void

 

SetRequiresVsync

(
    bool bShouldVsync
)

Indicate that the viewport should be block for vsync.

Public function Virtual

void

 

SetSoftwareCursorPosition

(
    FVector2D Position
)

Public function

bool

 

SetUserFocus

(
    bool bFocus
)

Public function Virtual

void

 

SetViewportClient

(
    FViewportClient* InViewportCli...
)

Sets a viewport client if one wasn't provided at construction time.

Public function Virtual

void

 

ShowCursor

(
    bool bVisible
)

Public function Virtual

void

 

ShowSoftwareCursor

(
    bool bVisible
)

Public function

bool

 

TakeHighResScreenShot()

Trigger a high res screenshot.

Public function Virtual

bool

 

UpdateMouseCursor

(
    bool bSetCursor
)

Public function

void

 

UpdateRenderTargetSurfaceRHIToCurrentBackBuffer()

Update the render target surface RHI to the current back buffer

Protected function Virtual

void

 

UpdateViewportRHI

(
    bool bDestroyed,
    uint32 NewSizeX,
    uint32 NewSizeY,
    EWindowMode::Type NewWindowMode,
    EPixelFormat PreferredPixelFormat
)

Updates the viewport RHI with the current viewport state.

Public function Const

FIntPoint

 

ViewportToVirtualDesktopPixel

(
    FVector2D ViewportCoordinate
)

Transforms a coordinate in the local space of this viewport into a virtual desktop pixel.

Public function Const

FVector2D

 

VirtualDesktopPixelToViewport

(
    FIntPoint VirtualDesktopPointPx
)

Transforms a virtual desktop pixel (the origin is in the primary screen's top left corner) to the local space of this viewport

Overridden from FRenderTarget

Name Description

Public function Virtual Const

FRHIGPUMask

 

GetGPUMask

(
    FRHICommandListImmediate& RHICmdLi...
)

Returns the GPU nodes on which to render this viewport.

Public function Virtual Const

FIntPoint

 

GetSizeXY()

Properties.

Public function Virtual

bool

 

HasToggleFreezeCommand()

Returns if there is a command to freeze

Returns if there is a command to toggle freezing

Public function Virtual

void

 

ProcessToggleFreezeCommand()

Handles freezing/unfreezing of rendering

Overridden from FRenderResource

Name Description

Protected function Virtual

void

 

InitDynamicRHI()

Initializes the dynamic RHI resource and/or RHI render target used by this resource.

Protected function Virtual

void

 

InitRHI()

Initializes the RHI resources used by this resource.

Protected function Virtual

void

 

ReleaseDynamicRHI()

Releases the dynamic RHI resource and/or RHI render target resources used by this resource.

Protected function Virtual

void

 

ReleaseRHI()

Releases the RHI resources used by this resource.

Classes

Name

Description

Protected class

FHitProxyMap

A map from 2D coordinates to cached hit proxies.

Typedefs

Name

Description

FOnViewportResized

Delegate type for viewport resize events ( Params: FViewport* Viewport, uint32 )

Constants

Name

Description

bIsGameRenderingEnabled

True if we should draw game viewports (has no effect on Editor viewports)

PresentAndStopMovieDelay

Delay in frames to disable present (but still render scene) and stopping of a movie.

ViewportResizedEvent

Send when a viewport is resized

References

Module

Engine

Header

Runtime/Engine/Public/UnrealClient.h

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback