9 #pragma region ENGINE_SYSTEMS
35 const SDL_DisplayMode*
data =
nullptr;
124 void update(
double delta_time = 0);
140 template <
typename T>
144 double _physics_accumulator = 0.0;
146 std::vector<std::unique_ptr<EngineManager>> _systems{};
165 Renderer* _create_renderer_internal(SDL_Window* window,
int view_width,
int view_height,
Backend type);
177 Renderer* _create_renderer_gl(SDL_Window* window,
int view_width,
int view_height);
189 Renderer* _create_renderer_metal(SDL_Window* window,
int view_width,
int view_height);
192 template <
typename T>
195 for (
auto& sys : _systems) {
196 if (T* casted =
dynamic_cast<T*
>(sys.get())) {
205 extern std::unique_ptr<Engine>
GEngine;
228 template <
typename T>
230 static std::random_device rd;
231 static std::mt19937 gen(rd());
232 if constexpr (std::is_integral_v<T>) {
233 std::uniform_int_distribution<T> dist(min, max);
235 }
else if constexpr (std::is_floating_point_v<T>) {
236 std::uniform_real_distribution<T> dist(min, max);
239 static_assert(
"Unsupported type for random function");
Core Engine singleton.
Definition: engine.h:28
T * get_system()
Definition: engine.h:193
Ember_VFS VirtualFileSystem
Definition: engine.h:48
void resize_window(int w, int h)
Resize the SDL window.
Definition: engine.cpp:371
float global_volume
Definition: engine.h:45
SDL_AudioSpec spec
Definition: engine.h:44
b2WorldId get_physics_world() const
Get the created physics world.
Definition: engine.cpp:36
Renderer * get_renderer() const
Get the renderer instance.
Definition: engine.cpp:379
int bbWidth
Definition: engine.h:36
void shutdown()
Deinitialize window, renderer, and modules.
Definition: engine.cpp:289
SDL_Window * handle
Definition: engine.h:37
SDL_AudioDeviceID device_id
Definition: engine.h:43
EngineConfig Config
Definition: engine.h:40
void update(double delta_time=0)
Update all engine systems.
Definition: engine.cpp:17
TimeManager * time_manager() const
Get the time manager.
Definition: engine.cpp:387
int bbHeight
Definition: engine.h:36
Engine()
Definition: engine.cpp:365
const SDL_DisplayMode * data
Definition: engine.h:35
float width
Definition: engine.h:33
bool is_running
Definition: engine.h:50
void set_vsync(bool enabled)
Disable or enable vertical synchronization (VSync).
Definition: engine.cpp:59
InputManager * input_manager() const
Get the input manager.
Definition: engine.cpp:383
bool initialize(int width, int height, Backend type, Uint64 flags=0)
Initialize the engine: SDL window, renderer, audio, fonts.
Definition: engine.cpp:70
float height
Definition: engine.h:34
Opengl Renderer implementation.
Definition: ember_gl.h:25
Opengl Shader implementation.
Definition: shader_gl.h:18
Base class for all renderers.
Definition: ember_core.h:109
TimeManager class.
Definition: time_manager.h:11
T random(T min, T max)
Generate a random number between min and max.
Definition: engine.h:229
b2Vec2 pixels_to_world(const glm::vec2 &pixel_pos)
Convert pixel coordinates to Physics world coordinates.
Definition: engine.cpp:502
ma_engine audio_engine
Definition: engine.cpp:12
std::unique_ptr< Engine > GEngine
Definition: engine.cpp:10
constexpr float METERS_PER_PIXEL
Definition: engine.h:21
glm::vec2 world_to_pixels(const b2Vec2 &world_pos)
Convert pixel coordinates to Physics world coordinates.
Definition: engine.cpp:507
constexpr float PIXELS_PER_METER
Definition: engine.h:20
Backend
Supported rendering backends for the engine.
Definition: engine_config.h:11
Engine virtual file system.
Definition: file_system.h:43
Definition: engine_config.h:138