Skip to content

Simulation

Ryan Andersen edited this page Jul 10, 2022 · 1 revision

The Simulation class is the easiest way to setup an application using SimulationFramework.

Example

class MySimulation : Simulation
{
    public override OnInitialize(AppConfig config)
    {
    }

    public override OnRender(ICanvas canvas)
    {
    }
}

Properties

Application

Application Application { get; }

The simulation's application.

Methods

OnInitialize

abstract void OnInitialize(AppConfig config);

OnInitialize is called after the simulation has been initialized, before any calls to OnRender. This is the first time that any static APIs can be used.

The config parameter provides an AppConfig instance the simulation can use to properly configure the window or any needed features.

This method must be overridden by inheriting classes.

OnRender

abstract void OnRender(ICanvas canvas);

This method is called once per frame, when the simulation needs to render.

The canvas parameter provides the canvas that the simulation should render to. This is not guaranteed to be the window canvas.

This method must be overridden by inheriting classes.

OnUninitialize

virtual void OnUninitialize();

Called when the simulation is ending, after the final call to OnRender. No static APIs should be used here.

OnResize

virtual void OnResize(int width, int height);

Called when the simulation is resized. The width and height parameters specify the new size of the simulation's window.

This method is always called before OnRender.

Run

void Run(IAppPlatform platform);

Starts a simulation, using the provided platform. This method returns only when the simulation stops running.