Files
sbox-public/engine/Sandbox.Engine/Scene/GameObjectSystems/DebugOverlay/DebugOverlaySystem.DrawTexture.cs
Matt Stevens cdedb6e4c7 All of these SceneCustomObjects should be safe to run on non-main thread
- TextRenderer.TextSceneObject — world text component
- DebugTextureSceneObject — debug overlay textures
- DebugTextSceneObject — debug overlay text
- DebugSphereSceneObject — debug overlay spheres
- SceneMapLoader.TextSceneObject — map world text entities
- LPVDebugGridObject — light probe debug grid
- ClutterBatchSceneObject — clutter instanced rendering

These ones are not as simple:

- ScenePanelObject - so much UI shit wasn't thread safe before, but should nwo be ...
- GizmoInlineSceneObject
- SpriteBatchSceneObject - lots of non concurrent dictionaries around here (needs a commandlist approach)
2026-04-18 09:22:18 +01:00

41 lines
1011 B
C#

namespace Sandbox;
public partial class DebugOverlaySystem
{
public void Texture( Vector2 pixelPosition, Texture texture, Vector2 size, float duration = 0 )
{
var so = new DebugTextureSceneObject( Scene.SceneWorld );
so.ScreenPos = pixelPosition;
so.ScreenSize = size;
so.Flags.CastShadows = false;
so.RenderLayer = SceneRenderLayer.OverlayWithoutDepth;
Add( duration, so );
}
}
file class DebugTextureSceneObject : SceneCustomObject
{
public Texture Texture;
public Vector2 ScreenPos;
public Vector2 ScreenSize;
Material material;
public DebugTextureSceneObject( SceneWorld sceneWorld ) : base( sceneWorld )
{
managedNative.ExecuteOnMainThread = false;
material = Material.FromShader( "shaders/Debug/screen_texture.shader" );
}
public override void RenderSceneObject()
{
var rect = new Rect( ScreenPos, ScreenSize );
var attributes = new RenderAttributes();
attributes.Set( "Texture", Texture );
Graphics.DrawQuad( rect, material, Color.White, attributes );
}
}