Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::Engine Class Reference

Singleton façade that drives the full engine lifecycle. More...

#include <Engine.h>

Public Member Functions

 Engine ()=default
 
 Engine (const Engine &)=delete
 
 Engine (Engine &&)=delete
 
Engineoperator= (const Engine &)=delete
 
Engineoperator= (Engine &&)=delete
 
bool Init (int width, int height)
 Initialise the window, OpenGL context, and subsystems.
 
void Run ()
 Enter the blocking main loop.
 
void Destroy ()
 Shut down the application and release all GL resources.
 
void SetApplication (Application *app)
 Transfer ownership of the application to the engine.
 
ApplicationGetApplication ()
 Returns a raw pointer to the active application (owned by the engine).
 
InputManagerGetInputManager ()
 Returns the InputManager that tracks keyboard and mouse state.
 
GraphicsAPIGetGraphicsAPI ()
 Returns the low-level OpenGL wrapper used for all draw calls.
 
RenderQueueGetRenderQueue ()
 Returns the per-frame command queue that batches and issues draw calls.
 
SpriteRendererGetSpriteRenderer ()
 Returns the 2D sprite/font renderer. Queue draw calls during Application::Update().
 
ParticleSystemGetParticleSystem ()
 Returns the global particle pool. Emitter components push particles via Spawn().
 
FileSystemGetFileSystem ()
 Returns the file system helper for asset-relative path resolution.
 
TextureManagerGetTextureManager ()
 Returns the TextureManager that caches loaded textures by path.
 
PhysicsManagerGetPhysicsManager ()
 
AudioManagerGetAudioManager ()
 
void SetScene (Scene *scene)
 Replace the active scene (takes ownership).
 
SceneGetScene ()
 Returns the currently active scene, or nullptr if none is set.
 
EditorGetEditor ()
 ImGui-based editor overlay.
 
RenderSettingsGetRenderSettings ()
 Mutable render settings edited by the Editor's Render panel.
 
RenderTargetGetSceneTarget ()
 Offscreen low-res render target (only active when RenderSettings::useInternalRes is true).
 
PostProcessGetPostProcess ()
 Outline / highlight post-pass; tunables exposed via the Editor render panel.
 
GLFWwindow * GetWindow ()
 
float GetTimeScale () const
 Game-time multiplier applied to deltaTime each frame (1.0 = realtime).
 
void SetTimeScale (float scale)
 
bool IsPaused () const
 When true, deltaTime is forced to 0.0 (Application::Update still runs).
 
void SetPaused (bool paused)
 
void DrawLoadingScreen (const char *message, float progress=-1.0F)
 
void UpdateLoadingProgress (float progress, const char *message)
 Update the loading panel mid-load (single swap). Cheap to call per step.
 

Static Public Member Functions

static EngineGetInstance ()
 Returns the single Engine instance (created on first call).
 

Detailed Description

Singleton façade that drives the full engine lifecycle.

Owns one instance of every major subsystem (InputManager, GraphicsAPI, RenderQueue, FileSystem, TextureManager, Scene) and the user Application. All subsystems are reachable via the Get*() accessors from anywhere in the codebase without passing references through layers.

Definition at line 64 of file Engine.h.

Constructor & Destructor Documentation

◆ Engine() [1/3]

mnd::Engine::Engine ( )
default

◆ Engine() [2/3]

mnd::Engine::Engine ( const Engine )
delete

◆ Engine() [3/3]

mnd::Engine::Engine ( Engine &&  )
delete

Member Function Documentation

◆ Destroy()

void mnd::Engine::Destroy ( )

Shut down the application and release all GL resources.

Calls Application::Destroy(), then terminates GLFW. Must be called after Run() returns to ensure clean resource cleanup.

Definition at line 382 of file Engine.cpp.

References mnd::PostProcess::Destroy(), mnd::RenderTarget::Destroy(), LOG_INFO, LOG_WARN, mnd::Editor::Shutdown(), mnd::ParticleSystem::Shutdown(), and mnd::SpriteRenderer::Shutdown().

◆ DrawLoadingScreen()

void mnd::Engine::DrawLoadingScreen ( const char *  message,
float  progress = -1.0F 
)

Render a centered loading panel with optional progress bar. Pass progress < 0 for an indeterminate (animated) bar. Performs two swaps on first call so the frame is presented before blocking work begins on platforms that delay the first present.

Definition at line 513 of file Engine.cpp.

Referenced by Init().

◆ GetApplication()

Application * mnd::Engine::GetApplication ( )

Returns a raw pointer to the active application (owned by the engine).

Definition at line 408 of file Engine.cpp.

◆ GetAudioManager()

AudioManager & mnd::Engine::GetAudioManager ( )

Definition at line 438 of file Engine.cpp.

Referenced by mnd::Audio::Load(), and mnd::AudioListenerComponent::Update().

◆ GetEditor()

Editor & mnd::Engine::GetEditor ( )
inline

ImGui-based editor overlay.

Definition at line 149 of file Engine.h.

Referenced by mnd::RenderQueue::Draw(), mnd::EditorSwallowsInput(), and mnd::PlayerControllerComponent::Update().

◆ GetFileSystem()

FileSystem & mnd::Engine::GetFileSystem ( )

Returns the file system helper for asset-relative path resolution.

Definition at line 453 of file Engine.cpp.

Referenced by mnd::ModelImporter::Import(), mnd::PostProcess::Init(), mnd::ParticleSystem::Init(), mnd::Audio::Load(), mnd::Texture::Load(), mnd::Material::Load(), mnd::Scene::Load(), and mnd::GameObject::LoadGLTF().

◆ GetGraphicsAPI()

GraphicsAPI & mnd::Engine::GetGraphicsAPI ( )

Returns the low-level OpenGL wrapper used for all draw calls.

Definition at line 418 of file Engine.cpp.

Referenced by mnd::Mesh::Mesh(), mnd::Mesh::Mesh(), mnd::ParticleSystem::Init(), mnd::Material::Load(), and mnd::ParticleSystem::Render().

◆ GetInputManager()

InputManager & mnd::Engine::GetInputManager ( )

Returns the InputManager that tracks keyboard and mouse state.

Definition at line 413 of file Engine.cpp.

Referenced by mnd::Editor::BeginFrame(), mnd::CursorPositionCallback(), mnd::KeyCallback(), mnd::MouseButtonCallback(), and mnd::PlayerControllerComponent::Update().

◆ GetInstance()

◆ GetParticleSystem()

ParticleSystem & mnd::Engine::GetParticleSystem ( )
inline

Returns the global particle pool. Emitter components push particles via Spawn().

Definition at line 127 of file Engine.h.

◆ GetPhysicsManager()

◆ GetPostProcess()

PostProcess & mnd::Engine::GetPostProcess ( )
inline

Outline / highlight post-pass; tunables exposed via the Editor render panel.

Definition at line 158 of file Engine.h.

◆ GetRenderQueue()

RenderQueue & mnd::Engine::GetRenderQueue ( )

Returns the per-frame command queue that batches and issues draw calls.

Definition at line 423 of file Engine.cpp.

Referenced by mnd::MeshComponent::Update(), and mnd::SkinnedMeshComponent::Update().

◆ GetRenderSettings()

RenderSettings & mnd::Engine::GetRenderSettings ( )
inline

Mutable render settings edited by the Editor's Render panel.

Definition at line 152 of file Engine.h.

Referenced by mnd::RenderQueue::Draw(), and mnd::PostProcess::RunOutline().

◆ GetScene()

Scene * mnd::Engine::GetScene ( )

Returns the currently active scene, or nullptr if none is set.

Definition at line 448 of file Engine.cpp.

◆ GetSceneTarget()

RenderTarget & mnd::Engine::GetSceneTarget ( )
inline

Offscreen low-res render target (only active when RenderSettings::useInternalRes is true).

Definition at line 155 of file Engine.h.

◆ GetSpriteRenderer()

SpriteRenderer & mnd::Engine::GetSpriteRenderer ( )
inline

Returns the 2D sprite/font renderer. Queue draw calls during Application::Update().

Definition at line 124 of file Engine.h.

◆ GetTextureManager()

TextureManager & mnd::Engine::GetTextureManager ( )

Returns the TextureManager that caches loaded textures by path.

Definition at line 433 of file Engine.cpp.

Referenced by mnd::ParseGLTFNode().

◆ GetTimeScale()

float mnd::Engine::GetTimeScale ( ) const
inline

Game-time multiplier applied to deltaTime each frame (1.0 = realtime).

Definition at line 163 of file Engine.h.

◆ GetWindow()

GLFWwindow * mnd::Engine::GetWindow ( )
inline

Definition at line 160 of file Engine.h.

◆ Init()

bool mnd::Engine::Init ( int  width,
int  height 
)

Initialise the window, OpenGL context, and subsystems.

Sequence: GLFW init → window create → GLFW callbacks → GLEW init → GraphicsAPI::Init()Application::Init().

Parameters
widthFramebuffer width in pixels.
heightFramebuffer height in pixels.
Returns
true on success; false if any step fails (logged to stderr).

Definition at line 65 of file Engine.cpp.

References mnd::RenderTarget::Create(), mnd::CreateOpenGLRendererBackend(), mnd::CursorPositionCallback(), DrawLoadingScreen(), mnd::AudioManager::Init(), mnd::PostProcess::Init(), mnd::PhysicsManager::Init(), mnd::ParticleSystem::Init(), mnd::SpriteRenderer::Init(), mnd::Editor::Init(), mnd::RenderSettings::internalH, mnd::RenderSettings::internalW, kDefaultWindowTitle, mnd::KeyCallback(), LOG_ERROR, LOG_INFO, mnd::MouseButtonCallback(), mnd::Scene::RegisterTypes(), UpdateLoadingProgress(), and mnd::RenderSettings::useOutline.

◆ IsPaused()

bool mnd::Engine::IsPaused ( ) const
inline

When true, deltaTime is forced to 0.0 (Application::Update still runs).

Definition at line 167 of file Engine.h.

◆ operator=() [1/2]

Engine & mnd::Engine::operator= ( const Engine )
delete

◆ operator=() [2/2]

Engine & mnd::Engine::operator= ( Engine &&  )
delete

◆ Run()

void mnd::Engine::Run ( )

Enter the blocking main loop.

Returns when the window close button is pressed or the application calls SetNeedsToBeClosed(true). See the class-level documentation for the per-frame execution order.

Definition at line 174 of file Engine.cpp.

References mnd::Editor::BeginFrame(), mnd::RenderTarget::Bind(), mnd::RenderTarget::BindDefault(), mnd::BlitNearest(), mnd::GraphicsAPI::ClearBuffers(), mnd::RenderSettings::clearColor, mnd::Color, mnd::RenderTarget::ColorTex(), mnd::RenderSettings::debugView, mnd::DecodeNrm, mnd::Depth, mnd::PostProcess::depthEdgeStrength, mnd::RenderTarget::DepthTex(), mnd::Editor::Draw(), mnd::RenderQueue::Draw(), mnd::SpriteRenderer::DrawRect(), mnd::SpriteRenderer::DrawText(), mnd::Editor::EndFrame(), mnd::CameraData::farPlane, mnd::SpriteRenderer::Flush(), mnd::InputManager::GetMousePositionCurrent(), mnd::RenderSettings::internalH, mnd::RenderSettings::internalW, mnd::PostProcess::IsValid(), mnd::RenderTarget::IsValid(), kDefaultInternalHeight, kDefaultInternalWidth, LOG_ERROR, LOG_INFO, LOG_WARN, mnd::CameraData::nearPlane, mnd::Normal, mnd::PostProcess::normalEdgeStrength, mnd::RenderTarget::NormalTex(), mnd::PostProcess::OutputTex(), mnd::RenderSettings::pixelSize, mnd::CameraData::position, mnd::CameraData::projectionMatrix, mnd::ParticleSystem::Render(), mnd::RenderTarget::Resize(), mnd::PostProcess::RunOutline(), mnd::GraphicsAPI::SetClearColor(), mnd::InputManager::SetMousePositionChanged(), mnd::InputManager::SetMousePositionOld(), mnd::RenderSettings::showFps, mnd::SplatRed, mnd::ParticleSystem::Update(), mnd::PhysicsManager::Update(), mnd::RenderSettings::useInternalRes, mnd::RenderSettings::useOutline, and mnd::CameraData::viewMatrix.

◆ SetApplication()

void mnd::Engine::SetApplication ( Application app)

Transfer ownership of the application to the engine.

Parameters
appHeap-allocated Application subclass. Engine takes ownership.

Definition at line 403 of file Engine.cpp.

◆ SetPaused()

void mnd::Engine::SetPaused ( bool  paused)
inline

Definition at line 168 of file Engine.h.

◆ SetScene()

void mnd::Engine::SetScene ( Scene scene)

Replace the active scene (takes ownership).

Parameters
sceneHeap-allocated Scene. Previous scene is destroyed.

Definition at line 428 of file Engine.cpp.

◆ SetTimeScale()

void mnd::Engine::SetTimeScale ( float  scale)
inline

Definition at line 164 of file Engine.h.

◆ UpdateLoadingProgress()

void mnd::Engine::UpdateLoadingProgress ( float  progress,
const char *  message 
)

Update the loading panel mid-load (single swap). Cheap to call per step.

Definition at line 525 of file Engine.cpp.

Referenced by Init(), and mnd::Scene::Load().


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