MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / load

Function load

native/watchos/src/textures.rs:29–50  ·  view source on GitHub ↗

Load a texture — stores the path + parses PNG header for dimensions, returns a 1-based handle. Returns 0 on failure.

(path: &str)

Source from the content-addressed store, hash-verified

27/// Load a texture — stores the path + parses PNG header for dimensions,
28/// returns a 1-based handle. Returns 0 on failure.
29pub 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

Callers

nothing calls this directly

Calls 3

resolve_bundle_pathFunction · 0.85
parse_png_sizeFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected