Skip to content

IChartDrawSink

InterfaceChartGuruChartGuru
public interface IChartDrawSink

Backend-neutral immediate-mode draw target used by ChartRenderer to emit geometry without binding to a specific rendering pipeline.

Implementations in this project:

  • GLDrawSink - forwards to GL.Begin/Vertex3/Color/End. Used by the uGUI ChartGraphic path (render-to-texture) and the Scene ChartComponent path.
  • UITKMeshDrawSink - emits into a MeshGenerationContext for the UI Toolkit ChartGuruElement.

The API intentionally mirrors GL's state machine: Begin(topology, material), any number of Color/Vertex pairs, then End. Color state persists until the next Color call, matching GL's current-color model. Scissoring and transform stack are managed out-of-band so the renderer can match GL's MultMatrix/LoadPixelMatrix patterns during morph passes without caring which backend is active.

void Begin(DrawTopology topology, DrawMaterial material = DrawMaterial.Standard)

Begins a primitive batch with the given topology and material bucket. Must be balanced with IChartDrawSink.End() before another IChartDrawSink.Begin(DrawTopology, DrawMaterial).

Parameters

NameType
topologyChartGuru.DrawTopology
materialChartGuru.DrawMaterial
void Color(Color c)

Sets the current vertex color. Applies to all subsequently emitted vertices until overridden.

Parameters

NameType
cUnityEngine.Color
void Vertex(float x, float y)

Emits a vertex at the specified chart-space pixel coordinate (Y up, bottom-left origin).

Parameters

NameType
xSystem.Single
ySystem.Single
void End()

Closes the current primitive batch started by IChartDrawSink.Begin(DrawTopology, DrawMaterial).

void SetScissor(Rect? clipRectPixels)

Sets an axis-aligned scissor rectangle in pixel coordinates, or clears it when null. Intended for morph and inset panels; the GL sink translates this to an SRP scissor, the UI Toolkit sink to a clipping descendant or manual CPU-side clipping.

Parameters

NameType
clipRectPixelsSystem.Nullable{UnityEngine.Rect}
void PushTransform(Matrix4x4 m)

Pushes a transform onto the sink’s matrix stack. Subsequent IChartDrawSink.Vertex(float, float) calls are effectively multiplied by the top-of-stack matrix. Matches GL.PushMatrix + GL.MultMatrix(m).

Parameters

NameType
mUnityEngine.Matrix4x4
void PopTransform()

Pops the top matrix from the sink’s transform stack. Matches GL.PopMatrix.