GraphicsAPI reference
Class Renderer2D
Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics2D.dll
Guide: The 2D batcher and the camera
The engine’s 2D batcher (IRenderer2D) over one graphics device.
public sealed class Renderer2D : IRenderer2D, IDisposableInheritance
Implements
Constructors
Renderer2D(IGraphicsDevice)
Creates the batcher (and its 1 × 1 white texture, which untextured draws sample).
public Renderer2D(IGraphicsDevice device)Parameters
device IGraphicsDevice
Properties
Device
The device the batcher draws with.
public IGraphicsDevice Device { get; }Property Value
State
The state draws are recorded with; set it, or push and pop it.
public RenderState State { get; set; }Property Value
Statistics
Counts of the current (or last) batch.
public Renderer2DStatistics Statistics { get; }Property Value
Target
The target of the current batch, or null outside a batch.
public RenderTarget? Target { get; }Property Value
White
The 1 × 1 opaque white texture untextured draws sample.
public Texture White { get; }Property Value
Methods
Begin(in BatchSettings)
public void Begin(in BatchSettings settings)Parameters
settings BatchSettings
Clear(ColorF)
Submits what was recorded, then clears the whole target (viewport and scissor ignored) to a premultiplied colour.
public void Clear(ColorF color)Parameters
color ColorF
Dispose()
Releases the batcher’s buffers and white texture.
public void Dispose()Draw(Texture, RectF, in Matrix3x2, ColorF, float, SpriteFlip)
public void Draw(Texture texture, RectF source, in Matrix3x2 world, ColorF tint, float depth = 0, SpriteFlip flip = SpriteFlip.None)Parameters
texture Texture
source RectF
world Matrix3x2
tint ColorF
depth float
flip SpriteFlip
DrawGeometry(Texture?, ReadOnlySpan<Vertex2D>, ReadOnlySpan<ushort>, float)
Draws triangles (positions transformed like a draw’s local units); a null texture draws the vertex colours.
public void DrawGeometry(Texture? texture, ReadOnlySpan<Vertex2D> vertices, ReadOnlySpan<ushort> indices, float depth = 0)Parameters
texture Texture?
vertices ReadOnlySpan<Vertex2D>
indices ReadOnlySpan<ushort>
depth float
Exceptions
An index selects no vertex, or more than 65,535 vertices.
End()
Submits what remains and ends the batch.
public void End()Exceptions
No batch is open, or a pushed transform or state was not popped.
Flush()
Submits what was recorded so far (for example before reading the target back).
public void Flush()PopState()
Restores the state saved by the last PushState.
public void PopState()Exceptions
Nothing was pushed.
PopTransform()
Returns to the transform before the last PushTransform.
public void PopTransform()Exceptions
Nothing was pushed.
PushState(in RenderState)
public void PushState(in RenderState state)Parameters
state RenderState
PushTransform(in Matrix3x2)
public void PushTransform(in Matrix3x2 transform)Parameters
transform Matrix3x2