Files
sbox-public/engine/Sandbox.Engine/Systems/Render/Debug/DebugOverlay.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

87 lines
2.1 KiB
C#

using Sandbox.Rendering;
namespace Sandbox;
internal static partial class DebugOverlay
{
static CommandList _overlay = new( "Engine Overlay" );
public static CommandList CommandList => _overlay;
public static HudPainter Hud => new HudPainter( CommandList );
public static void Reset()
{
_overlay.Reset();
}
public static void Render()
{
_overlay.ExecuteOnRenderThread();
}
[ConVar( "overlay_profile", Help = "Draws an overlay showing timings from the main profile categories" )]
internal static int overlay_profile { get; set; } = 0;
[ConVar( "overlay_alloc", Help = "Draws an overlay showing allocations and garbage collection" )]
internal static int overlay_alloc { get; set; } = 0;
[ConVar( "overlay_frame", Help = "Draws an overlay render frame stats" )]
internal static int overlay_frame { get; set; } = 0;
[ConVar( "overlay_network_graph", Help = "Draws an overlay showing a network usage summary" )]
internal static int overlay_network_graph { get; set; } = 0;
[ConVar( "overlay_network_calls", Help = "Draws an overlay showing most received network calls" )]
internal static int overlay_network_calls { get; set; } = 0;
[ConVar( "overlay_pp", Help = "Draws an overlay showing current post process stack" )]
internal static int overlay_pp { get; set; } = 0;
public static void Draw()
{
Vector2 pos = new Vector2( 100, 130 );
var activeScene = Application.GetActiveScene();
if ( overlay_network_calls == 1 )
{
DebugOverlay.NetworkCalls.Draw( ref pos );
pos.y += 20;
}
if ( overlay_network_graph == 1 )
{
DebugOverlay.NetworkGraph.Draw( ref pos );
pos.y += 20;
}
if ( overlay_profile == 1 )
{
DebugOverlay.Profiler.Draw( ref pos );
pos.y += 20;
}
if ( overlay_frame == 1 )
{
DebugOverlay.Frame.Draw( ref pos );
pos.y += 20;
}
if ( overlay_pp == 1 )
{
activeScene?.Camera?.PrintPostProcessDebugOverlay( ref pos, Hud );
pos.y += 20;
}
if ( overlay_alloc == 1 )
{
DebugOverlay.Allocations.Draw( ref pos );
pos.y += 20;
}
else
{
DebugOverlay.Allocations.Disabled();
}
}
}