QuickstartApp
in package
implements
GameLoopDelegate
uses
SystemRegistryTrait
Table of Contents
Interfaces
Properties
- $container : Container
- $dispatcher : Dispatcher
- A event dispacher instance
- $entities : EntityRegistry
- An entity registry instance
- $frameIndex : int
- The current frame index
- $gl : GLState
- GL State holder
- $input : Input
- The input instance of the app
- $inputContext : InputContextMap
- An input action mapper
- $options : QuickstartOptions
- $renderResources : PipelineResources
- Rendering pipeline resources
- $shaders : ShaderCollection
- A shader collection instance
- $tickIndex : int
- The current tick index
- $vg : VGContext
- VectorGraphics Context
- $window : Window
- The window instance of the app
- $bindedSystems : array<string|int, SystemInterface>
- Array of binded systems
- $dbgOverlayRenderer : QuickstartDebugMetricsOverlay
- Quickstart Debug Metrics Overlay
- $fullscreenTextureRenderer : FullscreenTextureRenderer
- Fullscreen Texture Renderer
- $profiler : ProfilerInterface|null
- Optional Profiler
Methods
- __construct() : void
- QuickstartApp constructor.
- attachProfiler() : void
- Attaches the given profiler to the app, the profiler will be passed to the rendering pipeline.
- bindSystem() : void
- Binds a system to the registry
- bindSystems() : void
- Binds multiple systems to the registry
- draw() : void
- Draw the scene. (You most definetly want to use this)
- loadCompatGPUProfiler() : void
- Loads a GPU Compat Profiler and attaches it to the app
- ready() : void
- A function that is invoked once the app is ready to run.
- registerSystems() : void
- Registers all binded systems to the entity registry
- render() : void
- Render the current game state This method is called once per frame.
- renderSystem() : void
- Renders the given system with the given render context
- setupDrawAfter() : void
- Prepare / setup additional render passes after the quickstart draw pass This is an "setup" method meaning you should not emit any draw calls here, but rather add additional render passes to the pipeline.
- setupDrawBefore() : void
- Prepare / setup additional render passes before the quickstart draw pass This is an "setup" method meaning you should not emit any draw calls here, but rather add additional render passes to the pipeline.
- shouldStop() : bool
- Returns boolean indicating whether the game loop should stop.
- unregisterSystems() : void
- Unregisters all binded systems from the entity registry
- update() : void
- Update the games state This method might be called multiple times per frame, or not at all if the frame rate is very high.
- updateSystem() : void
- Updates the given system
Properties
$container
public
Container
$container
$dispatcher
A event dispacher instance
public
Dispatcher
$dispatcher
$entities
An entity registry instance
public
EntityRegistry
$entities
$frameIndex
The current frame index
public
int
$frameIndex
= 0
$gl
GL State holder
public
GLState
$gl
$input
The input instance of the app
public
Input
$input
$inputContext
An input action mapper
public
InputContextMap
$inputContext
$options
public
QuickstartOptions
$options
$renderResources
Rendering pipeline resources
public
PipelineResources
$renderResources
$shaders
A shader collection instance
public
ShaderCollection
$shaders
$tickIndex
The current tick index
public
int
$tickIndex
= 0
$vg
VectorGraphics Context
public
VGContext
$vg
$window
The window instance of the app
public
Window
$window
$bindedSystems
Array of binded systems
protected
array<string|int, SystemInterface>
$bindedSystems
= []
$dbgOverlayRenderer
Quickstart Debug Metrics Overlay
private
QuickstartDebugMetricsOverlay
$dbgOverlayRenderer
$fullscreenTextureRenderer
Fullscreen Texture Renderer
private
FullscreenTextureRenderer
$fullscreenTextureRenderer
$profiler
Optional Profiler
private
ProfilerInterface|null
$profiler
= null
Methods
__construct()
QuickstartApp constructor.
public
__construct(Container $container, QuickstartOptions $options) : void
Parameters
- $container : Container
- $options : QuickstartOptions
attachProfiler()
Attaches the given profiler to the app, the profiler will be passed to the rendering pipeline.
public
attachProfiler(ProfilerInterface|null $profiler) : void
Parameters
- $profiler : ProfilerInterface|null
bindSystem()
Binds a system to the registry
public
bindSystem(SystemInterface $system) : void
Will check if the system is already binded before adding it.
Parameters
- $system : SystemInterface
bindSystems()
Binds multiple systems to the registry
public
bindSystems(array<string|int, SystemInterface> $systems) : void
Parameters
- $systems : array<string|int, SystemInterface>
draw()
Draw the scene. (You most definetly want to use this)
public
draw(RenderContext $context, RenderTarget $renderTarget) : void
This is called from within the Quickstart render pass where the pipeline is already prepared, a VG frame is also already started.
Parameters
- $context : RenderContext
- $renderTarget : RenderTarget
loadCompatGPUProfiler()
Loads a GPU Compat Profiler and attaches it to the app
public
loadCompatGPUProfiler() : void
The GPU Compat Profiler uses blocking glBeginQuery / glEndQuery calls which are not optimal for performance but allows basic GPU profiling on all systems.
Just do not enable it in production builds ;)
ready()
A function that is invoked once the app is ready to run.
public
ready() : void
This happens exactly just before the game loop starts.
Here you can prepare your game state, register services, callbacks etc.
registerSystems()
Registers all binded systems to the entity registry
public
registerSystems(EntitiesInterface $entities) : void
Parameters
- $entities : EntitiesInterface
render()
Render the current game state This method is called once per frame.
public
render(float $deltaTime) : void
The render method should draw the current game state to the screen. You recieve a delta time value which you can use to interpolate between the current and the previous frame. This is useful for animations and other things that should be smooth with variable frame rates.
Parameters
- $deltaTime : float
renderSystem()
Renders the given system with the given render context
public
renderSystem(SystemInterface $system, RenderContext $context) : void
Parameters
- $system : SystemInterface
- $context : RenderContext
setupDrawAfter()
Prepare / setup additional render passes after the quickstart draw pass This is an "setup" method meaning you should not emit any draw calls here, but rather add additional render passes to the pipeline.
public
setupDrawAfter(RenderContext $context, RenderTargetResource $renderTarget) : void
Parameters
- $context : RenderContext
- $renderTarget : RenderTargetResource
setupDrawBefore()
Prepare / setup additional render passes before the quickstart draw pass This is an "setup" method meaning you should not emit any draw calls here, but rather add additional render passes to the pipeline.
public
setupDrawBefore(RenderContext $context, RenderTargetResource $renderTarget) : void
Parameters
- $context : RenderContext
- $renderTarget : RenderTargetResource
shouldStop()
Returns boolean indicating whether the game loop should stop.
public
shouldStop() : bool
This method is called once per frame and should return true if the game loop should stop. This is useful if you want to quit the game after a certain amount of time or if the player has lost all his lives etc..
Return values
boolunregisterSystems()
Unregisters all binded systems from the entity registry
public
unregisterSystems(EntitiesInterface $entities) : void
Parameters
- $entities : EntitiesInterface
update()
Update the games state This method might be called multiple times per frame, or not at all if the frame rate is very high.
public
update() : void
The update method should step the game forward in time, this is the place where you would update the position of your game objects, check for collisions and so on.
updateSystem()
Updates the given system
public
updateSystem(SystemInterface $system) : void
Parameters
- $system : SystemInterface