How luiscrespo-bot/antigravity-game-engine works
1. Top-level shape
- This repo is split into two clear layers: engine/ is the reusable runtime library, and game/ is the client application entry point.
- The architecture is intentionally modular: each subsystem lives in its own module and communicates through engine-level interfaces rather than directly through the game code.
2. Bootstrapping and lifetime
- game/src/main.cpp is the application entry.
- It likely constructs or invokes the engine Application layer, which owns the main loop and coordinates startup/shutdown of the other systems.
- The engine’s lifetime boundary is centered around the Application class and the Window/graphics context it manages.
3. Core runtime
- The core module provides the engine’s foundational services: Application, Window, Input, Log, Timestep, and ResourceManager.
- Timestep indicates a fixed/variable update model.
- Input is a static-style facade over GLFW-style input handling, so gameplay and tools can query input without depending on windowing details.
- ResourceManager is the central asset boundary to avoid duplicated loads and to share resources across renderer, scene, and gameplay systems.
4. Rendering stack
- The renderer module contains the OpenGL rendering pipeline and its abstractions: GraphicsContext, OpenGLContext, Shader/OpenGLShader, Framebuffer, Mesh, Model, Camera, PerspectiveCamera, Light, Material, and Renderer.
- Data flow is: scene/game objects provide renderable meshes/materials and camera state, then Renderer turns that into OpenGL draw calls.
- Framebuffer suggests offscreen passes such as shadow maps or render targets.
- Model and Mesh indicate imported asset rendering, with Assimp handling external model formats.
5. Scene and entity organization
- scene contains Scene and SceneManager, which act as the boundary between engine systems and actual world content.
- entity/Entity.h implies the world is entity-centric, with entities being the common unit passed to physics, scripting, UI inspection, and rendering.
- The scene layer is where engine systems are coordinated per world or level.
6. Physics
- physics/PhysicsSystem is a separate subsystem, suggesting simulation is not embedded inside rendering or scene code.
- It likely consumes entity transform/collision data from the scene and writes back updated positions or collision state.
- This keeps simulation independent from frame rendering, which matters for fixed-step updates.
7. Scripting
- scripting/ScriptSystem is the Lua integration point, backed by sol2 per the README.
- Its role is to attach behavior to entities without recompiling C++, so gameplay logic can be extended dynamically.
- The script system likely bridges engine objects into Lua and is another consumer/producer of entity state.
8. UI and editor tooling
- ui/UISystem wraps Dear ImGui and provides in-engine tooling such as inspectors, light editors, and debug panels.
- UI is an overlay system: it reads engine state, but should not own it.
- The README’s docking/viewports support implies the UI runs as an editor-like layer on top of the main rendered scene.
9. Audio
- audio/AudioSystem is isolated from rendering and scene management, using miniaudio for playback.
- Its separation indicates audio is treated as its own runtime service rather than as part of gameplay logic or UI.
- In practice, it likely consumes events or entity-related triggers from the scene/game layer.
10. Platform and graphics dependencies
- The architecture is anchored on C++20, CMake, GLFW, GLAD, GLM, OpenGL 4.1, ImGui, Lua 5.4, sol2, miniaudio, Assimp, and spdlog.
- GLFW/GLAD/OpenGL define the runtime graphics boundary; GLM provides math types used across camera, renderer, and physics.
- spdlog is the shared observability layer for the whole engine.
11. Subsystem interaction pattern
- The engine is organized as a set of independent services updated from the main loop: input, scripting, physics, audio, scene updates, UI, and rendering.
- The main directional flow is from application startup → scene/world state update → render/audio/UI output.
- Cross-system coupling is minimized by using engine abstractions like Entity, Scene, ResourceManager, and the render/shader interfaces.
12. Build and packaging boundary
- CMake drives the build, and the GitHub workflow suggests multi-platform CI for the engine library and game executable.
- The engine is intended to be consumed as a local library by the game target rather than as a standalone product.
- For an architecture diagram, the most important separation is: game supplies content and entry point; engine supplies the runtime services and subsystem orchestration.
Main entry points: Application.h Application · Scene.h Scene · Renderer.h Renderer · UISystem.h UI
Components 18
Game
Application entry point and content-side bootstrap.
- Main · Starts the game executable and hands control to the engine.
game/src/main.cpp
Engine Core
Lifetime, platform, and shared services.
- Application · Owns startup, main loop, and subsystem coordination.
engine/src/core/Application.h - Window · Creates and manages the graphics/windowing boundary.
engine/src/core/Window.h - Input · Global input queries over the active window and backend.
engine/src/core/Input.h - Log · Shared logging and diagnostics for the engine.
engine/src/core/Log.h - Resources · Central asset loading and sharing boundary.
engine/src/core/ResourceManager.h
Engine Runtime
World management and major runtime subsystems.
- Scene Manager · Switches and manages active scenes or levels.
engine/src/scene/SceneManager.h - Scene · Owns the active world and coordinates per-frame systems.
engine/src/scene/Scene.h - Entity · Common unit shared across gameplay, rendering, and tools.
engine/src/entity/Entity.h - Renderer · Converts scene state into OpenGL draw work.
engine/src/renderer/Renderer.h - GL Context · Initializes the OpenGL runtime and device context.
engine/src/renderer/OpenGLContext.h - Shaders · Loads and manages shader program objects.
engine/src/renderer/Shader.h - Models · Imports and stores mesh/model geometry for rendering.
engine/src/renderer/Model.h - Camera · Defines the view and projection used by rendering.
engine/src/renderer/Camera.h - Physics · Updates simulation state independently of rendering.
engine/src/physics/PhysicsSystem.h - Scripting · Binds engine objects into Lua-driven gameplay behavior.
engine/src/scripting/ScriptSystem.h - UI · ImGui-based in-engine tools and debug overlays.
engine/src/ui/UISystem.h - Audio · Plays and manages audio through the audio backend.
engine/src/audio/AudioSystem.h
Connections 27
- Main → Application: bootstraps · The executable enters through the engine application layer.
- Application → Window: owns · Application creates and drives the window and context boundary.
- Application → Input: polls · Main-loop updates query input state through the core facade.
- Application → Log: reports · Startup and runtime diagnostics flow through logging.
- Application → Resources: shares assets · Application exposes centralized resource loading to subsystems.
- Application → Scene Manager: runs world · Application hands control to scene management and update flow.
- Application → Renderer: drives render · Application schedules the frame rendering path.
- Application → Physics: ticks sim · Application advances fixed-step simulation.
- Application → Scripting: ticks scripts · Application updates Lua gameplay logic.
- Application → UI: updates ui · Application runs the editor/debug overlay.
- Application → Audio: updates audio · Application advances audio playback and events.
- Scene Manager → Scene: activates · Scene manager owns the currently active scene.
- Scene → Entity: contains · Scenes organize the world as entities.
- Scene → Renderer: provides view · Scenes supply renderable world state to the renderer.
- Scene → Physics: feeds state · Physics consumes transforms and collision-relevant entity data.
- Scene → Scripting: binds gameplay · Scripts attach behavior to scene entities.
- Renderer → GL Context: uses · Renderer executes against the OpenGL backend.
- Renderer → Shaders: binds · Rendering relies on shader programs.
- Renderer → Models: draws · Renderer consumes imported model and mesh data.
- Renderer → Camera: views · Camera state defines the active render perspective.
- Models → Resources: loads from · Models are retrieved through the shared asset cache.
- Shaders → Resources: loads from · Shaders are also managed through the resource boundary.
- Physics → Entity: updates · Physics writes back motion and simulation results on entities.
- Scripting → Entity: controls · Lua scripts operate on entities and gameplay state.
- UI → Scene: inspects · UI overlays read scene state for tools and inspection.
- UI → Renderer: overlays · UI is composited on top of the rendered frame.
- Audio → Scene: reacts to · Audio is driven by scene or gameplay events.