60 lines
1.4 KiB
Markdown
60 lines
1.4 KiB
Markdown
# Odin + SDL3 GPU cubes (Vulkan only)
|
|
|
|
Small starter project in Odin that opens an SDL3 window, renders several 3D cubes with the SDL3 GPU API, and uses a Vulkan-only backend with SPIR-V shaders.
|
|
|
|
## Controls
|
|
|
|
- Left mouse drag: orbit camera
|
|
- Middle mouse drag: pan
|
|
- Mouse wheel: zoom in/out
|
|
- `W/A/S/D`: move camera target
|
|
- `Esc`: quit
|
|
|
|
## Requirements
|
|
|
|
- [Odin compiler](https://odin-lang.org/)
|
|
- SDL3 installed on your system (for runtime linking)
|
|
- Vulkan-capable GPU/driver with SDL3 Vulkan support
|
|
- `glslc` (from `shaderc`) to compile GLSL to SPIR-V
|
|
|
|
On macOS with Homebrew:
|
|
|
|
```bash
|
|
brew install odin sdl3 shaderc
|
|
```
|
|
|
|
## Build and run
|
|
|
|
Quick start:
|
|
|
|
```bash
|
|
./run.sh
|
|
```
|
|
|
|
The script compiles shaders, sets `VK_ICD_FILENAMES` to MoltenVK if available,
|
|
adds `/opt/homebrew/lib` to `DYLD_FALLBACK_LIBRARY_PATH`, and runs the app.
|
|
|
|
Compile shaders first:
|
|
|
|
```bash
|
|
glslc -fshader-stage=vert shaders/cubes.vert.glsl -o shaders/cubes.vert.spv
|
|
glslc -fshader-stage=frag shaders/cubes.frag.glsl -o shaders/cubes.frag.spv
|
|
```
|
|
|
|
From the project root:
|
|
|
|
```bash
|
|
odin run src -out:bin/cubes_gpu
|
|
```
|
|
|
|
Or build only:
|
|
|
|
```bash
|
|
odin build src -out:bin/cubes_gpu
|
|
```
|
|
|
|
## Notes
|
|
|
|
- Shaders source files are `shaders/cubes.vert.glsl` and `shaders/cubes.frag.glsl`.
|
|
- Runtime shader binaries are `shaders/cubes.vert.spv` and `shaders/cubes.frag.spv`.
|
|
- The app forces SDL3 GPU driver `vulkan` and exits if Vulkan is unavailable.
|