Turbo Engine 0.3
A C++ game engine using Allegro 5
turbo::Engine Class Referencefinal

Main engine class. More...

#include <Engine.hpp>

Collaboration diagram for turbo::Engine:

Public Member Functions

 Engine ()
 Initialize a new engine.
 ~Engine ()
void start_window (const char *win_name, unsigned short width, unsigned short height)
 Create the display, initialise the renderer (and the editor overlay when built with ImGui) and start the engine subsystems.
void stop_window ()
 Destroy the display and release the renderer.
void set_window_title (const char *title)
 Change the window title.
void set_window_size (unsigned short width, unsigned short height)
 Resize the window.
void loop ()
 Starts main loop.
void force_render ()
 Force the engine to render as soon as possible.
void force_logic ()
 Force the engine to tick as soon as possible.
void close ()
 Stops the main loop and close the window.
bool is_simulating () const
 Whether scene logic (component updates) is currently running. When false the engine still renders and processes input, but the active scene is not ticked — this is the editor "edit mode".
void set_simulating (bool value)
 Enable/disable scene logic ticking (editor Play/Pause).
script::ScriptEnginescripts () const
 The Lua scripting VM (owns the engine-API bindings).
void run_script_repl (const std::string &code)
 Run a line of Lua against the shared state (editor REPL). Thin forwarder so callers don't need the sol2 headers.
void on_update_tick ()
 Tick the active scene's logic (one fixed update step).
void on_render_tick ()
 Render the active scene (one frame).
void init_shader_library ()
 Register the built-in shader programs/materials. Requires a GL context, so it runs from start_window after the display is created.
void init_imgui ()
 Create the ImGui context, load the UI + monospace fonts and apply the theme. No-op when built without ImGui.
 ONLYIMGUI (editor::Editor editor=editor::Editor(this))

Public Attributes

SceneManager scene_manager
 Owns the registered scenes and the active scene.
ShaderLibrary shaders
 Engine-wide registry of shader programs and materials. Populated once the GL context exists (see start_window).
Event update_tick = Event<>()
 Fired on every logic tick; subscribe to run game logic.
Event render_tick = Event<>()
 Fired on every rendered frame; subscribe to draw.
Logger logger = Logger("Turbo Engine")
 Engine-wide logger.

Static Public Attributes

static const std::string version = "0.3"
 Engine version.
static Engineengine = nullptr
 The active engine instance (set in the constructor).
static Input input = Input()
 Global keyboard/mouse input state.

Detailed Description

Main engine class.

Constructor & Destructor Documentation

◆ Engine()

turbo::Engine::Engine ( )

Initialize a new engine.

Note
Only one instance should be used at a time
Parameters
win_nameName of the window
widthwidth of the window
heightheight of the window

◆ ~Engine()

turbo::Engine::~Engine ( )

Member Function Documentation

◆ close()

void turbo::Engine::close ( )

Stops the main loop and close the window.

◆ force_logic()

void turbo::Engine::force_logic ( )

Force the engine to tick as soon as possible.

◆ force_render()

void turbo::Engine::force_render ( )

Force the engine to render as soon as possible.

◆ init_imgui()

void turbo::Engine::init_imgui ( )

Create the ImGui context, load the UI + monospace fonts and apply the theme. No-op when built without ImGui.

◆ init_shader_library()

void turbo::Engine::init_shader_library ( )

Register the built-in shader programs/materials. Requires a GL context, so it runs from start_window after the display is created.

◆ is_simulating()

bool turbo::Engine::is_simulating ( ) const
inline

Whether scene logic (component updates) is currently running. When false the engine still renders and processes input, but the active scene is not ticked — this is the editor "edit mode".

◆ loop()

void turbo::Engine::loop ( )

Starts main loop.

◆ on_render_tick()

void turbo::Engine::on_render_tick ( )

Render the active scene (one frame).

◆ on_update_tick()

void turbo::Engine::on_update_tick ( )

Tick the active scene's logic (one fixed update step).

◆ ONLYIMGUI()

turbo::Engine::ONLYIMGUI ( editor::Editor editor = editor::Editor(this))

◆ run_script_repl()

void turbo::Engine::run_script_repl ( const std::string & code)

Run a line of Lua against the shared state (editor REPL). Thin forwarder so callers don't need the sol2 headers.

◆ scripts()

script::ScriptEngine * turbo::Engine::scripts ( ) const
inline

The Lua scripting VM (owns the engine-API bindings).

◆ set_simulating()

void turbo::Engine::set_simulating ( bool value)
inline

Enable/disable scene logic ticking (editor Play/Pause).

◆ set_window_size()

void turbo::Engine::set_window_size ( unsigned short width,
unsigned short height )

Resize the window.

◆ set_window_title()

void turbo::Engine::set_window_title ( const char * title)

Change the window title.

◆ start_window()

void turbo::Engine::start_window ( const char * win_name,
unsigned short width,
unsigned short height )

Create the display, initialise the renderer (and the editor overlay when built with ImGui) and start the engine subsystems.

Parameters
win_namewindow title
widthwindow width in pixels
heightwindow height in pixels

◆ stop_window()

void turbo::Engine::stop_window ( )

Destroy the display and release the renderer.

Member Data Documentation

◆ engine

Engine* turbo::Engine::engine = nullptr
inlinestatic

The active engine instance (set in the constructor).

◆ input

Input turbo::Engine::input = Input()
inlinestatic

Global keyboard/mouse input state.

◆ logger

Logger turbo::Engine::logger = Logger("Turbo Engine")

Engine-wide logger.

◆ render_tick

Event turbo::Engine::render_tick = Event<>()

Fired on every rendered frame; subscribe to draw.

◆ scene_manager

SceneManager turbo::Engine::scene_manager

Owns the registered scenes and the active scene.

◆ shaders

ShaderLibrary turbo::Engine::shaders

Engine-wide registry of shader programs and materials. Populated once the GL context exists (see start_window).

◆ update_tick

Event turbo::Engine::update_tick = Event<>()

Fired on every logic tick; subscribe to run game logic.

◆ version

const std::string turbo::Engine::version = "0.3"
inlinestatic

Engine version.

Note
This string is hard writter read only

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