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

classMySimulation:Simulation{publicoverrideOnInitialize(AppConfigconfig){}publicoverrideOnRender(ICanvascanvas){}}

Properties

Application

ApplicationApplication{get;}

The simulation's application.

Methods

OnInitialize

abstractvoidOnInitialize(AppConfigconfig);

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

abstractvoidOnRender(ICanvascanvas);

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

virtualvoidOnUninitialize();

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

OnResize

virtualvoidOnResize(intwidth,intheight);

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

voidRun(IAppPlatformplatform);

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

Clone this wiki locally