![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <CanvasTypes.h>
Classes | |
| class | FCanvasSortElement |
| class | FTransformEntry |
Public Types | |
| enum | EElementType { ET_Line , ET_Triangle , ET_MAX } |
| enum | ECanvasAllowModes { Allow_Flush = 1 << 0 , Allow_DeleteOnRender = 1 << 1 } |
| enum | ECanvasDrawMode { CDM_DeferDrawing , CDM_ImmediateDrawing } |
Static Public Member Functions | |
| static ENGINE_API FCanvas * | Create (FRDGBuilder &GraphBuilder, FRDGTextureRef InRenderTarget, FHitProxyConsumer *InHitProxyConsumer, const FGameTime &Time, ERHIFeatureLevel::Type InFeatureLevel, float InDPIScale=1.0f) |
| static ENGINE_API ESimpleElementBlendMode | BlendToSimpleElementBlend (EBlendMode BlendMode) |
| static ENGINE_API FMatrix | CalcBaseTransform2D (uint32 ViewSizeX, uint32 ViewSizeY) |
| static ENGINE_API FMatrix | CalcBaseTransform3D (uint32 ViewSizeX, uint32 ViewSizeY, float fFOV, float NearPlane) |
| static ENGINE_API FMatrix | CalcViewMatrix (uint32 ViewSizeX, uint32 ViewSizeY, float fFOV) |
| static ENGINE_API FMatrix | CalcProjectionMatrix (uint32 ViewSizeX, uint32 ViewSizeY, float fFOV, float NearPlane) |
Public Attributes | |
| float | AlphaModulate |
| TSharedPtr< FCanvasWordWrapper > | WordWrapper |
| TArray< FCanvasSortElement > | SortedElements |
| TMap< int32, int32 > | SortedElementLookupMap |
| int32 | LastElementIndex |
Friends | |
| class | FCanvasRenderContext |
| class | FCanvasRenderThreadScope |
Encapsulates the canvas state.
| FCanvas::FCanvas | ( | FRenderTarget * | InRenderTarget, |
| FHitProxyConsumer * | InHitProxyConsumer, | ||
| UWorld * | InWorld, | ||
| ERHIFeatureLevel::Type | InFeatureLevel, | ||
| ECanvasDrawMode | DrawMode = CDM_DeferDrawing, |
||
| float | InDPIScale = 1.0f |
||
| ) |
Constructor.
| FCanvas::FCanvas | ( | FRenderTarget * | InRenderTarget, |
| FHitProxyConsumer * | InHitProxyConsumer, | ||
| const FGameTime & | Time, | ||
| ERHIFeatureLevel::Type | InFeatureLevel, | ||
| float | InDPIScale = 1.0f |
||
| ) |
Constructor. For situations where a world is not available, but time information is
| FCanvas::~FCanvas | ( | ) |
Destructor.
| void FCanvas::AddTileRenderItem | ( | float | X, |
| float | Y, | ||
| float | SizeX, | ||
| float | SizeY, | ||
| float | U, | ||
| float | V, | ||
| float | SizeU, | ||
| float | SizeV, | ||
| const FMaterialRenderProxy * | MaterialRenderProxy, | ||
| FHitProxyId | HitProxyId, | ||
| bool | bFreezeTime, | ||
| FColor | InColor | ||
| ) |
Generates a new FCanvasTileRendererItem for the current sortkey and adds it to the sortelement list of items to render
| void FCanvas::AddTriangleRenderItem | ( | const FCanvasUVTri & | Tri, |
| const FMaterialRenderProxy * | MaterialRenderProxy, | ||
| FHitProxyId | HitProxyId, | ||
| bool | bFreezeTime | ||
| ) |
Generates a new FCanvasTriangleRendererItem for the current sortkey and adds it to the sortelement list of items to render
|
static |
Translate EBlendMode into ESimpleElementBlendMode used by tiles
| BlendMode | Normal Unreal blend mode enum |
Generate a 2D projection for the canvas. Use this if you only want to transform in 2D on the XY plane
| ViewSizeX | - Viewport width |
| ViewSizeY | - Viewport height |
|
static |
Generate a 3D projection for the canvas. Use this if you want to transform in 3D
| ViewSizeX | - Viewport width |
| ViewSizeY | - Viewport height |
| fFOV | - Field of view for the projection |
| NearPlane | - Distance to the near clip plane |
|
static |
Generate a projection matrix for the canvas. Used for CalcBaseTransform3D
| ViewSizeX | - Viewport width |
| ViewSizeY | - Viewport height |
| fFOV | - Field of view for the projection |
| NearPlane | - Distance to the near clip plane |
Generate a view matrix for the canvas. Used for CalcBaseTransform3D
| ViewSizeX | - Viewport width |
| ViewSizeY | - Viewport height |
| fFOV | - Field of view for the projection |
| void FCanvas::Clear | ( | const FLinearColor & | Color | ) |
Clear the canvas
| Color | Color to clear with. |
| void FCanvas::ClearBatchesToRender | ( | ) |
Clear the list of dirty batches that need to be rendered by the canvas
Copy the conents of the TransformStack from an existing canvas
| Copy | canvas to copy from |
|
static |
| void FCanvas::DrawItem | ( | FCanvasItem & | Item | ) |
Draw a CanvasItem
| Item | Item to draw |
| void FCanvas::DrawItem | ( | FCanvasItem & | Item, |
| const FVector2D & | InPosition | ||
| ) |
Draw a CanvasItem at the given coordinates
| Item | Item to draw |
| InPosition | Position to draw item |
| void FCanvas::DrawItem | ( | FCanvasItem & | Item, |
| float | X, | ||
| float | Y | ||
| ) |
Draw a CanvasItem at the given coordinates
| Item | Item to draw |
| X | X Position to draw item |
| Y | Y Position to draw item |
| void FCanvas::DrawNGon | ( | const FVector2D & | Center, |
| const FColor & | Color, | ||
| int32 | NumSides, | ||
| float | Radius | ||
| ) |
| int32 FCanvas::DrawShadowedString | ( | double | StartX, |
| double | StartY, | ||
| FStringView | Text, | ||
| const UFont * | Font, | ||
| const FLinearColor & | Color, | ||
| const FLinearColor & | ShadowColor = FLinearColor::Black |
||
| ) |
Draw an string centered on given location. This function is being deprecated. a FCanvasTextItem should be used instead.
| StartX | - X point |
| StartY | - Y point |
| Text | - Text to draw |
| Font | - Font to use |
| Color | - Color of the text |
| ShadowColor | - Shadow color to draw underneath the text (ignored for distance field fonts) |
| int32 FCanvas::DrawShadowedText | ( | double | StartX, |
| double | StartY, | ||
| const FText & | Text, | ||
| const UFont * | Font, | ||
| const FLinearColor & | Color, | ||
| const FLinearColor & | ShadowColor = FLinearColor::Black |
||
| ) |
| void FCanvas::DrawTile | ( | double | X, |
| double | Y, | ||
| double | SizeX, | ||
| double | SizeY, | ||
| float | U, | ||
| float | V, | ||
| float | SizeU, | ||
| float | SizeV, | ||
| const FLinearColor & | Color, | ||
| const FTexture * | Texture, | ||
| ESimpleElementBlendMode | BlendMode | ||
| ) |
| void FCanvas::DrawTile | ( | double | X, |
| double | Y, | ||
| double | SizeX, | ||
| double | SizeY, | ||
| float | U, | ||
| float | V, | ||
| float | SizeU, | ||
| float | SizeV, | ||
| const FLinearColor & | Color, | ||
| const FTexture * | Texture = NULL, |
||
| bool | AlphaBlend = true |
||
| ) |
Draw arbitrary aligned rectangle.
| X | - X position to draw tile at |
| Y | - Y position to draw tile at |
| SizeX | - Width of tile |
| SizeY | - Height of tile |
| U | - Horizontal position of the upper left corner of the portion of the texture to be shown(texels) |
| V | - Vertical position of the upper left corner of the portion of the texture to be shown(texels) |
| SizeU | - The width of the portion of the texture to be drawn. This value is in texels. |
| SizeV | - The height of the portion of the texture to be drawn. This value is in texels. |
| Color | - tint applied to tile |
| Texture | - Texture to draw |
| AlphaBlend | - true to alphablend |
Sends a message to the rendering thread to draw the batched elements.
| bForce | - force the flush even if Allow_Flush is not enabled |
| void FCanvas::Flush_RenderThread | ( | FRDGBuilder & | GraphBuilder, |
| bool | bForce = false |
||
| ) |
| void FCanvas::Flush_RenderThread | ( | FRHICommandListImmediate & | RHICmdList, |
| bool | bForce = false |
||
| ) |
Sends a message to the rendering thread to draw the batched elements.
| RHICmdList | - command list to use |
| bForce | - force the flush even if Allow_Flush is not enabled |
| bInsideRenderPass | - Set to true if flushing inside a render pass (e.g. Render Graph pass). This will skip creating a render pass internally, and assert if the command list is not in a render pass. |
|
inline |
Accessor for allowed canvas modes
| FBatchedElements * FCanvas::GetBatchedElements | ( | EElementType | InElementType, |
| FBatchedElementParameters * | InBatchedElementParameters = NULL, |
||
| const FTexture * | Texture = NULL, |
||
| ESimpleElementBlendMode | BlendMode = SE_BLEND_MAX, |
||
| const FDepthFieldGlowInfo & | GlowInfo = FDepthFieldGlowInfo(), |
||
| bool | bApplyDPIScale = true |
||
| ) |
Returns a FBatchedElements pointer to be used for adding vertices and primitives for rendering. Adds a new render item to the sort element entry based on the current sort key.
| InElementType | - Type of element we are going to draw. |
| InBatchedElementParameters | - Parameters for this element |
| InTexture | - New texture that will be set. |
| InBlendMode | - New blendmode that will be set. |
| GlowInfo | - info for optional glow effect when using depth field rendering |
|
inline |
Get the bottom-most element of the transform stack.
|
inline |
|
inline |
Access current feature level
|
inline |
Get the current top-most transform entry
|
inline |
|
inline |
|
inline |
|
inline |
Get the current render target for the canvas
|
inline |
| EShaderPlatform FCanvas::GetShaderPlatform | ( | ) | const |
Access current shader platform
| FCanvas::FCanvasSortElement & FCanvas::GetSortElement | ( | int32 | DepthSortKey | ) |
Get the sort element for the given sort key. Allocates a new entry if one does not exist
| DepthSortKey | - the key used to find the sort element entry |
|
inline |
Access gameplay time
|
inline |
Get the current top-most transform entry without the canvas projection
|
inline |
returns the transform stack
|
inline |
| bool FCanvas::HasBatchesToRender | ( | ) | const |
Determine if the canvas has dirty batches that need to be rendered
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Pop sort key off of the stack.
| void FCanvas::PopTransform | ( | ) |
Removes the top transform from the canvas's transform stack.
Pushes a transform onto the canvas's transform stack.
| Transform | - The transform to push onto the stack. |
Push sort key onto the stack. Rendering is done with the current sort key stack entry.
| InSortKey | - key value to push onto the stack |
Pushes a transform onto the canvas's transform stack, multiplying it with the current top of the stack.
| Transform | - The transform to push onto the stack. |
Toggle allowed canvas modes
| InAllowedModes | New modes to set |
Replace the base (ie. TransformStack(0)) transform for the canvas with the given matrix
| Transform | - The transform to use for the base |
Sets the hit proxy which will be used for subsequent canvas primitives.
| void FCanvas::SetRenderTarget_GameThread | ( | FRenderTarget * | NewRenderTarget | ) |
Sets the render target which will be used for subsequent canvas primitives.
Marks render target as dirty so that it will be resolved to texture
Sets a rect that should be used to offset rendering into the viewport render target If not set the canvas will render to the full target
| ViewRect | The rect to use |
The clipping rectangle used when rendering this canvas
| ScissorRect | The rect to use |
|
inline |
Return top sort key of the stack.
| void FCanvas::WrapString | ( | FTextSizingParameters & | Parameters, |
| const float | InCurX, | ||
| FStringView | Text, | ||
| TArray< FWrappedStringElement > & | out_Lines, | ||
| FCanvasWordWrapper::FWrappedLineData *const | OutWrappedLineData = nullptr |
||
| ) |
|
friend |
|
friend |
| float FCanvas::AlphaModulate |
Map from sortkey to array index of SortedElements for faster lookup of existing entries
| TArray<FCanvasSortElement> FCanvas::SortedElements |
Batched canvas elements to be sorted for rendering. Sort order is back-to-front
| TSharedPtr<FCanvasWordWrapper> FCanvas::WordWrapper |
Private class for handling word wrapping behavior.