-
Notifications
You must be signed in to change notification settings - Fork 9
Engine main game loop description
As every other engine, the ScrapEngine has a main loop that run few tasks.
In this page you can find a small description of how it works.
Before it, an event is called:
game_start() is called to every SGameObject registered, allowing initializations or other stuff to be made before the game starts.
Here is what happens in the main game loop:
- The time spent to generating a frame is computed;
- game_update(float time) is called to every SGameObject registered, allowing update or other stuff to be made every frame. float time is the time spent generating the last frame, also called "delta time";
- on_gui() is called to every SGameObject registered, allowing gui operations to be made (for example a gui that show the current score or time left);
- It runs the "physics update", updating all rigidbodies locations and connected meshes. For more informations about the physics update accumulator see reactphysics3d documentation;
- It runs the "audio update", reading the camera location to update the listener location and rotation, allowing 3D audio to work correctly;
- Finally, it generate and draw the frame.
It is not possible to do everything in the main game loop, as some tasks are too heavy and would slow down the framerate a lot. For more informations about that, you can read Tasks running in background.
This documentation describe only a small part of the engine, since it's not made to be used by a large amount of people.
If you would like to know more about a part of the engine, how to do something, or if a part of the documentation is not correct/out of date, please open an issue and tell me.
Thank you for reading the ScrapEngine Wiki!
Getting started
Engine structure
Using the Engine