40 Engine(SDL_Window* window) : _window(window) {}
52 const std::shared_ptr<Scene>&
scene()
const {
return _scene; }
53 const std::shared_ptr<GraphicsDevice>&
graphicsDevice()
const {
return _graphicsDevice; }
62 std::pair<int, int>
resizeCanvas(
int width = 0,
int height = 0);
92 std::shared_ptr<Entity>
root() {
return _root; }
94 std::shared_ptr<ScriptRegistry>
scripts()
const {
return _scripts; }
96 std::shared_ptr<ComponentSystemRegistry>
systems()
const {
return _systems; }
104 const std::shared_ptr<ResourceLoader>&
loader()
const {
return _loader; }
112 static std::unordered_map<std::string, std::shared_ptr<Engine>> _engines;
115 void renderComposition();
119 void initDefaultMaterial();
121 void initProgramLibrary();
123 void registerSceneImmediate(
const std::shared_ptr<Scene>&
scene);
125 void fillFrameStatsBasic(
double now,
float dt,
float ms);
127 void fillFrameStats();
129 std::shared_ptr<GraphicsDevice> _graphicsDevice;
131 std::shared_ptr<Entity> _root;
132 std::shared_ptr<ForwardRenderer> _renderer;
134 std::shared_ptr<Scene> _scene;
137 std::shared_ptr<ComponentSystemRegistry> _systems;
139 void* _frameRequestId =
nullptr;
140 float _timeScale = 1.0f;
141 float _maxDeltaTime = 0.1f;
147 bool _autoRender =
true;
149 std::shared_ptr<ApplicationStats> _stats;
151 std::shared_ptr<ResourceLoader> _loader;
152 std::shared_ptr<AssetRegistry> _assets;
153 std::shared_ptr<BundleRegistry> _bundles;
154 std::shared_ptr<SceneRegistry> _scenes;
155 std::shared_ptr<ScriptRegistry> _scripts;
156 std::shared_ptr<I18n> _i18n;
159 std::shared_ptr<Layer> _defaultLayerWorld;
160 std::shared_ptr<Layer> _defaultLayerDepth;
161 std::shared_ptr<Layer> _defaultLayerSkybox;
162 std::shared_ptr<Layer> _defaultLayerUi;
163 std::shared_ptr<Layer> _defaultLayerImmediate;
165 std::vector<std::string> _scriptsOrder;
166 std::string _scriptPrefix;
168 std::shared_ptr<Lightmapper> _lightmapper;
170 std::shared_ptr<BatchManager> _batcher;
172 std::shared_ptr<Controller> _controller;
173 std::shared_ptr<Keyboard> _keyboard;
174 std::shared_ptr<Mouse> _mouse;
175 std::shared_ptr<GamePads> _gamepads;
176 std::shared_ptr<TouchDevice> _touch;
177 std::shared_ptr<ElementInput> _elementInput;
178 std::shared_ptr<XrManager> _xr;
186 bool _allowResize =
true;
188 bool _inFrameUpdate =
false;
193 float _fixedDeltaTime = 1.0f / 60.0f;
194 double _fixedTimeAccumulator = 0.0;
195 int _maxFixedSubSteps = 8;
196 float _fixedTimeAlpha = 0.0f;
198 bool _renderNextFrame =
false;
200 bool _destroyRequested =
false;
202 std::unordered_map<std::string, std::shared_ptr<Entity>> _entityIndex;
204 bool _inTools =
false;
207 bool _frameStartCalled =
false;
208 bool _renderCompositionCalled =
false;
209 bool _frameEndCalled =
false;