Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
EstellaContext.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
13#pragma once
14
15#include "Types.hpp"
16#include "ServiceRegistry.hpp"
19
20namespace esengine {
21
22class GfxDevice;
23
25public:
28
31
40 bool init(int webglContextHandle);
41
43 bool init(int webglContextHandle, bool ownsContext);
44
53 bool init(Unique<GfxDevice> device);
54
58 void shutdown();
59
61 bool isInitialized() const { return state_.initialized; }
62
63 RenderThread& renderThread() { return render_thread_; }
64
65 ServiceRegistry& services() { return services_; }
66
67 template<typename T>
68 T& require() { return services_.require<T>(); }
69
70 template<typename T>
71 T* tryGet() { return services_.getService<T>(); }
72
73 EngineState& state() { return state_; }
74 const EngineState& state() const { return state_; }
75
76private:
77 void initSubsystems(Unique<GfxDevice> gfxDevice);
84 void registerLogicSystems();
85
86 ServiceRegistry services_;
87 EngineState state_;
88 RenderThread render_thread_;
89};
90
91} // namespace esengine
Typed service locator for engine subsystems.
Core type definitions and utilities for ESEngine.
bool init(int webglContextHandle)
Initialize with an existing WebGL context handle.
EstellaContext & operator=(const EstellaContext &)=delete
const EngineState & state() const
void shutdown()
Shut down all subsystems and release resources.
ServiceRegistry & services()
RenderThread & renderThread()
bool isInitialized() const
Check if the context is initialized.
EstellaContext(const EstellaContext &)=delete
bool init(int webglContextHandle, bool ownsContext)
Abstract graphics device interface.
Definition GfxDevice.hpp:75
Typed service locator for engine subsystems.
std::unique_ptr< T > Unique
Unique ownership smart pointer.
Definition Types.hpp:75