Load a texture — stores the path + parses PNG header for dimensions, returns a 1-based handle. Returns 0 on failure.
(path: &str)
| 27 | /// Load a texture — stores the path + parses PNG header for dimensions, |
| 28 | /// returns a 1-based handle. Returns 0 on failure. |
| 29 | pub fn load(path: &str) -> u32 { |
| 30 | if path.is_empty() { |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | // Resolve bundle-relative paths against the main bundle's resource path. |
| 35 | let full = resolve_bundle_path(path); |
| 36 | |
| 37 | let (w, h) = match parse_png_size(&full) { |
| 38 | Some(v) => v, |
| 39 | None => (0, 0), // unknown — Swift will skip/draw placeholder |
| 40 | }; |
| 41 | |
| 42 | let cpath = match CString::new(full) { |
| 43 | Ok(c) => c, |
| 44 | Err(_) => return 0, |
| 45 | }; |
| 46 | |
| 47 | let mut reg = REG.lock().unwrap(); |
| 48 | reg.entries.push(TexEntry { path: cpath, width: w, height: h }); |
| 49 | reg.entries.len() as u32 |
| 50 | } |
| 51 | |
| 52 | /// Register in-memory image bytes (PNG or JPEG) by writing them to a temp |
| 53 | /// file inside the app's sandbox and returning a handle. Used by the glTF |
nothing calls this directly
no test coverage detected