Add shapes and basic selective actions

This commit is contained in:
2026-04-27 18:26:02 +02:00
parent 21476a3b95
commit 5881a7dafc
12 changed files with 1060 additions and 423 deletions

View File

@@ -1,5 +1,34 @@
# CLAUDE.md
## Project: Cartograph
A browser-based world map creation tool (like Wonderdraft/Inkarnate). C99 compiled to WebAssembly via Emscripten.
### Stack
- **Graphics:** Sokol (WebGPU backend, `SOKOL_WGPU`) — `lib/sokol/`
- **UI:** Dear ImGui via cimgui — `lib/imgui/`
- **Math:** cglm (types are C arrays: `vec2` = `float[2]`, `mat4` = `float[4][4]` column-major) — `lib/cglm/`
- **Shaders:** WGSL in `src/shaders/`, compiled to C headers via `xxd -i` into `src/generated/`
### Build
- `make` (release) / `make debug` — outputs `app.html`
- All includes go through `src/api.h` which defines `SOKOL_IMPL`, `SOKOL_WGPU`, and pulls in every library header
- Include paths: `lib/sokol`, `lib/imgui`, `lib/imgui/imgui`, `lib/util`, `lib/cglm/include`
### Key files
- `src/main.c` — entry point, sokol init, render loop, input (zoom/pan/drag)
- `src/api.h` — central include hub, backend defines
- `src/sprite.h` — sprite batching, texture manager, file import stubs
- `src/util.h``vector_t` (dynamic array) and `mem_pool_t` (free-list pool), both stripe-based
- `src/rand.h` — xorshift32 PRNG
### Conventions
- No malloc/free directly — use `ALLOC`/`FREE` macros (wired to smemtrack in main.c)
- Assert is encouraged for invariant checks
- Data structures use stripe-based allocation (byte stride per element, not sizeof)
---
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
## 1. Think Before Coding