mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-24 13:44:58 +00:00
cleanup
This commit is contained in:
14
.clang-tidy
Normal file
14
.clang-tidy
Normal file
@@ -0,0 +1,14 @@
|
||||
Checks: >
|
||||
clang-analyzer-*,
|
||||
bugprone-*,
|
||||
performance-*,
|
||||
readability-*,
|
||||
modernize-*,
|
||||
misc-*,
|
||||
-modernize-use-trailing-return-type
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: 'src/.*'
|
||||
FormatStyle: file
|
||||
CheckOptions:
|
||||
- key: modernize-use-override.ForceOverride
|
||||
value: 1
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -45,3 +45,12 @@ venv/
|
||||
env/
|
||||
vendor/
|
||||
build/
|
||||
build-*/
|
||||
dist/
|
||||
*.egg-info/
|
||||
.eggs/
|
||||
.pytest_cache/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
|
||||
@@ -1,5 +1,47 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(SDL3App LANGUAGES CXX)
|
||||
list(APPEND CMAKE_PROGRAM_PATH "C:/ProgramData/chocolatey/bin")
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build configuration for single-config generators" FORCE)
|
||||
endif()
|
||||
option(ENABLE_CLANG_TIDY "Automatically run clang-tidy on every target when configuring via CMake" OFF)
|
||||
|
||||
if(ENABLE_CLANG_TIDY)
|
||||
find_program(CLANG_TIDY_EXE
|
||||
NAMES clang-tidy clang-tidy.exe
|
||||
HINTS "C:/Program Files/LLVM/bin" "C:/ProgramData/chocolatey/bin"
|
||||
)
|
||||
if(CLANG_TIDY_EXE)
|
||||
if(WIN32)
|
||||
set(CLANG_TIDY_WRAPPER "${CMAKE_CURRENT_BINARY_DIR}/clang_tidy_wrapper.bat")
|
||||
file(WRITE ${CLANG_TIDY_WRAPPER}
|
||||
"@echo off\n"
|
||||
"setlocal\n"
|
||||
"set \"CLANG_TIDY_EXE=${CLANG_TIDY_EXE}\"\n"
|
||||
"echo [clang-tidy] starting %*\n"
|
||||
"\"%CLANG_TIDY_EXE%\" %*\n"
|
||||
"set RET=%ERRORLEVEL%\n"
|
||||
"echo [clang-tidy] finished (exit %RET%)\n"
|
||||
"exit /b %RET%\n"
|
||||
)
|
||||
else()
|
||||
set(CLANG_TIDY_WRAPPER "${CMAKE_CURRENT_BINARY_DIR}/clang_tidy_wrapper.sh")
|
||||
file(WRITE ${CLANG_TIDY_WRAPPER}
|
||||
"#!/bin/sh\n"
|
||||
"echo \"[clang-tidy] starting $@\"\n"
|
||||
"\"${CLANG_TIDY_EXE}\" \"$@\"\n"
|
||||
"ret=$?\n"
|
||||
"echo \"[clang-tidy] finished (exit $ret)\"\n"
|
||||
"exit $ret\n"
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E chmod +x ${CLANG_TIDY_WRAPPER})
|
||||
endif()
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CLANG_TIDY_WRAPPER})
|
||||
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_WRAPPER}")
|
||||
else()
|
||||
message(WARNING "clang-tidy requested but not found on the PATH; disabling lint step")
|
||||
endif()
|
||||
endif()
|
||||
option(BUILD_SDL3_APP "Build the SDL3 Vulkan demo" ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/CMakePresets.json"
|
||||
"build/CMakePresets.json",
|
||||
"build-ninja/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
44
README.md
44
README.md
@@ -3,22 +3,28 @@ A minimal SDL3 + Vulkan spinning cube demo.
|
||||
|
||||
## Build
|
||||
|
||||
1. Install or update [Conan 2.x](https://docs.conan.io/en/latest/installation.html) and run
|
||||
```
|
||||
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"
|
||||
```
|
||||
so that Conan brings in `lua`, SDL3, and the Vulkan loader + headers.
|
||||
2. Configure the project with CMake using the generated Conan toolchain:
|
||||
```
|
||||
cmake -B build -S .
|
||||
```
|
||||
3. Build the demo:
|
||||
```
|
||||
cmake --build build --config Release --target sdl3_app
|
||||
```
|
||||
1. **Dependencies**
|
||||
- Install or update [Conan 2.x](https://docs.conan.io/en/latest/installation.html).
|
||||
- Run:
|
||||
```
|
||||
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"
|
||||
```
|
||||
so Conan pulls in `lua`, SDL3, Vulkan, and the rest of the graph defined in `conanfile.py`.
|
||||
|
||||
Shaders are copied into `build/shaders` during configuration, so the demo can load the precompiled `cube.{vert,frag}.spv`.
|
||||
2. **Configure**
|
||||
- Default (Visual Studio): `cmake -B build -S .`
|
||||
* This uses the Visual Studio 2022 generator.
|
||||
- Ninja: configure into a clean folder, e.g., `cmake -G Ninja -B build-ninja -S .`
|
||||
* CMake already appends `C:\ProgramData\chocolatey\bin` to `CMAKE_PROGRAM_PATH`, so Ninja and Chocolatey LLVM tools are discoverable without extra `PATH` edits.
|
||||
* 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=Debug` if you need another configuration in that folder.
|
||||
- Optional clang-tidy: add `-DENABLE_CLANG_TIDY=ON`
|
||||
* CMake searches both `C:\Program Files\LLVM\bin` and `C:\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.
|
||||
|
||||
3. **Build**
|
||||
- `cmake --build build --config Release --target sdl3_app` (or point at `build-ninja` if you used Ninja).
|
||||
- Shaders land in `build/shaders` or `build-ninja/shaders`, so the executable can load `cube.{vert,frag}.spv`.
|
||||
|
||||
## Run
|
||||
|
||||
@@ -27,14 +33,16 @@ cmake --build build --target spinning_cube
|
||||
./build/spinning_cube
|
||||
```
|
||||
|
||||
If you need the Conan runtime environment (e.g., because dependencies set env vars), source `build/conanrun.sh` before launching the binary on Linux/macOS or run `build\\conanrun.bat` on Windows.
|
||||
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.cpp` now uses a JSON-driven entrypoint. Use `sdl3_app --json-file-in <path>` to load a configuration that points at the Lua script and captures window dimensions, or run `sdl3_app --create-seed-json config/seed_runtime.json` to write a starter JSON file (based on the executable’s `scripts/cube_logic.lua` location). You can also use `sdl3_app --set-default-json` (optionally followed by an existing JSON path) to copy the runtime JSON to the platform default directory (APPDATA on Windows, `XDG_CONFIG_HOME`/`$HOME/.config` elsewhere); when that default file exists, the app picks it up automatically when launched without extra CLI options. If no JSON input is provided and no default exists, the app falls back to discovering `scripts/cube_logic.lua` next to the binary.
|
||||
1. `main.cpp` now uses a JSON-driven entrypoint. Run `sdl3_app --json-file-in <path>` to load a config that points at the Lua script and defines window dimensions.
|
||||
2. Generate a starter JSON peppered with the default script locations via `sdl3_app --create-seed-json config/seed_runtime.json` (it assumes `scripts/cube_logic.lua` is next to the executable).
|
||||
3. Copy a JSON into the platform default by running `sdl3_app --set-default-json [path]` (APPDATA on Windows, `XDG_CONFIG_HOME`/`~/.config` elsewhere). When the default file exists, the app picks it up automatically; otherwise it discovers `scripts/cube_logic.lua` next to the binary.
|
||||
|
||||
### 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 the new config as input to `sdl3_app --set-default-json`) to run the interactive overlay in the window.
|
||||
`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
|
||||
|
||||
|
||||
3
third_party/font8x8_basic.h
vendored
3
third_party/font8x8_basic.h
vendored
@@ -20,7 +20,8 @@
|
||||
|
||||
// Constant: font8x8_basic
|
||||
// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
|
||||
char font8x8_basic[128][8] = {
|
||||
#include <stdint.h>
|
||||
const uint8_t font8x8_basic[128][8] = {
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
|
||||
|
||||
Reference in New Issue
Block a user