Game Engine Architecture Intro
A game engine is the part of a game that is not about this particular game. It opens the window, reads the gamepad, keeps time, loads textures from disk, decides which objects to draw and in which order, runs physics, mixes sound and gives designers a way to build levels. The game itself (the rules, the levels, the feel) sits on top.
This course shows how those pieces are built and how they fit together, in modern C++. You will write small, runnable versions of the core systems (the loop, allocators, an entity-component system, a job system, a resource cache, a scene graph, a render graph) and read real setup code for the libraries that professional engines use for the rest: SDL3, OpenGL, sokol, Vulkan, EnTT, flecs, Jolt Physics, miniaudio, sol2, Dear ImGui and Tracy.
Note: You do not need to write an engine to make a game. Unity, Unreal and Godot are better than anything one person can build in a year. Learn this material if engine programming is your goal, if you want to understand what your engine does under the hood, or if you work on an engine team. The Field Notes section returns to this point.
What you will learn
| Section | The question it answers |
|---|---|
| Getting Started | Which layers does an engine have, and who may call whom? |
| Core | How does the frame loop keep time? How do we log, assert, configure and identify things? How does the platform layer talk to the OS? |
| Memory | Who owns what? How do allocators, handles and cache-friendly layouts keep frames fast and safe? |
| ECS and data-oriented design | How do we store thousands of entities so systems can iterate them quickly? |
| Multithreading | How do we spread a frame over many cores without data races? |
| Resources | How are assets loaded, shared, reloaded and saved? |
| Rendering layer | How does the engine turn a scene into GPU work: command buffers, render graphs, OpenGL, sokol, bgfx, Vulkan? |
| Subsystems | How are physics, audio, scripting, tools and profiling plugged in? |
| Toolkit and Field notes | Which build tools, debuggers and profilers to use, and the advice engine programmers learn the hard way. |
| Mini Project | A tiny engine built in stages: window, triangle, camera, mesh, lighting, ECS, playable demo. |
How the examples work
The runnable examples are C++20, compiled with g++ and run on Compiler Explorer when you press ▶ Run. They are complete programs with no third-party libraries, so each one models one engine idea in under a hundred lines. A real engine needs a window and a GPU, which a playground cannot provide, so code that uses SDL3, OpenGL or Vulkan appears in normal code blocks without a Run button. Wherever it helps, a runnable model of the same idea sits next to it.
Examples never read the real clock. A game loop driven by a wall clock prints different numbers on every run, so our loops use a simulated clock: a list of frame durations chosen in advance. This is also a good habit for real engines, because a loop that can be driven by a fake clock can be tested and replayed.
Here is the smallest possible "engine": a loop, a fixed simulation step and a game object, driven by made-up frame times.
#include <cstdio>
#include <vector>
struct Ball { double y = 10.0, vy = 0.0; };
int main() {
const double step = 0.1; // simulation step in seconds
std::vector<double> frameTimes{0.1, 0.25, 0.05, 0.1}; // what a real clock might report
Ball ball;
double accumulator = 0.0;
int frame = 0;
for (double dt : frameTimes) {
accumulator += dt;
int steps = 0;
while (accumulator >= step - 1e-9) { // run as many fixed steps as fit
ball.vy -= 9.8 * step;
ball.y += ball.vy * step;
accumulator -= step;
steps++;
}
std::printf("frame %d: dt=%.2f steps=%d y=%.3f\n", ++frame, dt, steps, ball.y);
}
}frame 1: dt=0.10 steps=1 y=9.902
frame 2: dt=0.25 steps=2 y=9.412
frame 3: dt=0.05 steps=1 y=9.020
frame 4: dt=0.10 steps=1 y=8.530
The next lessons turn each line of that program into a subsystem: the clock becomes a platform timer, Ball becomes components in an ECS, printf becomes a renderer.
The libraries we use
| Job | Library in this course | Runnable model in this course |
|---|---|---|
| Window, input, timers | SDL3 (GLFW as an alternative) | input mapping |
| Rendering | OpenGL 3.3 via glad, sokol_gfx, bgfx, Vulkan with vk-bootstrap and VMA | command buffer, render graph |
| Entities | EnTT, flecs | sparse-set ECS, archetype ECS |
| Physics | Jolt Physics | fixed-step bridge |
| Audio | miniaudio | mixer |
| Scripting | Lua through sol2 | command interpreter |
| Tools | Dear ImGui | immediate-mode UI |
| Profiling | Tracy | profiler scopes |
| Build | CMake + vcpkg or Conan | – |
Prerequisites
You should be comfortable with C++ classes, templates, lambdas, std::vector, std::unique_ptr and move semantics: the C++ course covers all of them, especially Smart Pointers and Move Semantics. The math (vectors, matrices, transform hierarchies) is in Math for Games. Shader code is taught in Shaders & Graphics Programming and physics solvers in Game Physics & Animation; this course plugs those systems into an engine instead of re-teaching them. If you have never made a game at all, start with Game Development Roadmap & Fundamentals.
Test yourself
Which of these belongs in the engine rather than in the game?
- The rule that three coins give an extra life
- Loading a texture file into GPU memory
- The layout of level 3
- The boss's attack pattern
Why do the runnable examples use a simulated clock?
- Compiler Explorer has no clock
- So the output is the same on every run and the loop can be tested and replayed
- Simulated clocks are faster
- Real engines never read the clock
In the first example, why does frame 2 (dt = 0.25) run more fixed steps than frame 1?
- The ball moves faster
- More time passed, so more 0.1 s steps fit into the accumulator
- The step size changes
- The loop skips frames