Files
sbox-public/engine/Sandbox.Engine/Systems/UI/Render/UIDrawBuffer.cs
Antoine Pilote a582fd6f7a UI Batching (#4372)
New UI rendering that groups multiple panels to be grouped into a single draw call when possible.

New custom rendering API for custom panels using `Panel.Draw.XX` to emit drawing commands.
2026-04-14 16:06:41 -07:00

40 lines
890 B
C#

using Sandbox.Rendering;
namespace Sandbox.UI;
/// <summary>
/// Thread-local buffer for collecting UI draw descriptors during panel.OnDraw().
/// Descriptors are routed directly to the active RenderLayer.
/// </summary>
internal class UIDrawBuffer
{
[ThreadStatic] static UIDrawBuffer _current;
internal static UIDrawBuffer Current => _current ??= new();
/// <summary>
/// The target layer for draw calls. Set by the renderer before OnDraw().
/// </summary>
public RenderLayer ActiveLayer;
public void AddBox( in BoxDrawDescriptor desc )
{
ActiveLayer.Boxes.Add( desc );
}
public void AddShadow( in ShadowDrawDescriptor desc )
{
ActiveLayer.AddShadow( desc );
}
public void AddOutline( in OutlineDrawDescriptor desc )
{
ActiveLayer.Outlines.Add( desc );
}
public void AddBackdrop( in BackdropDrawDescriptor desc )
{
ActiveLayer.Backdrops.Add( desc );
}
}