Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
Public Member Functions | Public Attributes | List of all members
Engine Class Reference

Core Engine singleton. More...

#include <engine.h>

Public Member Functions

 Engine ()
 
void resize_window (int w, int h)
 Resize the SDL window. More...
 
Rendererget_renderer () const
 Get the renderer instance. More...
 
InputManagerinput_manager () const
 Get the input manager. More...
 
TimeManagertime_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
 

Detailed Description

Core Engine singleton.

Manages window, renderer, audio, input, and timing systems.

Constructor & Destructor Documentation

◆ Engine()

Engine::Engine ( )

Member Function Documentation

◆ get_physics_world()

b2WorldId Engine::get_physics_world ( ) const

Get the created physics world.

Returns
b2WorldId Physics world ID.

◆ get_renderer()

Renderer * Engine::get_renderer ( ) const

Get the renderer instance.

Returns
Renderer* Renderer pointer.

◆ get_system()

template<typename T >
T * Engine::get_system

◆ initialize()

bool Engine::initialize ( int  width,
int  height,
Backend  type,
Uint64  flags = 0 
)

Initialize the engine: SDL window, renderer, audio, fonts.

  • Creates Window
  • Chooses Graphics Backend (OpenGL or Metal)
  • Initializes Audio and Font subsystems
Parameters
widthVirtual Window width.
heightVirtual Window height.
typeRenderer type (OPENGL or METAL).
flagsSDL window flags. See: https://wiki.libsdl.org/SDL_WindowFlags
Returns
true on success, false on failure.
Version
0.0.1

Unset some SDL flags and set supported later.

Can have more than one display, but for now we will just use the first one

◆ input_manager()

InputManager * Engine::input_manager ( ) const

Get the input manager.

Returns
InputManager* Input manager pointer.

◆ resize_window()

void Engine::resize_window ( int  w,
int  h 
)

Resize the SDL window.

Parameters
wNew width.
hNew height.

◆ set_vsync()

void Engine::set_vsync ( bool  enabled)

Disable or enable vertical synchronization (VSync).

by default, VSync is disabled.

Version
1.0.0

◆ shutdown()

void Engine::shutdown ( )

Deinitialize window, renderer, and modules.

Version
0.0.1

◆ time_manager()

TimeManager * Engine::time_manager ( ) const

Get the time manager.

Returns
TimeManager* Time manager pointer.

◆ update()

void Engine::update ( double  delta_time = 0)

Update all engine systems.

Parameters
delta_timeTime elapsed since last frame (in seconds).
Version
0.0.1

Member Data Documentation

◆ 

struct { ... } Engine::Audio

◆ bbHeight

int Engine::bbHeight = 0

◆ bbWidth

int Engine::bbWidth = 0

◆ Config

EngineConfig Engine::Config {}

◆ data

const SDL_DisplayMode* Engine::data = nullptr

◆ device_id

SDL_AudioDeviceID Engine::device_id = 0

◆ global_volume

float Engine::global_volume = 1.f

◆ handle

SDL_Window* Engine::handle {}

◆ height

float Engine::height = 0

◆ is_running

bool Engine::is_running = false

◆ spec

SDL_AudioSpec Engine::spec {}

◆ VirtualFileSystem

Ember_VFS Engine::VirtualFileSystem {}

◆ width

float Engine::width = 0

◆ 

struct { ... } Engine::Window

The documentation for this class was generated from the following files: