A minimal SDL3 project template. Clone it, build it, and start writing your game.
Includes SDL3, SDL3_image, and SDL3_ttf via vcpkg.
| Tool | Version |
|---|---|
| CMake | 3.15+ |
| vcpkg | latest |
| GCC / Clang / MSVC | C++23 support |
Skip this if you already have it. Clone it anywhere — there is no standard location.
git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
cd ~/vcpkg
./bootstrap-vcpkg.sh # macOS / Linux
.\bootstrap-vcpkg.bat # WindowsThen add these to your shell profile (~/.zshrc, ~/.bashrc, or PowerShell $PROFILE):
export VCPKG_ROOT=~/vcpkg # update to your actual path
export CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmakesudo apt install build-essential git cmake autoconf autoconf-archive automake libtoolxcode-select --installVisual Studio 2022 with the Desktop development with C++ workload.
git clone https://github.com/yourusername/sdl3-starter-template.git
cd sdl3-starter-template
mkdir build && cd build
cmake ..
make -j$(nproc)git clone https://github.com/yourusername/sdl3-starter-template.git
cd sdl3-starter-template
mkdir build && cd build
cmake .. -G "Visual Studio 17 2022" -A x64
cmake --build . --config Releasecmake .. -G Ninja
cmake --build .vcpkg will automatically download and build SDL3, SDL3_image, and SDL3_ttf on first run. This may take a few minutes.
# Linux & macOS
./sdl3-starter-template
# Windows
.\Release\sdl3-starter-template.exesdl3-starter-template/
├── src/
│ ├── main.cpp # entry point and game loop
│ ├── window.hpp # SDLWindow class
│ └── window.cpp # SDLWindow implementation
├── vcpkg.json # dependency manifest
├── CMakeLists.txt
└── README.md
Your game loop lives in src/main.cpp:
while (!gameWindow.shouldClose()) {
gameWindow.handleEvents();
SDL_SetRenderDrawColor(gameWindow.getRenderer(), 0, 0, 0, 255);
SDL_RenderClear(gameWindow.getRenderer());
// render here
SDL_RenderPresent(gameWindow.getRenderer());
}To add source files, update CMakeLists.txt:
set(SOURCES
src/main.cpp
src/window.cpp
src/player.cpp # add yours here
)Symlink the generated compile_commands.json to the project root:
ln -s build/compile_commands.json compile_commands.jsonMIT