|
Monad Engine da02fba2
> Undercity Codex_
|
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 | |
| Engine & | operator= (const Engine &)=delete |
| Engine & | operator= (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. | |
| Application * | GetApplication () |
| Returns a raw pointer to the active application (owned by the engine). | |
| InputManager & | GetInputManager () |
| Returns the InputManager that tracks keyboard and mouse state. | |
| GraphicsAPI & | GetGraphicsAPI () |
| Returns the low-level OpenGL wrapper used for all draw calls. | |
| RenderQueue & | GetRenderQueue () |
| Returns the per-frame command queue that batches and issues draw calls. | |
| SpriteRenderer & | GetSpriteRenderer () |
| Returns the 2D sprite/font renderer. Queue draw calls during Application::Update(). | |
| ParticleSystem & | GetParticleSystem () |
| Returns the global particle pool. Emitter components push particles via Spawn(). | |
| FileSystem & | GetFileSystem () |
| Returns the file system helper for asset-relative path resolution. | |
| TextureManager & | GetTextureManager () |
| Returns the TextureManager that caches loaded textures by path. | |
| PhysicsManager & | GetPhysicsManager () |
| AudioManager & | GetAudioManager () |
| void | SetScene (Scene *scene) |
| Replace the active scene (takes ownership). | |
| Scene * | GetScene () |
| Returns the currently active scene, or nullptr if none is set. | |
| Editor & | GetEditor () |
| ImGui-based editor overlay. | |
| RenderSettings & | GetRenderSettings () |
| Mutable render settings edited by the Editor's Render panel. | |
| RenderTarget & | GetSceneTarget () |
| Offscreen low-res render target (only active when RenderSettings::useInternalRes is true). | |
| PostProcess & | GetPostProcess () |
| 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 Engine & | GetInstance () |
| Returns the single Engine instance (created on first call). | |
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.
|
default |
|
delete |
|
delete |
| 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().
| 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().
| Application * mnd::Engine::GetApplication | ( | ) |
Returns a raw pointer to the active application (owned by the engine).
Definition at line 408 of file Engine.cpp.
| AudioManager & mnd::Engine::GetAudioManager | ( | ) |
Definition at line 438 of file Engine.cpp.
Referenced by mnd::Audio::Load(), and mnd::AudioListenerComponent::Update().
|
inline |
ImGui-based editor overlay.
Definition at line 149 of file Engine.h.
Referenced by mnd::RenderQueue::Draw(), mnd::EditorSwallowsInput(), and mnd::PlayerControllerComponent::Update().
| 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().
| 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().
| 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().
|
static |
Returns the single Engine instance (created on first call).
Definition at line 59 of file Engine.cpp.
Referenced by mnd::KinematicCharacterController::KinematicCharacterController(), mnd::Mesh::Mesh(), mnd::Mesh::Mesh(), mnd::KinematicCharacterController::~KinematicCharacterController(), mnd::RigidBody::~RigidBody(), mnd::Editor::BeginFrame(), mnd::CursorPositionCallback(), mnd::RenderQueue::Draw(), mnd::EditorSwallowsInput(), mnd::ModelImporter::Import(), mnd::PostProcess::Init(), mnd::ParticleSystem::Init(), mnd::PhysicsComponent::Init(), mnd::KeyCallback(), mnd::Audio::Load(), mnd::Texture::Load(), mnd::Material::Load(), mnd::Scene::Load(), mnd::GameObject::LoadGLTF(), mnd::MouseButtonCallback(), mnd::ParseGLTFNode(), mnd::ParticleSystem::Render(), mnd::PostProcess::RunOutline(), mnd::MeshComponent::Update(), mnd::PlayerControllerComponent::Update(), mnd::SkinnedMeshComponent::Update(), and mnd::AudioListenerComponent::Update().
|
inline |
| PhysicsManager & mnd::Engine::GetPhysicsManager | ( | ) |
Definition at line 443 of file Engine.cpp.
Referenced by mnd::KinematicCharacterController::KinematicCharacterController(), mnd::KinematicCharacterController::~KinematicCharacterController(), mnd::RigidBody::~RigidBody(), and mnd::PhysicsComponent::Init().
|
inline |
| 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().
|
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().
| Scene * mnd::Engine::GetScene | ( | ) |
Returns the currently active scene, or nullptr if none is set.
Definition at line 448 of file Engine.cpp.
|
inline |
Offscreen low-res render target (only active when RenderSettings::useInternalRes is true).
|
inline |
Returns the 2D sprite/font renderer. Queue draw calls during Application::Update().
| 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().
|
inline |
| 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().
| width | Framebuffer width in pixels. |
| height | Framebuffer height in pixels. |
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.
|
inline |
When true, deltaTime is forced to 0.0 (Application::Update still runs).
| 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.
| void mnd::Engine::SetApplication | ( | Application * | app | ) |
Transfer ownership of the application to the engine.
| app | Heap-allocated Application subclass. Engine takes ownership. |
Definition at line 403 of file Engine.cpp.
| void mnd::Engine::SetScene | ( | Scene * | scene | ) |
Replace the active scene (takes ownership).
| scene | Heap-allocated Scene. Previous scene is destroyed. |
Definition at line 428 of file Engine.cpp.
| 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().