Defines the base App class that serves as the application core structure and the entry point.
More...
#include <App.hpp>
|
int | run (int argc, char **argv) |
| The main entry point into the App.
|
|
virtual | ~App ()=default |
|
|
template<typename TController > |
TController * | register_controller () |
| Registers the controller for execution. The Controller instance that the register_controller returns isn't initialized yet. It will be initialized during the App::initialize. If the register_controller is called twice for the same controller, it's registered only once. The other calls just return the pointer to the already registered instance.
|
|
|
void | engine_setup (int argc, char **argv) |
| The first function that the engine calls to do its internal Controller classes engine_setup .
|
|
virtual void | app_setup () |
| Override to define your custom app setup that gets called after engine engine_setup .
|
|
void | initialize () |
| Initializes all the controllers registered in App::user_setup. Calls engine::Controller::initialize for registered controllers.
|
|
void | poll_events () |
| Processes all pending events. Calls engine::Controller::poll_events for registered controllers.
|
|
bool | loop () |
| Checks whether the render loop should continue executing. Calls engine::Controller::loop for registered controllers.
|
|
void | update () |
| Updates the app logic state. Calls engine::Controller::update for registered controllers.
|
|
void | draw () |
| Draws the frame. Calls engine::Controller::draw for registered controllers.
|
|
void | terminate () |
| Terminates the app. Calls engine::Controller::terminate for registered controllers in the reverse order.
|
|
virtual int | on_exit () |
| Called right before the App exits.
|
|
virtual void | handle_error (const util::Error &) |
|
Defines the base App class that serves as the application core structure and the entry point.
The main function calls App::run that defines the core structure of the application. You can hook into the engine execution by overriding the desired methods in your implementations of the engine::Controller class and registering your implementations via App::register_controller.
try {
}
} catch (const Error &e) {
}
}
virtual void app_setup()
Override to define your custom app setup that gets called after engine engine_setup.
Definition App.cpp:115
void draw()
Draws the frame. Calls engine::Controller::draw for registered controllers.
Definition App.cpp:88
void terminate()
Terminates the app. Calls engine::Controller::terminate for registered controllers in the reverse ord...
Definition App.cpp:106
void initialize()
Initializes all the controllers registered in App::user_setup. Calls engine::Controller::initialize f...
Definition App.cpp:47
int run(int argc, char **argv)
The main entry point into the App.
Definition App.cpp:13
virtual void handle_error(const util::Error &)
Definition App.cpp:119
virtual int on_exit()
Called right before the App exits.
Definition App.hpp:144
void update()
Updates the app logic state. Calls engine::Controller::update for registered controllers.
Definition App.cpp:80
void engine_setup(int argc, char **argv)
The first function that the engine calls to do its internal Controller classes engine_setup.
Definition App.cpp:31
bool loop()
Checks whether the render loop should continue executing. Calls engine::Controller::loop for register...
Definition App.cpp:63
void poll_events()
Processes all pending events. Calls engine::Controller::poll_events for registered controllers.
Definition App.cpp:72
◆ ~App()
virtual engine::core::App::~App |
( |
| ) |
|
|
virtualdefault |
◆ run()
int engine::core::App::run |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
The main entry point into the App.
try {
}
} catch (const Error &e) {
}
}
◆ engine_setup()
void engine::core::App::engine_setup |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
|
private |
The first function that the engine calls to do its internal Controller classes engine_setup
.
After the engine engine_setup
is finished, engine_setup
calls the App::user_setup(int argc, char** argv) that you can override and do your custom setup operations. This is where you should register your own controllers.
◆ app_setup()
void engine::core::App::app_setup |
( |
| ) |
|
|
privatevirtual |
◆ initialize()
void engine::core::App::initialize |
( |
| ) |
|
|
private |
Initializes all the controllers registered in App::user_setup. Calls engine::Controller::initialize for registered controllers.
After this functions finishes all the controllers have been initialized, and they can be now used by calling engine::core::Controller::get<TController>()
◆ poll_events()
void engine::core::App::poll_events |
( |
| ) |
|
|
private |
Processes all pending events. Calls engine::Controller::poll_events for registered controllers.
It handles input events, system events, and any other types of events that have been queued. This is where the platform events are processed.
◆ loop()
bool engine::core::App::loop |
( |
| ) |
|
|
private |
Checks whether the render loop should continue executing. Calls engine::Controller::loop for registered controllers.
This is where you should check if an internal or external event happened that stops the main render loop. For example the user presses ESC.
- Returns
- true if the main loop should continue, false otherwise.
◆ update()
void engine::core::App::update |
( |
| ) |
|
|
private |
Updates the app logic state. Calls engine::Controller::update for registered controllers.
This is where all the App state should be updated including handling events registered in App::poll_events, processing physics, world logic etc.
◆ draw()
void engine::core::App::draw |
( |
| ) |
|
|
private |
Draws the frame. Calls engine::Controller::draw for registered controllers.
This is where all the drawing should happen based on the state that the App::update computed.
◆ terminate()
void engine::core::App::terminate |
( |
| ) |
|
|
private |
Terminates the app. Calls engine::Controller::terminate for registered controllers in the reverse order.
Terminate is called always, regardless of whether the app closes successfully or an error occurs.
◆ on_exit()
virtual int engine::core::App::on_exit |
( |
| ) |
|
|
inlineprivatevirtual |
Called right before the App exits.
This where you can do custom operation when all the app state has already been terminated, and all the internal engine systems have been shutdown. This functions gets called just before the return from main.
- Returns
- The value that should be returned from the int main(...).
◆ handle_error()
void engine::core::App::handle_error |
( |
const util::Error & |
e | ) |
|
|
privatevirtual |
◆ register_controller()
template<typename TController >
TController * engine::core::App::register_controller |
( |
| ) |
|
|
inlineprotected |
Registers the controller for execution. The Controller instance that the register_controller returns isn't initialized yet. It will be initialized during the App::initialize. If the register_controller is called twice for the same controller, it's registered only once. The other calls just return the pointer to the already registered instance.
- Returns
- Pointer to the only instance of the provided Controller class TController.
◆ m_controllers
std::vector<Controller *> engine::core::App::m_controllers |
|
private |
The documentation for this class was generated from the following files: