Skip to content

ERS Debugger

The ERS Debugger is a powerful tool for inspecting and controlling simulation execution in real-time. Because it's built into ERS itself, it can be used with any model.

ERS Debugger

The ERS Debugger.

Basic usage

The easiest way to use the debugger is using the Run function. This function requires a ModelContainer to inspect.

// Initialize ERS
ERS::Initialize();

// Create a model container
Ers::ModelContainer model = Ers::ModelContainer::Create();

// Run the debugger
Ers::Debugger::Run(modelContainer);
// Initialize ERS
ERS.Initialize();

// Create a model container
ModelContainer modelContainer = ModelContainer.Create();

// Run the debugger
Debugger.Run(modelContainer);

This is all that is necessary to open the debugger. Inside the debugger there are various widgets to inspect and run the model. See the Available ImGui widgets page for an overview of these widgets.

Accessing data of the debugger

Various variables of the debugger's state may be useful to access. The following data can be accessed programmatically:

Name Description
SelectedSimulator The simulator that is currently selected in the debugger.
SelectedEntity The entity that is currently selected in the debugger.
Window The Window of the debugger.
RenderContext The RenderContext of the debugger.
IsRunning Whether the model is currently being executed.
Is3DMode Whether the visualization in the debugger is rendering in 3D. False means it is rendering in 2D.

Custom rendering

By default, the debugger will visualize all entities that use the standard render system inside the visualization widget at the center of the application. However, it may be necessary to a use more advanced visualization (see also custom rendering). To be able to use all rendering function available in ERS, the Open function can optionally be given a 2D and 3D rendering function to create custom rendering.

void Render2D(Ers::Debugger& debugger, Ers::Simulator& simulator)
{
    Ers::RenderContext renderContext = debugger.GetRenderContext();
    // Implement custom 2D rendering us the render context here

    // Optionally call the standard render system if it should be combined with custom rendering
    Ers::RenderSystem::Render2D(Ers::SubModel::Get(), debugger.GetRenderContext());
}

void Render3D(Ers::Debugger& debugger, Ers::Simulator& simulator)
{
    Ers::RenderContext renderContext = debugger.GetRenderContext();
    // Implement custom 3D rendering us the render context here

    // Optionally call the standard render system if it should be combined with custom rendering
    Ers::RenderSystem::Render3D(Ers::SubModel::Get(), debugger.GetRenderContext());
}

void RenderUI(Ers::Debugger& debugger)
{
    // Implement custom UI using ImGui here
}

Ers::Debugger::Run(modelContainer, Render2D, Render3D, RenderUI);
void Render2D(Debugger debugger, Simulator simulator)
{
    RenderContext renderContext = debugger.RenderContext;
    // Implement custom 2D rendering us the render context here

    // Optionally call the standard render system if it should be combined with custom rendering
    RenderSystem.Render2D(SubModel.Get(), debugger.RenderContext);
}

void Render3D(Debugger debugger, Simulator simulator)
{
    RenderContext renderContext = debugger.RenderContext;
    // Implement custom 3D rendering us the render context here

    // Optionally call the standard render system if it should be combined with custom rendering
    RenderSystem.Render3D(SubModel.Get(), debugger.RenderContext);
}

void RenderUI(Debugger debugger)
{
    // Implement custom UI using ImGui here
}

Ers.Debugger.Run(modelContainer, Render2D, Render3D, RenderUI);
Was this page helpful?