Class UIBatch
A utility class to batch and draw UI images.
public class UIBatch : BatchBase<UIBatch.UIImageDrawInfo>, IDisposable, IComponent, IReferencable, ICollectorHolder
- Inheritance
-
objectUIBatch
- Implements
- Inherited Members
- Extension Methods
Constructors
UIBatch(GraphicsDevice)
Initializes a new instance of the UIBatch class.
public UIBatch(GraphicsDevice device)
Parameters
deviceGraphicsDeviceA valid instance of GraphicsDevice.
Properties
SDFSpriteFontEffect
public EffectInstance SDFSpriteFontEffect { get; }
Property Value
Methods
Begin(GraphicsContext, ref Matrix, BlendStateDescription?, SamplerState, RasterizerStateDescription?, DepthStencilStateDescription?, int)
Begins a image batch rendering using the specified blend state, sampler, depth stencil, rasterizer state objects, and the view-projection transformation matrix. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp).
public void Begin(GraphicsContext graphicsContext, ref Matrix viewProjection, BlendStateDescription? blendState, SamplerState samplerState, RasterizerStateDescription? rasterizerState, DepthStencilStateDescription? depthStencilState, int stencilValue)
Parameters
graphicsContextGraphicsContextThe graphics context to use.
viewProjectionMatrixThe view projection matrix used for this series of draw calls
blendStateBlendStateDescription?Blending options.
samplerStateSamplerStateTexture sampling options.
rasterizerStateRasterizerStateDescription?Rasterization options.
depthStencilStateDepthStencilStateDescription?Depth and stencil options.
stencilValueintThe value of the stencil buffer to take as reference
Begin(GraphicsContext, ref Matrix, BlendStateDescription?, DepthStencilStateDescription?, int)
Begins a image batch rendering using the specified blend state, depth stencil and a view-projection transformation matrix. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.None).
public void Begin(GraphicsContext graphicsContext, ref Matrix viewProjection, BlendStateDescription? blendState, DepthStencilStateDescription? depthStencilState, int stencilValue)
Parameters
graphicsContextGraphicsContextThe graphics context to use.
viewProjectionMatrixThe view projection matrix used for this series of draw calls
blendStateBlendStateDescription?Blending options.
depthStencilStateDepthStencilStateDescription?Depth and stencil options.
stencilValueintThe value of the stencil buffer to take as reference
BeginCustom(GraphicsContext, int)
public void BeginCustom(GraphicsContext graphicsContext, int overrideEffect)
Parameters
graphicsContextGraphicsContextoverrideEffectint
DrawBackground(ref Matrix, ref Vector3, ref Color, int)
Draw a colored background having provided size at the position specified by the world matrix.
public void DrawBackground(ref Matrix worldMatrix, ref Vector3 elementSize, ref Color color, int depthBias)
Parameters
worldMatrixMatrixThe world matrix specifying the position of the element in the world
elementSizeVector3The size of the element
colorColorThe color of the element
depthBiasintThe depth bias to use when drawing the element
DrawCube(ref Matrix, ref Vector3, ref Color, int)
Draw a cube of the provided size at the position specified by the world matrix having the provided color.
public void DrawCube(ref Matrix worldMatrix, ref Vector3 elementSize, ref Color color, int depthBias)
Parameters
worldMatrixMatrixThe world matrix specifying the position of the cube in the world
elementSizeVector3The size of the cube
colorColorThe color of the cube
depthBiasintThe depth bias to use when drawing the element
DrawImage(Texture, ref Matrix, ref RectangleF, ref Vector3, ref Vector4, ref Color, int, ImageOrientation, SwizzleMode, bool)
Batch a new border image draw to the draw list.
public void DrawImage(Texture texture, ref Matrix worldMatrix, ref RectangleF sourceRectangle, ref Vector3 elementSize, ref Vector4 borderSize, ref Color color, int depthBias, ImageOrientation imageOrientation = ImageOrientation.AsIs, SwizzleMode swizzle = SwizzleMode.None, bool snapImage = false)
Parameters
textureTextureThe texture to use during the draw
worldMatrixMatrixThe world matrix of the element
sourceRectangleRectangleFThe rectangle indicating the source region of the texture to use
elementSizeVector3The size of the ui element
borderSizeVector4The size of the borders in the texture in pixels (left/top/right/bottom)
colorColorThe color to apply to the texture image.
depthBiasintThe depth bias of the ui element
imageOrientationImageOrientationThe rotation to apply on the image uv
swizzleSwizzleModeSwizzle mode indicating the swizzle use when sampling the texture in the shader
snapImageboolIndicate if the image needs to be snapped or not
DrawRectangle(ref Matrix, ref Vector3, ref Color, int)
Draw a rectangle of the provided size at the position specified by the world matrix having the provided color.
public void DrawRectangle(ref Matrix worldMatrix, ref Vector3 elementSize, ref Color color, int depthBias)
Parameters
worldMatrixMatrixThe world matrix specifying the position of the rectangle in the world
elementSizeVector3The size of the rectangle
colorColorThe color of the rectangle
depthBiasintThe depth bias to use when drawing the element
UpdateBufferValuesFromElementInfo(ref ElementInfo, nint, nint, int)
Update the mapped vertex and index buffer values using the provided element info.
protected override void UpdateBufferValuesFromElementInfo(ref BatchBase<UIBatch.UIImageDrawInfo>.ElementInfo elementInfo, nint vertexPtr, nint indexPtr, int vertexOffset)
Parameters
elementInfoBatchBase<UIBatch.UIImageDrawInfo>.ElementInfoThe structure containing the information about the element to draw.
vertexPtrnintindexPtrnintvertexOffsetint