This tutorial walks you from an empty project to a working Guillaume scene. It assumes you have already built the library.
1. Create a utility::Engine implementation
Guillaume is engine-coupled: rendering and event polling are delegated to a utility::Engine subclass. Implement the pure virtual methods for your platform:
#include <utility/engine.hpp>
class MyEngine : public utility::Engine {
public:
void clear(void) override { }
void present(void) override { }
size_t createObject(
std::shared_ptr<utility::graphic::Renderable> object) override {
return 0;
}
bool updateObject(std::shared_ptr<utility::graphic::Renderable> object,
size_t objectID) override { return true; }
bool removeObject(std::shared_ptr<utility::graphic::Renderable> object,
size_t objectID) override { return true; }
utility::graphic::SizeF
measureText(const utility::graphic::Text &text) const override {
return { 0.0f, 0.0f };
}
utility::graphic::ViewF getView(void) const override {
return utility::graphic::ViewF();
}
void pollEvents(void) override {}
void update(void) override {}
};
2. Define a scene and build entities
A Scene owns its entity and component registries. Build your UI in onEnter():
#include <guillaume/scene.hpp>
public:
}
};
One screen of the application: it owns the entities shown and the components that hold their state.
Scene(std::shared_ptr< utility::RessourceProvider > ressourceProvider, LocalStorage &localStorage, SessionStorage &sessionStorage)
Create an empty scene with its registries and its builders.
virtual void onEnter(void)
Called each time the scene becomes the active one: at start-up for the default scene,...
3. Run the main loop
Wire the application together and call run():
#include <guillaume/application.hpp>
int main() {
auto resources = std::make_shared<utility::RessourceProvider>(...);
std::make_unique<MyEngine>());
return app.run();
}
The entry point of a program: owns the engine, the scenes and the systems, and runs the frame loop.
The first template argument is the scene shown at start-up; list any other scenes after it (Application<HomeScene, SettingsScene>). The application takes ownership of the engine and enters the first scene in its constructor.
Application::run() drives the frame loop: it polls events, clears, updates, runs the system phases, processes scene transitions, and presents.
4. Handle an input event and render
Subscribe to events through the EventBus (available on the application) and let systems react. For example, a KeyboardControl system already handles text editing for entities with Text and Focus components.
Next steps