4.6 KiB
SDL3CPlusPlus
A minimal SDL3 + Vulkan spinning cube demo.
Build
-
Dependencies
- Install or update Conan 2.x.
- Run:
so Conan pulls in
conan profile detect conan install . -of build -b missing -s compiler=msvc -s compiler.version=194 -s compiler.cppstd=17 -c tools.cmake.cmaketoolchain:generator="Visual Studio 17 2022"lua, SDL3, Vulkan, and the rest of the graph defined inconanfile.py.
-
Configure
- Default (Visual Studio):
cmake -B build -S .- This uses the Visual Studio 2022 generator.
- Ninja (clang/MinGW): configure into a clean folder, e.g.,
cmake -G Ninja -B build-ninja -S .- CMake already appends
C:\ProgramData\chocolatey\bintoCMAKE_PROGRAM_PATH, so Ninja and Chocolatey LLVM tools are discoverable without extraPATHedits. - Ninja is a single-config generator. When no multi-config generator has been used, the project defaults
CMAKE_BUILD_TYPE=Release; override it with-DCMAKE_BUILD_TYPE=Debugif you need another configuration in that folder.
- CMake already appends
- Ninja with MSVC: open a Developer Command Prompt (call
"%VSINSTALLDIR%VC\\Auxiliary\\Build\\vcvarsall.bat" x64or run that batch file from PowerShell) and configure withKeep using the same prompt (socmake -G Ninja -B build-ninja-msvc -S . -DCMAKE_BUILD_TYPE=Releasecl.execarries the SDK/CRT paths) and build withcmake --build build-ninja-msvc --config Release.- Quick one-liner that initializes the MSVC environment and runs the Release build from a regular shell:
When you run the command from PowerShell wrap the
cmd /c "call \"%VSINSTALLDIR%VC\Auxiliary\Build\vcvarsall.bat\" x64 && cmake --build build-ninja-msvc --config Release"cmdinvocation in single quotes so the embedded double quotes stay intact:cmd /c 'call "%VSINSTALLDIR%VC\Auxiliary\Build\vcvarsall.bat" x64 && cmake --build build-ninja-msvc --config Release'
- Quick one-liner that initializes the MSVC environment and runs the Release build from a regular shell:
- Optional clang-tidy: add
-DENABLE_CLANG_TIDY=ON- CMake searches both
C:\Program Files\LLVM\binandC:\ProgramData\chocolatey\bin, so standard LLVM/Chocolatey installs are found automatically. - The wrapped clang-tidy binary prints
[clang-tidy] starting .and[clang-tidy] finished (exit .)markers so you can spot linting in verbose logs even when no diagnostics appear.
- CMake searches both
- Default (Visual Studio):
-
Build
cmake --build build --config Release --target sdl3_app(or point atbuild-ninjaif you used Ninja).- Shaders land in
build/shadersorbuild-ninja/shaders, so the executable can loadcube.{vert,frag}.spv.
Run
cmake --build build --target spinning_cube
./build/spinning_cube
If you rely on the Conan runtime environment (some dependencies export env vars), source build/conanrun.sh on Linux/macOS or run build\\conanrun.bat on Windows before launching the binary.
Runtime configuration
main.cppnow uses a JSON-driven entrypoint.- Pass
sdl3_app --json-file-in <path>to load runtime settings such as the Lua script path, window size, andlua_debug. - The loader enforces valid types and resolves relative scripts next to the configuration file.
- Pass
- Generate a starter JSON with the shipped script locations:
The helper assumes
sdl3_app --create-seed-json config/seed_runtime.jsonscripts/cube_logic.lualives beside the executable and writes normalized paths. - Store or override the app-wide config with
sdl3_app --set-default-json [path].- Windows uses
%APPDATA%/sdl3cpp; other platforms use$XDG_CONFIG_HOME/sdl3cpp/default_runtime.json, falling back to~/.config/sdl3cpp. - Providing a
pathduplicates that JSON into the platform default without editing the runtime values. - When the default file exists the executable reads it automatically; otherwise it falls back to the built-in script discovery logic.
- Windows uses
GUI Demo
scripts/gui_demo.lua shows off the Lua GUI framework (buttons, text boxes, list views, and SVG icons) rendered on top of the Vulkan scene. Launch it with ./build/sdl3_app --json-file-in config/gui_runtime.json (or use that config via sdl3_app --set-default-json) to run the interactive overlay in the window.
Dependency automation
This project ships a renovate.json configuration so Renovate can open PRs that bump the Conan packages listed in conanfile.py. Either install Renovate locally (npm install -g renovate or npx renovate) and run it from the repo root, or enable the Renovate bot on your GitHub/GitLab install to pick up the configuration automatically.