Class Render2D
Rendering 2D shapes and text using Graphics Device.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Render2D/Render2D.h
Syntax
public class Render2D
Fields
Features
The active rendering features flags.
Declaration
public static RenderingFeatures Features
Field Value
RenderingFeatures
|
Methods
Begin(GPUContext* context, GPUTexture* output, GPUTexture* depthBuffer, const Matrix& viewProjection)
Begins the rendering phrase.
Declaration
public static void Begin(GPUContext* context, GPUTexture* output, GPUTexture* depthBuffer, const Matrix& viewProjection)
Parameters
GPUContext
context
The GPU commands context to use. |
GPUTexture
output
The output target. |
GPUTexture
depthBuffer
The depth buffer. |
Matrix
viewProjection
The View*Projection matrix. Allows to render GUI in 3D or with custom transformations. |
Begin(GPUContext* context, GPUTexture* output, GPUTexture* depthBuffer=nullptr)
Begins the rendering phrase.
Declaration
public static void Begin(GPUContext* context, GPUTexture* output, GPUTexture* depthBuffer=nullptr)
Parameters
GPUContext
context
The GPU commands context to use. |
GPUTexture
output
The output target. |
GPUTexture
depthBuffer
The depth buffer. |
Begin(GPUContext* context, GPUTextureView* output, GPUTextureView* depthBuffer, const Viewport& viewport)
Begins the rendering phrase.
Declaration
public static void Begin(GPUContext* context, GPUTextureView* output, GPUTextureView* depthBuffer, const Viewport& viewport)
Parameters
GPUContext
context
The GPU commands context to use. |
GPUTextureView
output
The output target. |
GPUTextureView
depthBuffer
The depth buffer. |
Viewport
viewport
The output viewport. |
Begin(GPUContext* context, GPUTextureView* output, GPUTextureView* depthBuffer, const Viewport& viewport, const Matrix& viewProjection)
Begins the rendering phrase.
Declaration
public static void Begin(GPUContext* context, GPUTextureView* output, GPUTextureView* depthBuffer, const Viewport& viewport, const Matrix& viewProjection)
Parameters
GPUContext
context
The GPU commands context to use. |
GPUTextureView
output
The output target. |
GPUTextureView
depthBuffer
The depth buffer. |
Viewport
viewport
The output viewport. |
Matrix
viewProjection
The View*Projection matrix. Allows to render GUI in 3D or with custom transformations. |
BeginFrame()
Called when frame rendering begins by the graphics device.
Declaration
public static void BeginFrame()
Draw9SlicingSprite(const SpriteHandle& spriteHandle, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Draws a sprite using 9-slicing.
Declaration
public static void Draw9SlicingSprite(const SpriteHandle& spriteHandle, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
Float4
border
The borders for 9-slicing (inside rectangle, ordered: left, right, top, bottom). |
Float4
borderUVs
The borders UVs for 9-slicing (inside rectangle UVs, ordered: left, right, top, bottom). |
Color
color
The color to multiply all texture pixels. |
Draw9SlicingSpritePoint(const SpriteHandle& spriteHandle, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Draws a sprite using 9-slicing (uses point sampler).
Declaration
public static void Draw9SlicingSpritePoint(const SpriteHandle& spriteHandle, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
Float4
border
The borders for 9-slicing (inside rectangle, ordered: left, right, top, bottom). |
Float4
borderUVs
The borders UVs for 9-slicing (inside rectangle UVs, ordered: left, right, top, bottom). |
Color
color
The color to multiply all texture pixels. |
Draw9SlicingTexture(TextureBase* t, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Draws the texture using 9-slicing.
Declaration
public static void Draw9SlicingTexture(TextureBase* t, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Parameters
TextureBase
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Float4
border
The borders for 9-slicing (inside rectangle, ordered: left, right, top, bottom). |
Float4
borderUVs
The borders UVs for 9-slicing (inside rectangle UVs, ordered: left, right, top, bottom). |
Color
color
The color to multiply all texture pixels. |
Draw9SlicingTexturePoint(TextureBase* t, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Draws the texture using 9-slicing (uses point sampler).
Declaration
public static void Draw9SlicingTexturePoint(TextureBase* t, const Rectangle& rect, const Float4& border, const Float4& borderUVs, const Color& color=Color::White)
Parameters
TextureBase
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Float4
border
The borders for 9-slicing (inside rectangle, ordered: left, right, top, bottom). |
Float4
borderUVs
The borders UVs for 9-slicing (inside rectangle UVs, ordered: left, right, top, bottom). |
Color
color
The color to multiply all texture pixels. |
DrawBezier(const Float2& p1, const Float2& p2, const Float2& p3, const Float2& p4, const Color& color, float thickness=1.0f)
Draws a Bezier curve.
Declaration
public static void DrawBezier(const Float2& p1, const Float2& p2, const Float2& p3, const Float2& p4, const Color& color, float thickness=1.0f)
Parameters
Float2
p1
The start point. |
Float2
p2
The first control point. |
Float2
p3
The second control point. |
Float2
p4
The end point. |
Color
color
The line color |
float
thickness
The line thickness. |
DrawBlur(const Rectangle& rect, float blurStrength)
Draws the background blur.
Declaration
public static void DrawBlur(const Rectangle& rect, float blurStrength)
Parameters
Rectangle
rect
The target rectangle to draw (blurs its background). |
float
blurStrength
The blur strength defines how blurry the background is. Larger numbers increase blur, resulting in a larger runtime cost on the GPU. |
DrawCustom(GPUTexture* t, const Rectangle& rect, GPUPipelineState* ps, const Color& color=Color::White)
Performs custom rendering.
Declaration
public static void DrawCustom(GPUTexture* t, const Rectangle& rect, GPUPipelineState* ps, const Color& color=Color::White)
Parameters
GPUTexture
t
The texture to use. |
Rectangle
rect
The rectangle area to draw. |
GPUPipelineState
ps
The custom pipeline state to use (input must match default Render2D vertex shader and can use single texture). |
Color
color
The color to multiply all texture pixels. |
DrawLine(const Float2& p1, const Float2& p2, const Color& color, float thickness=1.0f)
Draws a line.
Declaration
public static void DrawLine(const Float2& p1, const Float2& p2, const Color& color, float thickness=1.0f)
Parameters
Float2
p1
The start point. |
Float2
p2
The end point. |
Color
color
The line color. |
float
thickness
The line thickness. |
Returns
void
|
DrawLine(const Float2& p1, const Float2& p2, const Color& color1, const Color& color2, float thickness=1.0f)
Draws a line.
Declaration
public static void DrawLine(const Float2& p1, const Float2& p2, const Color& color1, const Color& color2, float thickness=1.0f)
Parameters
Float2
p1
The start point. |
Float2
p2
The end point. |
Color
color1
The line start color. |
Color
color2
The line end color. |
float
thickness
The line thickness. |
DrawMaterial(MaterialBase* material, const Rectangle& rect, const Color& color)
Draws the GUI material.
Declaration
public static void DrawMaterial(MaterialBase* material, const Rectangle& rect, const Color& color)
Parameters
MaterialBase
material
The material to render. Must be a GUI material type. |
Rectangle
rect
The target rectangle to draw. |
Color
color
The color to use. |
DrawRectangle(const Rectangle& rect, const Color& color, float thickness=1.0f)
Draws a rectangle borders.
Declaration
public static void DrawRectangle(const Rectangle& rect, const Color& color, float thickness=1.0f)
Parameters
Rectangle
rect
The rectangle to draw. |
Color
color
The color to use. |
float
thickness
The line thickness. |
Returns
void
|
DrawRectangle(const Rectangle& rect, const Color& color1, const Color& color2, const Color& color3, const Color& color4, float thickness=1.0f)
Draws a rectangle borders.
Declaration
public static void DrawRectangle(const Rectangle& rect, const Color& color1, const Color& color2, const Color& color3, const Color& color4, float thickness=1.0f)
Parameters
Rectangle
rect
The rectangle to fill. |
Color
color1
The color to use for upper left vertex. |
Color
color2
The color to use for upper right vertex. |
Color
color3
The color to use for bottom right vertex. |
Color
color4
The color to use for bottom left vertex. |
float
thickness
The line thickness. |
DrawSpline(const Float2& p1, const Float2& p2, const Float2& p3, const Float2& p4, const Color& color, float thickness=1.0f)
Draws a spline curve (Bezier but X axis represents uniform time).
Declaration
public static void DrawSpline(const Float2& p1, const Float2& p2, const Float2& p3, const Float2& p4, const Color& color, float thickness=1.0f)
Parameters
Float2
p1
The start point. |
Float2
p2
The first control point. |
Float2
p3
The second control point. |
Float2
p4
The end point. |
Color
color
The line color |
float
thickness
The line thickness. |
DrawSprite(const SpriteHandle& spriteHandle, const Rectangle& rect, const Color& color=Color::White)
Draws a sprite.
Declaration
public static void DrawSprite(const SpriteHandle& spriteHandle, const Rectangle& rect, const Color& color=Color::White)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawSpritePoint(const SpriteHandle& spriteHandle, const Rectangle& rect, const Color& color=Color::White)
Draws a sprite (uses point sampler).
Declaration
public static void DrawSpritePoint(const SpriteHandle& spriteHandle, const Rectangle& rect, const Color& color=Color::White)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawText(Font* font, const StringView& text, const Color& color, const Float2& location, MaterialBase* customMaterial=nullptr)
Draws a text.
Declaration
public static void DrawText(Font* font, const StringView& text, const Color& color, const Float2& location, MaterialBase* customMaterial=nullptr)
Parameters
Font
font
The font to use. |
StringView
text
The text to render. |
Color
color
The text color. |
Float2
location
The text location. |
MaterialBase
customMaterial
The custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture. |
DrawText(Font* font, const StringView& text, const Color& color, const TextLayoutOptions& layout, MaterialBase* customMaterial=nullptr)
Draws a text with formatting.
Declaration
public static void DrawText(Font* font, const StringView& text, const Color& color, const TextLayoutOptions& layout, MaterialBase* customMaterial=nullptr)
Parameters
Font
font
The font to use. |
StringView
text
The text to render. |
Color
color
The text color. |
TextLayoutOptions
layout
The text layout properties. |
MaterialBase
customMaterial
The custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture. |
DrawText(Font* font, const StringView& text, const TextRange& textRange, const Color& color, const Float2& location, MaterialBase* customMaterial=nullptr)
Draws a text.
Declaration
public static void DrawText(Font* font, const StringView& text, const TextRange& textRange, const Color& color, const Float2& location, MaterialBase* customMaterial=nullptr)
Parameters
Font
font
The font to use. |
StringView
text
The text to render. |
TextRange
textRange
The input text range (substring range of the input text parameter). |
Color
color
The text color. |
Float2
location
The text location. |
MaterialBase
customMaterial
The custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture. |
DrawText(Font* font, const StringView& text, const TextRange& textRange, const Color& color, const TextLayoutOptions& layout, MaterialBase* customMaterial=nullptr)
Draws a text with formatting.
Declaration
public static void DrawText(Font* font, const StringView& text, const TextRange& textRange, const Color& color, const TextLayoutOptions& layout, MaterialBase* customMaterial=nullptr)
Parameters
Font
font
The font to use. |
StringView
text
The text to render. |
TextRange
textRange
The input text range (substring range of the input text parameter). |
Color
color
The text color. |
TextLayoutOptions
layout
The text layout properties. |
MaterialBase
customMaterial
The custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture. |
DrawTexture(GPUTexture* t, const Rectangle& rect, const Color& color=Color::White)
Draws the texture.
Declaration
public static void DrawTexture(GPUTexture* t, const Rectangle& rect, const Color& color=Color::White)
Parameters
GPUTexture
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawTexture(GPUTextureView* rt, const Rectangle& rect, const Color& color=Color::White)
Draws the render target.
Declaration
public static void DrawTexture(GPUTextureView* rt, const Rectangle& rect, const Color& color=Color::White)
Parameters
GPUTextureView
rt
The render target handle to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawTexture(TextureBase* t, const Rectangle& rect, const Color& color=Color::White)
Draws the texture.
Declaration
public static void DrawTexture(TextureBase* t, const Rectangle& rect, const Color& color=Color::White)
Parameters
TextureBase
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawTexturedTriangles(GPUTexture* t, const Span<Float2>& vertices, const Span<Float2>& uvs)
Draws vertices array.
Declaration
public static void DrawTexturedTriangles(GPUTexture* t, const Span<Float2>& vertices, const Span<Float2>& uvs)
Parameters
GPUTexture
t
The texture. |
Span<Float2>
vertices
The vertices array. |
Span<Float2>
uvs
The uvs array. |
DrawTexturedTriangles(GPUTexture* t, const Span<Float2>& vertices, const Span<Float2>& uvs, const Color& color)
Draws vertices array.
Declaration
public static void DrawTexturedTriangles(GPUTexture* t, const Span<Float2>& vertices, const Span<Float2>& uvs, const Color& color)
Parameters
GPUTexture
t
The texture. |
Span<Float2>
vertices
The vertices array. |
Span<Float2>
uvs
The uvs array. |
Color
color
The color. |
DrawTexturedTriangles(GPUTexture* t, const Span<Float2>& vertices, const Span<Float2>& uvs, const Span<Color>& colors)
Draws vertices array.
Declaration
public static void DrawTexturedTriangles(GPUTexture* t, const Span<Float2>& vertices, const Span<Float2>& uvs, const Span<Color>& colors)
Parameters
GPUTexture
t
The texture. |
Span<Float2>
vertices
The vertices array. |
Span<Float2>
uvs
The uvs array. |
Span<Color>
colors
The colors array. |
DrawTexturedTriangles(GPUTexture* t, const Span<uint16>& indices, const Span<Float2>& vertices, const Span<Float2>& uvs, const Span<Color>& colors)
Draws indexed vertices array.
Declaration
public static void DrawTexturedTriangles(GPUTexture* t, const Span<uint16>& indices, const Span<Float2>& vertices, const Span<Float2>& uvs, const Span<Color>& colors)
Parameters
GPUTexture
t
The texture. |
Span<uint16>
indices
The indices array. |
Span<Float2>
vertices
The vertices array. |
Span<Float2>
uvs
The uvs array. |
Span<Color>
colors
The colors array. |
DrawTexturePoint(GPUTexture* t, const Rectangle& rect, const Color& color=Color::White)
Draws the texture (uses point sampler).
Declaration
public static void DrawTexturePoint(GPUTexture* t, const Rectangle& rect, const Color& color=Color::White)
Parameters
GPUTexture
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawTriangles(const Span<Float2>& vertices, const Color& color, float thickness=1.0f)
Draws vertices array.
Declaration
public static void DrawTriangles(const Span<Float2>& vertices, const Color& color, float thickness=1.0f)
Parameters
Span<Float2>
vertices
The vertices array. |
Color
color
The color. |
float
thickness
The line thickness. |
DrawTriangles(const Span<Float2>& vertices, const Span<Color>& colors, float thickness=1.0f)
Draws vertices array.
Declaration
public static void DrawTriangles(const Span<Float2>& vertices, const Span<Color>& colors, float thickness=1.0f)
Parameters
Span<Float2>
vertices
The vertices array. |
Span<Color>
colors
The colors array. |
float
thickness
The line thickness. |
End()
Ends the rendering phrase.
Declaration
public static void End()
EndFrame()
Called when frame rendering ends by the graphics device.
Declaration
public static void EndFrame()
FillRectangle(const Rectangle& rect, const Color& color)
Fills a rectangle area.
Declaration
public static void FillRectangle(const Rectangle& rect, const Color& color)
Parameters
Rectangle
rect
The rectangle to fill. |
Color
color
The color to use. |
FillRectangle(const Rectangle& rect, const Color& color1, const Color& color2, const Color& color3, const Color& color4)
Fills a rectangle area.
Declaration
public static void FillRectangle(const Rectangle& rect, const Color& color1, const Color& color2, const Color& color3, const Color& color4)
Parameters
Rectangle
rect
The rectangle to fill. |
Color
color1
The color to use for upper left vertex. |
Color
color2
The color to use for upper right vertex. |
Color
color3
The color to use for bottom right vertex. |
Color
color4
The color to use for bottom left vertex. |
FillTriangle(const Float2& p0, const Float2& p1, const Float2& p2, const Color& color)
Fills a triangular area.
Declaration
public static void FillTriangle(const Float2& p0, const Float2& p1, const Float2& p2, const Color& color)
Parameters
Float2
p0
The first point. |
Float2
p1
The second point. |
Float2
p2
The third point. |
Color
color
The color. |
FillTriangles(const Span<Float2>& vertices, const Color& color)
Draws vertices array.
Declaration
public static void FillTriangles(const Span<Float2>& vertices, const Color& color)
Parameters
Span<Float2>
vertices
The vertices array. |
Color
color
The color. |
FillTriangles(const Span<Float2>& vertices, const Span<Color>& colors, bool useAlpha=true)
Draws vertices array.
Declaration
public static void FillTriangles(const Span<Float2>& vertices, const Span<Color>& colors, bool useAlpha=true)
Parameters
Span<Float2>
vertices
The vertices array. |
Span<Color>
colors
The colors array. |
bool
useAlpha
If true alpha blending will be enabled. |
GetViewport()
Gets the current rendering viewport.
Declaration
public static Viewport GetViewport()
Returns
Viewport
|
IsRendering()
Checks if interface is during rendering phrase (Draw calls may be performed without failing).
Declaration
public static bool IsRendering()
Returns
bool
|
PeekClip(Rectangle& clipRect)
Peeks the current clipping rectangle mask.
Declaration
public static void PeekClip(Rectangle& clipRect)
Parameters
Rectangle
clipRect
The output axis aligned clipping mask rectangle combined from all the masks together (pushed into the masking stack). |
PeekTint(Color& tint)
Peeks the current tint color.
Declaration
public static void PeekTint(Color& tint)
Parameters
Color
tint
The output tint color. |
PeekTransform(Matrix3x3& transform)
Peeks the current transformation layer.
Declaration
public static void PeekTransform(Matrix3x3& transform)
Parameters
Matrix3x3
transform
The output transformation to apply combined from all the transformations together (pushed into the transformation stack). |
PopClip()
Pops clipping rectangle mask.
Declaration
public static void PopClip()
PopTint()
Pops tint color.
Declaration
public static void PopTint()
PopTransform()
Pops transformation layer.
Declaration
public static void PopTransform()
PushClip(const Rectangle& clipRect)
Pushes clipping rectangle mask.
Declaration
public static void PushClip(const Rectangle& clipRect)
Parameters
Rectangle
clipRect
The axis aligned clipping mask rectangle. |
PushTint(const Color& tint, bool inherit=true)
Pushes tint color.
Declaration
public static void PushTint(const Color& tint, bool inherit=true)
Parameters
Color
tint
The tint color. |
bool
inherit
Multiply by the last tint on the stack. |
PushTransform(const Matrix3x3& transform)
Pushes transformation layer.
Declaration
public static void PushTransform(const Matrix3x3& transform)
Parameters
Matrix3x3
transform
The transformation to apply. |