-
Notifications
You must be signed in to change notification settings - Fork 10
Basic engine initialization
Most of the "basic engine usage" Wiki is based on the SimpleGame code, so there will be examples referring to that code.
SimpleGame keep all the initialization in Game.cpp
, directly inside int main()
.
The first thing to do it's to create an EngineManager object calling:
ScrapEngine::Manager::EngineManager(...)
This will initialize the engine and create a game instance, creating the window and all the engine stuff.
Once the engine has been initialized, it will display the loading screen until you start the game. This is useful because you can take all the time you need to load a huge 3D model or to initialize a large amount of objects. So, until you start the game, the loading screen is displayed and you can do whatever you want without slowing down the game render.
The ScrapEngine is divided into Managers, every side of it has a Manager that manage its calls and objects. There are 2 managers that are very important, the LogicManagerView and the ComponentsManager. Let's describe the main managers:
-
LogicManagerView: it's a user-view of the LogicManager, responsible of executing the GameObject events and registering/unregistering GameObjects. A GameObjects doesn't execute
game_start()
andgame_update(...)
if it hasn't been registered in the LogicManager.game_start()
andgame_update(...)
aren't always necessary so it's up to the user if to register a GameObject or not. -
ComponentsManager: it's responsible of creating and managing components. a Component it's an object that is possesed by a GameObject (a Mesh for example). If you need to create or to destroy a component, you must use the methods in ComponentsManager.
But there are others managers that are useful, such as:
-
InputManager: if you want/need to read user input, you must use the InputManager. It's responsible of managing the mouse cursor and reading if a keyboard/mouse key is pressed or not.
-
SceneManager: right now the SceneManager is responsible only of creating and editing a Skybox. But more stuff might be added in the future, as sun light management or similar .
-
RenderManagerView: it's a user-view of the RenderManager, responsible of rendering the game. Right now is useful only to get the GameWindow and the game Camera, but more stuff might be added in the future.
Remember that all the necessary managers are accessible from the EngineManager, that's the public interface to the user.
Once you're done creating the engine and the objects, you can start the game with:
scrap_engine_manager_obj->start_game_loop();
First, the EngineManager will call game_start()
to every SGameObject registered.
Then, the game render will begin, starting the execution of the engine loop (see article).
For more about creating objects and engine calls see "basic engine usage".
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