natiny_mesh_load

C
NatinyMesh natiny_mesh_load(NatinyResource mesh_resource);

Loads glTF 2.0 geometry from a resource.

Both binary (.glb) and text (.gltf + external .bin) glTF are accepted. The model is split into parts: one part per material, so every part has its own texture. Material textures are loaded automatically through natiny_resource_load(), relative to the model's own path.

Parameters

Name Type Description
mesh_resource NatinyResource Resource handle produced by natiny_resource_load(path) (a .gltf or .glb file)

Returns

Type Description
NatinyMesh Mesh handle (0 on failure)

Example

C
NatinyMesh mesh = natiny_mesh_load(mesh_resource);

Notes

  • .glb and .gltf are supported. Triangle primitives sharing a material are merged into one part, and glTF node transforms are baked into its vertices.
  • Each part keeps the selected material texture. The mesh owns its geometry and loaded textures.
  • External files (.bin buffers, image URIs) are resolved relative to the path used to load the source resource. A resource created from memory has no base path, so its external references cannot be resolved.
  • The mesh holds its own geometry copy; the source resource can be destroyed after natiny_mesh_load returns.
  • Multiple models may share the returned mesh.