wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 3eda72e8c2
commit 5ffe50ed02
463 changed files with 72045 additions and 67421 deletions

View file

@ -4,31 +4,31 @@
# at the boundary, so nothing raw crosses it.
# an accessor's float components (gltf_count elements of gltf_comps floats), as floats
function gltf_accessor_floats(render3d_st: mut Render3dState, idx: int) -> floats {
let p = gltf_accessor(render3d_st, idx)
let n = render3d_st.gltf_count * render3d_st.gltf_comps
function gltf_accessor_floats(idx: int) -> floats {
let p = gltf_accessor(idx)
let n = gltf_count * gltf_comps
let out = floats(n)
for i in 0 .. n { out[i] = float_from_bits(mem_get_f32_bits(p, i)) }
free(p)
return out
}
# how many elements an accessor holds, without reading them
function gltf_accessor_count(render3d_st: Render3dState, idx: int) -> int {
let acc = value_at(value_get(render3d_st.gltf_doc, "accessors"), idx)
function gltf_accessor_count(idx: int) -> int {
let acc = value_at(value_get(gltf_doc, "accessors"), idx)
return jint(acc, "count", 0)
}
# the presented frame as RGB8, bottom row first, into `out` (at least w * h * 3 bytes)
function gpu_read_screen_bytes(render3d_st: mut Render3dState, w: int, h: int, out: []byte) -> bool {
function gpu_read_screen_bytes(w: int, h: int, out: []byte) -> bool {
if out == null or len(out) < w * h * 3 { return false }
gpu_read_screen(render3d_st, w, h, data_of(out))
gpu_read_screen(w, h, data_of(out))
return true
}
# a PNG's samples (tex_w x tex_h x tex_channels, 8 or 16 bits): into `reuse` when it is large
# enough - a map swap decodes the same size again - else into a new buffer. null if unreadable.
function png_decode_bytes(render3d_st: mut Render3dState, path: string, reuse: []byte) -> []byte {
let p = png_decode(render3d_st, path)
function png_decode_bytes(path: string, reuse: []byte) -> []byte {
let p = png_decode(path)
if p == null { return null }
let n = render3d_st.tex_w * render3d_st.tex_h * render3d_st.tex_channels * (render3d_st.tex_depth / 8)
let n = tex_w * tex_h * tex_channels * (tex_depth / 8)
var out = reuse
if out == null or len(out) < n { out = buffer(n) }
for i in 0 .. n { out[i] = p[i] }
@ -36,6 +36,6 @@ function png_decode_bytes(render3d_st: mut Render3dState, path: string, reuse: [
return out
}
# upload samples laid out as the last decode left them (tex_w, tex_h, tex_channels, tex_depth)
function tex_upload_bytes(render3d_st: mut Render3dState, px: []byte, srgb: bool, mips: bool) -> int {
return tex_upload(render3d_st, data_of(px), srgb, mips)
function tex_upload_bytes(px: []byte, srgb: bool, mips: bool) -> int {
return tex_upload(data_of(px), srgb, mips)
}