Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
|
Core Engine singleton. More...
#include <engine.h>
Public Member Functions | |
Engine () | |
void | resize_window (int w, int h) |
Resize the SDL window. More... | |
Renderer * | get_renderer () const |
Get the renderer instance. More... | |
InputManager * | input_manager () const |
Get the input manager. More... | |
TimeManager * | time_manager () const |
Get the time manager. More... | |
void | shutdown () |
Deinitialize window, renderer, and modules. More... | |
void | set_vsync (bool enabled) |
Disable or enable vertical synchronization (VSync). More... | |
bool | initialize (int width, int height, Backend type, Uint64 flags=0) |
Initialize the engine: SDL window, renderer, audio, fonts. More... | |
void | update (double delta_time=0) |
Update all engine systems. More... | |
b2WorldId | get_physics_world () const |
Get the created physics world. More... | |
template<typename T > | |
T * | get_system () |
Public Attributes | |
struct { | |
float width = 0 | |
float height = 0 | |
const SDL_DisplayMode * data = nullptr | |
int bbWidth = 0 | |
int bbHeight = 0 | |
SDL_Window * handle {} | |
} | Window |
EngineConfig | Config {} |
struct { | |
SDL_AudioDeviceID device_id = 0 | |
SDL_AudioSpec spec {} | |
float global_volume = 1.f | |
} | Audio |
Ember_VFS | VirtualFileSystem {} |
bool | is_running = false |
Core Engine singleton.
Manages window, renderer, audio, input, and timing systems.
Engine::Engine | ( | ) |
b2WorldId Engine::get_physics_world | ( | ) | const |
Get the created physics world.
Renderer * Engine::get_renderer | ( | ) | const |
Get the renderer instance.
T * Engine::get_system |
bool Engine::initialize | ( | int | width, |
int | height, | ||
Backend | type, | ||
Uint64 | flags = 0 |
||
) |
Initialize the engine: SDL window, renderer, audio, fonts.
width | Virtual Window width. |
height | Virtual Window height. |
type | Renderer type (OPENGL or METAL ). |
flags | SDL window flags. See: https://wiki.libsdl.org/SDL_WindowFlags |
Unset some SDL flags and set supported later.
Can have more than one display, but for now we will just use the first one
InputManager * Engine::input_manager | ( | ) | const |
Get the input manager.
void Engine::resize_window | ( | int | w, |
int | h | ||
) |
Resize the SDL window.
w | New width. |
h | New height. |
void Engine::set_vsync | ( | bool | enabled | ) |
Disable or enable vertical synchronization (VSync).
by default, VSync is disabled.
void Engine::shutdown | ( | ) |
Deinitialize window, renderer, and modules.
TimeManager * Engine::time_manager | ( | ) | const |
Get the time manager.
void Engine::update | ( | double | delta_time = 0 | ) |
Update all engine systems.
delta_time | Time elapsed since last frame (in seconds). |
struct { ... } Engine::Audio |
int Engine::bbHeight = 0 |
int Engine::bbWidth = 0 |
EngineConfig Engine::Config {} |
const SDL_DisplayMode* Engine::data = nullptr |
SDL_AudioDeviceID Engine::device_id = 0 |
float Engine::global_volume = 1.f |
SDL_Window* Engine::handle {} |
float Engine::height = 0 |
bool Engine::is_running = false |
SDL_AudioSpec Engine::spec {} |
Ember_VFS Engine::VirtualFileSystem {} |
float Engine::width = 0 |
struct { ... } Engine::Window |