I started gamedev in 2020 with a straightforward goal: to catalog most of the techniques used in game development as small, readable C++ samples. The repository has since grown into a practical reference for graphics and audio programming across OpenGL 4, Direct3D 11, Direct3D 12, Metal 3, Vulkan 1, and OpenAL 1.
The samples progress from window creation and basic primitives through model loading, camera control, text rendering, sprites, animation, scripting, networking, pathfinding, physics, particles, terrain, oceans, lighting, shadows, PBR, and post-processing to modern forward and deferred lighting techniques. This is a collection of samples rather than an engine: each directory isolates one subject so that the implementation and API-specific details are easy to inspect.
I have kept abstractions to a minimum wherever possible. Some code is deliberately duplicated to keep each sample as self-contained as possible. Every sample depends on its backend's base library (the 000 or 00 directory). To use a sample independently, simply copy the base library files along with the sample's own files.
The graphics samples have been tested on Windows 11, Fedora 39, and macOS Sonoma with NVIDIA GeForce RTX 4090, AMD Radeon™ RX 6900 XT, and Intel® UHD Graphics 770 GPUs.
Contributions that improve the existing code or add new samples are very welcome. Please do not submit code that was generated entirely by AI or that has not been carefully reviewed by a human.
| Backend | Platform |
|---|---|
| OpenGL 4 | Windows, Linux, macOS |
| Direct3D 11 | Windows |
| Direct3D 12 | Windows |
| Metal 3 | macOS |
| Vulkan 1 | Windows, Linux, macOS |
| OpenAL 1 | Windows, Linux, macOS |
The project uses CMake 3.14 or later and requires a compiler that supports C++17. Most third-party libraries are included in the repository. Install the platform SDKs and shader tools required by the backends you want to build; CMake adds only the graphics backends available on the current system.
The default build type for single-configuration generators is Release. The entire project can be configured and built with:
git clone --recursive https://github.com/arabasso/gamedev.git
cmake -S gamedev -B gamedev/build
cmake --build gamedev/build --config Release --parallelEach sample also has a separate CMake target. Target suffixes identify the backend: _gl4, _d3d11, _d3d12, _mtl, _vk1, and _al1. For example:
cmake --build gamedev/build --config Release --target 005_triangle_gl4Shader sources can be selected at configuration time. Native shader languages remain the defaults, while Slang provides a common alternative across all graphics APIs. Vulkan can also compile HLSL to SPIR-V.
| CMake option | Default | Supported values | Additional tools |
|---|---|---|---|
OPENGL_SHADER_BACKEND |
glsl |
glsl, slang |
Slang uses slangc and spirv-cross |
DIRECT3D11_SHADER_BACKEND |
hlsl |
hlsl, slang |
Slang uses slangc |
DIRECT3D12_SHADER_BACKEND |
hlsl |
hlsl, slang |
Slang uses slangc |
VULKAN_SHADER_BACKEND |
glsl |
glsl, hlsl, slang |
GLSL uses glslc, HLSL uses dxc, and Slang uses slangc |
METAL_SHADER_BACKEND |
metal |
metal, slang |
Slang uses slangc |
METAL_SHADER_MODE |
metallib |
metal, metallib |
metallib uses the Apple command-line tools |
For Metal, METAL_SHADER_MODE=metal retains shader sources for runtime compilation, while metallib builds shader libraries ahead of time.
The selected command-line tools must be available on PATH. Useful sources are the Vulkan SDK, Slang releases, DirectX Shader Compiler, and SPIRV-Cross.
All graphics samples support all available shader backends.
Options can be combined in the same build tree:
cmake -S gamedev -B gamedev/build \
-DOPENGL_SHADER_BACKEND=slang \
-DVULKAN_SHADER_BACKEND=hlsl
cmake --build gamedev/build --config Release --parallelInstall Visual Studio 2022 or its Build Tools with the Desktop development with C++ workload, plus CMake. Install the Vulkan SDK when building the Vulkan samples.
git clone --recursive https://github.com/arabasso/gamedev.git
cmake -S gamedev -B gamedev/build
cmake --build gamedev/build --config Release --parallelInstall a C++ toolchain, CMake, and the OpenGL and window-system development packages. When building the Vulkan samples, also install the Vulkan development packages.
sudo apt install -y git g++ make cmake libvulkan-dev glslc zlib1g-dev pkg-config libgl1-mesa-dev \
libasound2-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libxext-dev libxrandr-dev \
libxinerama-dev libxcursor-dev libxi-dev libxtst-dev libxss-dev
git clone --recursive https://github.com/arabasso/gamedev.git
cmake -S gamedev -B gamedev/build
cmake --build gamedev/build --parallelsudo dnf install -y git gcc-c++ make cmake vulkan-loader-devel glslc \
mesa-libGL-devel alsa-lib-devel libXext-devel wayland-devel libdecor-devel \
libxkbcommon-devel libXrandr-devel libXinerama-devel libXcursor-devel \
libXi-devel libXtst-devel libXScrnSaver-devel
git clone --recursive https://github.com/arabasso/gamedev.git
cmake -S gamedev -B gamedev/build
cmake --build gamedev/build --parallelInstall Xcode and CMake. Install the Vulkan SDK when building the Vulkan samples. Xcode supplies the tools used to compile Metal shaders and metallib files.
git clone --recursive https://github.com/arabasso/gamedev.git
cmake -S gamedev -B gamedev/build
cmake --build gamedev/build --config Release --parallel- Programming guide for Direct3D 11
- Braynzar Soft Tutorials
- DirectXTutorial
- ChiliTomatoNoodle - C++ 3D DirectX Programming
- PardCode - C++ 3D Game Tutorial Series From Scratch
- Xbox-ATG-Samples
- Direct3D 12 programming guide
- Braynzar Soft Tutorials
- ChiliTomatoNoodle - Direct3D 12 Shallow Dive
- DirectX-Graphics-Samples
- Xbox-ATG-Samples
- Lötwig Fusel - D3D12 Beginners Tutorial
- Khronos OpenGL overview
- Learn OpenGL
- OGL Dev
- Victor Gordan - OpenGL Tutorials
- thecplusplusguy - GLSL tutorials
- opengl-tutorial
- Khronos Vulkan overview
- Khronos Vulkan Guide
- Vulkan Tutorial
- Vulkan Guide
- Brendan Galea - Vulkan (c++) Game Engine Tutorials
- GetIntoGameDev - Vulkan
- Sascha Willems - Vulkan C++ examples and demos
- Khronos Vulkan Samples
I develop and maintain this project in my spare time. If it has been useful to you, you can support continued work on samples, fixes, and documentation through one of these channels:
- PIX:
934a7c95-66cf-4286-b01f-eb403401a292 - PayPal
- GitHub Sponsors
- Buy Me a Coffee
- Patreon