Class Render2D
Rendering 2D shapes and text using Graphics Device.
Inheritance
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public static class Render2D : Object
Properties
Features
The active rendering features flags.
Declaration
[Unmanaged]
public static Render2D.RenderingFeatures Features { get; set; }
Property Value
Render2D.RenderingFeatures
|
Methods
Begin(GPUContext, GPUTexture, GPUTexture)
Begins the rendering phrase.
Declaration
[Unmanaged]
public static void Begin(GPUContext context, GPUTexture output, GPUTexture depthBuffer = null)
Parameters
GPUContext
context
The GPU commands context to use. |
GPUTexture
output
The output target. |
GPUTexture
depthBuffer
The depth buffer. |
Begin(GPUContext, GPUTexture, GPUTexture, ref Matrix)
Begins the rendering phrase.
Declaration
[Unmanaged]
public static void Begin(GPUContext context, GPUTexture output, GPUTexture depthBuffer, ref 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, GPUTextureView, GPUTextureView, ref Viewport)
Begins the rendering phrase.
Declaration
[Unmanaged]
public static void Begin(GPUContext context, GPUTextureView output, GPUTextureView depthBuffer, ref 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, GPUTextureView, GPUTextureView, ref Viewport, ref Matrix)
Begins the rendering phrase.
Declaration
[Unmanaged]
public static void Begin(GPUContext context, GPUTextureView output, GPUTextureView depthBuffer, ref Viewport viewport, ref 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. |
CallDrawing(IDrawable, GPUContext, GPUTexture)
Calls drawing GUI to the texture.
Declaration
public static void CallDrawing(IDrawable drawableElement, GPUContext context, GPUTexture output)
Parameters
IDrawable
drawableElement
The root container for Draw methods. |
GPUContext
context
The GPU context to handle graphics commands. |
GPUTexture
output
The output render target. |
CallDrawing(IDrawable, GPUContext, GPUTexture, GPUTexture, ref Matrix)
Calls drawing GUI to the texture using custom View*Projection matrix. If depth buffer texture is provided there will be depth test performed during rendering.
Declaration
public static void CallDrawing(IDrawable drawableElement, GPUContext context, GPUTexture output, GPUTexture depthBuffer, ref Matrix viewProjection)
Parameters
IDrawable
drawableElement
The root container for Draw methods. |
GPUContext
context
The GPU context to handle graphics commands. |
GPUTexture
output
The output render target. |
GPUTexture
depthBuffer
The depth buffer render target. It's optional parameter but if provided must match output texture. |
Matrix
viewProjection
The View*Projection matrix used to transform all rendered vertices. |
Draw9SlicingSprite(SpriteHandle, Rectangle, Float4, Float4, Color)
Draws a sprite using 9-slicing.
Declaration
[Unmanaged]
public static void Draw9SlicingSprite(SpriteHandle spriteHandle, Rectangle rect, Float4 border, Float4 borderUVs, Color color)
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(SpriteHandle, Rectangle, Float4, Float4, Color)
Draws a sprite using 9-slicing (uses point sampler).
Declaration
[Unmanaged]
public static void Draw9SlicingSpritePoint(SpriteHandle spriteHandle, Rectangle rect, Float4 border, Float4 borderUVs, Color color)
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, Rectangle, Float4, Float4, Color)
Draws the texture using 9-slicing.
Declaration
[Unmanaged]
public static void Draw9SlicingTexture(TextureBase t, Rectangle rect, Float4 border, Float4 borderUVs, Color color)
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, Rectangle, Float4, Float4, Color)
Draws the texture using 9-slicing (uses point sampler).
Declaration
[Unmanaged]
public static void Draw9SlicingTexturePoint(TextureBase t, Rectangle rect, Float4 border, Float4 borderUVs, Color color)
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(Float2, Float2, Float2, Float2, Color, Single)
Draws a Bezier curve.
Declaration
[Unmanaged]
public static void DrawBezier(Float2 p1, Float2 p2, Float2 p3, Float2 p4, Color color, float thickness = 1F)
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 |
System.Single
thickness
The line thickness. |
DrawBlur(Rectangle, Single)
Draws the background blur.
Declaration
[Unmanaged]
public static void DrawBlur(Rectangle rect, float blurStrength)
Parameters
Rectangle
rect
The target rectangle to draw (blurs its background). |
System.Single
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, Rectangle, GPUPipelineState, Color)
Performs custom rendering.
Declaration
[Unmanaged]
public static void DrawCustom(GPUTexture t, Rectangle rect, GPUPipelineState ps, Color color)
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(Float2, Float2, Color, Color, Single)
Draws a line.
Declaration
[Unmanaged]
public static void DrawLine(Float2 p1, Float2 p2, Color color1, Color color2, float thickness = 1F)
Parameters
Float2
p1
The start point. |
Float2
p2
The end point. |
Color
color1
The line start color. |
Color
color2
The line end color. |
System.Single
thickness
The line thickness. |
DrawLine(Float2, Float2, Color, Single)
Draws a line.
Declaration
[Unmanaged]
public static void DrawLine(Float2 p1, Float2 p2, Color color, float thickness = 1F)
Parameters
Float2
p1
The start point. |
Float2
p2
The end point. |
Color
color
The line color. |
System.Single
thickness
The line thickness. |
DrawMaterial(MaterialBase, Rectangle)
Draws the GUI material.
Declaration
public static void DrawMaterial(MaterialBase material, Rectangle rect)
Parameters
MaterialBase
material
The material to render. Must be a GUI material type. |
Rectangle
rect
The target rectangle to draw. |
DrawMaterial(MaterialBase, Rectangle, Color)
Draws the GUI material.
Declaration
[Unmanaged]
public static void DrawMaterial(MaterialBase material, Rectangle rect, 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(Rectangle, Color, Color, Color, Color, Single)
Draws a rectangle borders.
Declaration
[Unmanaged]
public static void DrawRectangle(Rectangle rect, Color color1, Color color2, Color color3, Color color4, float thickness = 1F)
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. |
System.Single
thickness
The line thickness. |
DrawRectangle(Rectangle, Color, Single)
Draws a rectangle borders.
Declaration
[Unmanaged]
public static void DrawRectangle(Rectangle rect, Color color, float thickness = 1F)
Parameters
Rectangle
rect
The rectangle to draw. |
Color
color
The color to use. |
System.Single
thickness
The line thickness. |
DrawSprite(SpriteHandle, Rectangle)
Draws a sprite.
Declaration
public static void DrawSprite(SpriteHandle spriteHandle, Rectangle rect)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
DrawSprite(SpriteHandle, Rectangle, Color)
Draws a sprite.
Declaration
[Unmanaged]
public static void DrawSprite(SpriteHandle spriteHandle, Rectangle rect, Color color)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawSpritePoint(SpriteHandle, Rectangle)
Draws a sprite (uses point sampler).
Declaration
public static void DrawSpritePoint(SpriteHandle spriteHandle, Rectangle rect)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
DrawSpritePoint(SpriteHandle, Rectangle, Color)
Draws a sprite (uses point sampler).
Declaration
[Unmanaged]
public static void DrawSpritePoint(SpriteHandle spriteHandle, Rectangle rect, Color color)
Parameters
SpriteHandle
spriteHandle
The sprite to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawText(Font, MaterialBase, String, Rectangle, Color, TextAlignment, TextAlignment, TextWrapping, Single, Single)
Draws a text using a custom material shader. Given material must have GUI domain and a public parameter named Font (texture parameter used for a font atlas sampling).
Declaration
public static void DrawText(Font font, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment, TextAlignment verticalAlignment, TextWrapping textWrapping, float baseLinesGapScale = 1F, float scale = 1F)
Parameters
Font
font
The font to use. |
MaterialBase
customMaterial
Custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture. |
System.String
text
The text to render. |
Rectangle
layoutRect
The size and position of the area in which the text is drawn. |
Color
color
The text color. |
TextAlignment
horizontalAlignment
The horizontal alignment of the text in a layout rectangle. |
TextAlignment
verticalAlignment
The vertical alignment of the text in a layout rectangle. |
TextWrapping
textWrapping
Describes how wrap text inside a layout rectangle. |
System.Single
baseLinesGapScale
The scale for distance one baseline from another. Default is 1. |
System.Single
scale
The text drawing scale. Default is 1. |
DrawText(Font, String, Color, Float2, MaterialBase)
Draws a text.
Declaration
[Unmanaged]
public static void DrawText(Font font, string text, Color color, Float2 location, MaterialBase customMaterial = null)
Parameters
Font
font
The font to use. |
System.String
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, String, Color, ref TextLayoutOptions, MaterialBase)
Draws a text with formatting.
Declaration
[Unmanaged]
public static void DrawText(Font font, string text, Color color, ref TextLayoutOptions layout, MaterialBase customMaterial = null)
Parameters
Font
font
The font to use. |
System.String
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, String, Rectangle, Color, TextAlignment, TextAlignment, TextWrapping, Single, Single)
Draws a text.
Declaration
public static void DrawText(Font font, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment, TextAlignment verticalAlignment, TextWrapping textWrapping, float baseLinesGapScale = 1F, float scale = 1F)
Parameters
Font
font
The font to use. |
System.String
text
The text to render. |
Rectangle
layoutRect
The size and position of the area in which the text is drawn. |
Color
color
The text color. |
TextAlignment
horizontalAlignment
The horizontal alignment of the text in a layout rectangle. |
TextAlignment
verticalAlignment
The vertical alignment of the text in a layout rectangle. |
TextWrapping
textWrapping
Describes how wrap text inside a layout rectangle. |
System.Single
baseLinesGapScale
The scale for distance one baseline from another. Default is 1. |
System.Single
scale
The text drawing scale. Default is 1. |
DrawText(Font, String, ref TextRange, Color, Float2, MaterialBase)
Draws a text.
Declaration
[Unmanaged]
public static void DrawText(Font font, string text, ref TextRange textRange, Color color, Float2 location, MaterialBase customMaterial = null)
Parameters
Font
font
The font to use. |
System.String
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, String, ref TextRange, Color, ref TextLayoutOptions, MaterialBase)
Draws a text with formatting.
Declaration
[Unmanaged]
public static void DrawText(Font font, string text, ref TextRange textRange, Color color, ref TextLayoutOptions layout, MaterialBase customMaterial = null)
Parameters
Font
font
The font to use. |
System.String
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, Rectangle)
Draws the texture.
Declaration
public static void DrawTexture(GPUTexture t, Rectangle rect)
Parameters
GPUTexture
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
DrawTexture(GPUTexture, Rectangle, Color)
Draws the texture.
Declaration
[Unmanaged]
public static void DrawTexture(GPUTexture t, Rectangle rect, Color color)
Parameters
GPUTexture
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawTexture(GPUTextureView, Rectangle)
Draws the render target.
Declaration
public static void DrawTexture(GPUTextureView rt, Rectangle rect)
Parameters
GPUTextureView
rt
The render target handle to draw. |
Rectangle
rect
The rectangle to draw. |
DrawTexture(GPUTextureView, Rectangle, Color)
Draws the render target.
Declaration
[Unmanaged]
public static void DrawTexture(GPUTextureView rt, Rectangle rect, Color color)
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, Rectangle)
Draws the texture.
Declaration
public static void DrawTexture(TextureBase t, Rectangle rect)
Parameters
TextureBase
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
DrawTexture(TextureBase, Rectangle, Color)
Draws the texture.
Declaration
[Unmanaged]
public static void DrawTexture(TextureBase t, Rectangle rect, Color color)
Parameters
TextureBase
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
DrawTexturedTriangles(GPUTexture, Float2[], Float2[])
Draws vertices array.
Declaration
[Unmanaged]
public static void DrawTexturedTriangles(GPUTexture t, Float2[] vertices, Float2[] uvs)
Parameters
GPUTexture
t
The texture. |
Float2[]
vertices
The vertices array. |
Float2[]
uvs
The uvs array. |
DrawTexturedTriangles(GPUTexture, Float2[], Float2[], Color)
Draws vertices array.
Declaration
[Unmanaged]
public static void DrawTexturedTriangles(GPUTexture t, Float2[] vertices, Float2[] uvs, Color color)
Parameters
GPUTexture
t
The texture. |
Float2[]
vertices
The vertices array. |
Float2[]
uvs
The uvs array. |
Color
color
The color. |
DrawTexturedTriangles(GPUTexture, Float2[], Float2[], Color[])
Draws vertices array.
Declaration
[Unmanaged]
public static void DrawTexturedTriangles(GPUTexture t, Float2[] vertices, Float2[] uvs, Color[] colors)
Parameters
GPUTexture
t
The texture. |
Float2[]
vertices
The vertices array. |
Float2[]
uvs
The uvs array. |
Color[]
colors
The colors array. |
DrawTexturedTriangles(GPUTexture, UInt16[], Float2[], Float2[], Color[])
Draws indexed vertices array.
Declaration
[Unmanaged]
public static void DrawTexturedTriangles(GPUTexture t, ushort[] indices, Float2[] vertices, Float2[] uvs, Color[] colors)
Parameters
GPUTexture
t
The texture. |
System.UInt16[]
indices
The indices array. |
Float2[]
vertices
The vertices array. |
Float2[]
uvs
The uvs array. |
Color[]
colors
The colors array. |
DrawTexturePoint(GPUTexture, Rectangle)
Draws the texture (uses point sampler).
Declaration
public static void DrawTexturePoint(GPUTexture t, Rectangle rect)
Parameters
GPUTexture
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
DrawTexturePoint(GPUTexture, Rectangle, Color)
Draws the texture (uses point sampler).
Declaration
[Unmanaged]
public static void DrawTexturePoint(GPUTexture t, Rectangle rect, Color color)
Parameters
GPUTexture
t
The texture to draw. |
Rectangle
rect
The rectangle to draw. |
Color
color
The color to multiply all texture pixels. |
End()
Ends the rendering phrase.
Declaration
[Unmanaged]
public static void End()
FillRectangle(Rectangle, Color)
Fills a rectangle area.
Declaration
[Unmanaged]
public static void FillRectangle(Rectangle rect, Color color)
Parameters
Rectangle
rect
The rectangle to fill. |
Color
color
The color to use. |
FillRectangle(Rectangle, Color, Color, Color, Color)
Fills a rectangle area.
Declaration
[Unmanaged]
public static void FillRectangle(Rectangle rect, Color color1, Color color2, Color color3, 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(Float2, Float2, Float2, Color)
Fills a triangular area.
Declaration
[Unmanaged]
public static void FillTriangle(Float2 p0, Float2 p1, Float2 p2, Color color)
Parameters
Float2
p0
The first point. |
Float2
p1
The second point. |
Float2
p2
The third point. |
Color
color
The color. |
FillTriangles(Float2[], Color[], Boolean)
Draws vertices array.
Declaration
[Unmanaged]
public static void FillTriangles(Float2[] vertices, Color[] colors, bool useAlpha)
Parameters
Float2[]
vertices
The vertices array. |
Color[]
colors
The colors array. |
System.Boolean
useAlpha
If true alpha blending will be enabled. |
PeekClip(out Rectangle)
Peeks the current clipping rectangle mask.
Declaration
[Unmanaged]
public static void PeekClip(out Rectangle clipRect)
Parameters
Rectangle
clipRect
The output axis aligned clipping mask rectangle combined from all the masks together (pushed into the masking stack). |
PeekTint(out Color)
Peeks the current tint color.
Declaration
[Unmanaged]
public static void PeekTint(out Color tint)
Parameters
Color
tint
The output tint color. |
PeekTransform(out Matrix3x3)
Peeks the current transformation layer.
Declaration
[Unmanaged]
public static void PeekTransform(out 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
[Unmanaged]
public static void PopClip()
PopTint()
Pops tint color.
Declaration
[Unmanaged]
public static void PopTint()
PopTransform()
Pops transformation layer.
Declaration
[Unmanaged]
public static void PopTransform()
PushClip(Rectangle)
Pushes clipping rectangle mask.
Declaration
public static void PushClip(Rectangle clipRect)
Parameters
Rectangle
clipRect
The axis aligned clipping mask rectangle. |
PushClip(ref Rectangle)
Pushes clipping rectangle mask.
Declaration
[Unmanaged]
public static void PushClip(ref Rectangle clipRect)
Parameters
Rectangle
clipRect
The axis aligned clipping mask rectangle. |
PushTint(ref Color, Boolean)
Pushes tint color.
Declaration
[Unmanaged]
public static void PushTint(ref Color tint, bool inherit = true)
Parameters
Color
tint
The tint color. |
System.Boolean
inherit
Multiply by the last tint on the stack. |
PushTransform(Matrix3x3)
Pushes transformation layer.
Declaration
public static void PushTransform(Matrix3x3 transform)
Parameters
Matrix3x3
transform
The transformation to apply. |
PushTransform(ref Matrix3x3)
Pushes transformation layer.
Declaration
[Unmanaged]
public static void PushTransform(ref Matrix3x3 transform)
Parameters
Matrix3x3
transform
The transformation to apply. |