-
Notifications
You must be signed in to change notification settings - Fork 2
Engine Architecture Overview
A recommended reading order for getting up to speed on the Gondwana engine codebase quickly.
README.md — Read the whole thing (~5 min). It explains the engine's philosophy (dirty-region rendering, world-space first, code-first design), the runtime flow, and lists all namespaces with their responsibilities. This is the best single document in the repo.
Gondwana.Hosting/GameHostBase.cs — The abstract base class for all games. Only ~260 lines, well-documented, and shows the exact lifecycle of a game:
Initialize()
→ ConfigureLogging → InitializeEngine → ConfigurePlatform → ConfigureInput
→ LoadContent → CreateSceneGraph → BindScene → InitializeSceneObjects
→ StartEngine
This tells you every extension point a game author uses before looking at any game-specific code.
Demos/Spot/SpotGameHost.cs + Demos/Spot/GameWindow.cs — This is the most complete working game in the repo. Read SpotGameHost to see how a real game wires up assets, scene layers, tilesheets, sprites, audio, input, and particle systems. It subclasses WinFormsGameHost, so you also see a concrete platform adapter in practice.
Gondwana/Engine.cs — The singleton engine. Read the event declarations (~lines 76–210) to understand the hooks (BeforeBackgroundTasksExecute, BeforeFrameRender, AfterFrameRender, etc.), then skim DoBackgroundTasks and DoForegroundTasks to see what happens every cycle.
Concurrency note:
Engine.Startruns the main loop (Cycle/DoForegroundTasks) on a backgroundTask, not the UI thread.
-
Gondwana/Rendering/RefreshQueue.cs(~95 lines) — The core dirty-region mechanism. Everything that changes enqueues a world-pixel rectangle here. Short, well-commented, and critical to understand. -
Gondwana/Rendering/Views/View.cs—View= Camera + Viewport. Read the coordinate-conversion methods (ScreenPxToWorldPx,WorldPxToScreenPx,WorldRectToScreenRect, etc.) — this is the math that connects world-space to screen-space. Understanding this file means understanding the rendering model. -
Gondwana/Rendering/Views/Camera.cs+Viewport.cs— Skim afterView.csto understand camera position/clamping and viewport zoom/offset.
Gondwana/Scenes/SceneLayer.cs — The primary data structure for game content. A SceneLayer is a grid of tiles with its own coordinate system, parallax factor, and RefreshQueue. Understanding this explains how sprites, tiles, and parallax backgrounds coexist.
| File/Namespace | What it covers |
|---|---|
Gondwana/Drawing/Direct/DirectDrawingManager.cs |
Thread-safe manager for overlay drawables (HUD, particles, text) |
Gondwana/Drawing/Sprites/ |
How sprites attach to scene layers and are positioned in world-space |
Gondwana/Drawing/Tilesheets/ |
How image atlases are defined and how sprites reference frame regions |
Gondwana.WinForms/Rendering/ — Only read if you're working on the host layer. Shows how a WinForms control wraps the SkiaSharp backbuffer and wires up paint/resize events.
GameHostBase
└─ Engine (singleton, loop)
├─ Scene
│ └─ SceneLayer (grid + parallax + RefreshQueue)
│ └─ SceneLayerTile → Sprite → Tilesheet frame
├─ ViewManager
│ └─ View (Camera + Viewport) ← world↔screen math lives here
├─ DirectDrawingManager ← HUD/overlays (not in scene grid)
├─ Input (Keyboard / Mouse / Gamepad)
└─ Timers / Collisions
The key insight: state changes call RefreshQueue.AddWorldRect() → the engine's render pass picks it up → View transforms the world rect to screen-space → the platform host repaints only that screen region.