package vendor:gltf2
Overview
Usage:
`odin
import gltf "gltf2"
buf := gltf.buffer_slice(data, accessor_index).([][3]f32)
for val, i in buf {
// ...
}
`
Alternatively you can use a switch statement to handle multiple data formats:
`odin
buf := gltf.buffer_slice(data, accessor_index)
#partial switch vals in buf {
case [][4]u8:
for val, i in vals {
// ...
}
case [][4]i16:
for val, i in vals {
// ...
}
}
`
Index
Types (57)
- Accessor
- Accessor_Sparse
- Accessor_Sparse_Indices
- Accessor_Sparse_Values
- Accessor_Type
- Animation
- Animation_Channel
- Animation_Channel_Path
- Animation_Channel_Target
- Animation_Sampler
- Asset
- Buffer
- Buffer_Slice
- Buffer_Type_Hint
- Buffer_View
- Camera
- Component_Type
- Data
- Error
- Error_Type
- Extensions
- Extras
- GLB_Chunk_Header
- GLB_Header
- GLTF_Error
- GLTF_Param_Error
- Image
- Image_Type
- Integer
- Interpolation_Algorithm
- JSON_Error
- Magnification_Filter
- Material
- Material_Alpha_Mode
- Material_Metallic_Roughness
- Material_Normal_Texture_Info
- Material_Occlusion_Texture_Info
- Matrix4
- Mesh
- Mesh_Primitive
- Mesh_Primitive_Mode
- Mesh_Target
- Mesh_Target_Type
- Minification_Filter
- Node
- Number
- Options
- Orthographic_Camera
- Perspective_Camera
- Quaternion
- Sampler
- Scene
- Skin
- Texture
- Texture_Info
- Uri
- Wrap_Mode
Variables (0)
This section is empty.
Procedures (50)
- accessor_sparse_parse
- accessors_free
- accessors_parse
- animation_channel_target_parse
- animation_channels_parse
- animation_samplers_parse
- animations_free
- animations_parse
- asset_parse
- buffer_slice
- buffer_views_free
- buffer_views_parse
- buffers_free
- buffers_parse
- cameras_free
- cameras_parse
- extensions_names_free
- extensions_names_parse
- images_free
- images_parse
- load_from_file
- materials_free
- materials_parse
- mesh_primitives_free
- mesh_primitives_parse
- mesh_targets_parse
- meshes_free
- meshes_parse
- nodes_free
- nodes_parse
- normal_texture_info_parse
- occlusion_texture_info_parse
- orthographic_camera_parse
- parse
- pbr_metallic_roughness_parse
- perspective_camera_parse
- samplers_free
- samplers_parse
- scenes_free
- scenes_parse
- skins_free
- skins_parse
- sparse_indices_parse
- sparse_values_parse
- texture_info_parse
- textures_free
- textures_parse
- unload
- uri_free
- uri_parse
Procedure Groups (0)
This section is empty.
Types
Accessor ¶
Accessor :: struct { byte_offset: u32, component_type: Component_Type, // Required normalized: bool, count: u32, // Required type: Accessor_Type, // Required buffer_view: runtime.Maybe($T=u32), max: runtime.Maybe($T=[16]f32), min: runtime.Maybe($T=[16]f32), name: runtime.Maybe($T=string), sparse: runtime.Maybe($T=Accessor_Sparse), extensions: encoding_json.Value, extras: encoding_json.Value, }
Accessor related data structures
Accessor_Sparse ¶
Accessor_Sparse :: struct { // count: Integer, // Required indices: []Accessor_Sparse_Indices, // Required values: []Accessor_Sparse_Values, // Required extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Accessor_Sparse_Indices ¶
Accessor_Sparse_Indices :: struct { buffer_view: u32, // Required byte_offset: u32, component_type: Component_Type, // Required extensions: encoding_json.Value, extras: encoding_json.Value, }
Accessor_Type ¶
Accessor_Type :: enum int { Scalar, Vector2, Vector3, Vector4, Matrix2, Matrix3, Matrix4, }
Animation ¶
Animation :: struct { channels: []Animation_Channel, // Required samplers: []Animation_Sampler, // Required name: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Animation related data structurs
Animation_Channel ¶
Animation_Channel :: struct { sampler: u32, // Required target: Animation_Channel_Target, // Required extensions: encoding_json.Value, extras: encoding_json.Value, }
Animation_Channel_Path ¶
Animation_Channel_Path :: enum int { Translation, Rotation, Scale, Weights, }
Animation_Channel_Target ¶
Animation_Channel_Target :: struct { path: Animation_Channel_Path, // Required node: runtime.Maybe($T=u32), extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Animation_Sampler ¶
Animation_Sampler :: struct { input: u32, output: u32, // Required interpolation: Interpolation_Algorithm, // Default: Linear extensions: encoding_json.Value, extras: encoding_json.Value, }
Asset ¶
Asset :: struct { version: f32, // Required min_version: runtime.Maybe($T=f32), copyright: runtime.Maybe($T=string), generator: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Asset data structure
Related Procedures With Returns
Buffer ¶
Buffer :: struct { byte_length: u32, name: runtime.Maybe($T=string), uri: Uri, extensions: encoding_json.Value, extras: encoding_json.Value, }
Buffer related data structures
Buffer_Slice ¶
Buffer_Slice :: union { []u8, []i8, []i16, []u16, []u32, []f32, [][2]u8, [][2]i8, [][2]i16, [][2]u16, [][2]u32, [][2]f32, [][3]u8, [][3]i8, [][3]i16, [][3]u16, [][3]u32, [][3]f32, [][4]u8, [][4]i8, [][4]i16, [][4]u16, [][4]u32, [][4]f32, []matrix[2, 2]u8, []matrix[2, 2]i8, []matrix[2, 2]i16, []matrix[2, 2]u16, []matrix[2, 2]u32, []matrix[2, 2]f32, []matrix[3, 3]u8, []matrix[3, 3]i8, []matrix[3, 3]i16, []matrix[3, 3]u16, []matrix[3, 3]u32, []matrix[3, 3]f32, []matrix[4, 4]u8, []matrix[4, 4]i8, []matrix[4, 4]i16, []matrix[4, 4]u16, []matrix[4, 4]u32, []matrix[4, 4]f32, }
All accessor type and component type combinations
Related Procedures With Returns
Buffer_Type_Hint ¶
Buffer_Type_Hint :: enum u16 { Array = 34962, Element_Array, }
Camera ¶
Camera :: struct { type: union { Perspective_Camera, Orthographic_Camera, }, name: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Camera related data structures
Component_Type ¶
Component_Type :: enum u16 { Byte = 5120, Unsigned_Byte, Short, Unsigned_Short, Unsigned_Int = 5125, Float, }
Other data structures
Data ¶
Data :: struct { asset: Asset, accessors: []Accessor, animations: []Animation, buffers: []Buffer, buffer_views: []Buffer_View, cameras: []Camera, images: []Image, materials: []Material, meshes: []Mesh, nodes: []Node, samplers: []Sampler, scene: runtime.Maybe($T=u32), scenes: []Scene, skins: []Skin, textures: []Texture, extensions_used: []string, extensions_required: []string, extensions: encoding_json.Value, extras: encoding_json.Value, json_value: encoding_json.Value, }
Related Procedures With Parameters
Related Procedures With Returns
Error ¶
Error :: union { JSON_Error, GLTF_Error, }
Related Procedures With Returns
- accessor_sparse_parse
- accessors_parse
- animation_channel_target_parse
- animation_channels_parse
- animation_samplers_parse
- animations_parse
- asset_parse
- buffer_views_parse
- buffers_parse
- cameras_parse
- images_parse
- load_from_file
- materials_parse
- mesh_primitives_parse
- mesh_targets_parse
- meshes_parse
- nodes_parse
- normal_texture_info_parse
- occlusion_texture_info_parse
- orthographic_camera_parse
- parse
- pbr_metallic_roughness_parse
- perspective_camera_parse
- samplers_parse
- scenes_parse
- skins_parse
- sparse_indices_parse
- sparse_values_parse
- texture_info_parse
- textures_parse
Error_Type ¶
Error_Type :: enum int { Bad_GLB_Magic, Cant_Read_File, Data_Too_Short, Missing_Required_Parameter, No_File, Invalid_Type, JSON_Missing_Section, Unknown_File_Type, Unsupported_Version, Wrong_Chunk_Type, }
Extensions ¶
Extensions :: encoding_json.Value
GLTF_Error ¶
GLTF_Error :: struct { type: Error_Type, proc_name: string, param: GLTF_Param_Error, }
Image ¶
Image :: struct { name: runtime.Maybe($T=string), uri: Uri, type: runtime.Maybe($T=Image_Type), buffer_view: runtime.Maybe($T=u32), extensions: encoding_json.Value, extras: encoding_json.Value, }
Image related data structures
Image_Type ¶
Image_Type :: enum int { JPEG, PNG, }
Interpolation_Algorithm ¶
Interpolation_Algorithm :: enum int { Linear = 0, // Default Step, Cubic_Spline, }
Magnification_Filter ¶
Magnification_Filter :: enum u16 { Nearest = 9728, Linear, }
Material ¶
Material :: struct { emissive_factor: [3]f32, alpha_mode: Material_Alpha_Mode, alpha_cutoff: f32, // Default 0.5 double_sided: bool, name: runtime.Maybe($T=string), emissive_texture: runtime.Maybe($T=Texture_Info), metallic_roughness: runtime.Maybe($T=Material_Metallic_Roughness), normal_texture: runtime.Maybe($T=Material_Normal_Texture_Info), occlusion_texture: runtime.Maybe($T=Material_Occlusion_Texture_Info), extensions: encoding_json.Value, extras: encoding_json.Value, }
Material related data structures
Material_Alpha_Mode ¶
Material_Alpha_Mode :: enum int { Opaque, // Default Mask, Alpha_Cutoff, Blend, }
Material_Metallic_Roughness ¶
Material_Metallic_Roughness :: struct { base_color_factor: [4]f32, // Default [1, 1, 1, 1] metallic_factor: f32, roughness_factor: f32, // Default 1 base_color_texture: runtime.Maybe($T=Texture_Info), metallic_roughness_texture: runtime.Maybe($T=Texture_Info), extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Material_Normal_Texture_Info ¶
Material_Normal_Texture_Info :: struct { index: u32, tex_coord: u32, scale: f32, // Default 1 extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Material_Occlusion_Texture_Info ¶
Material_Occlusion_Texture_Info :: struct { index: u32, tex_coord: u32, strength: f32, // Default 1 extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Mesh ¶
Mesh :: struct { primitives: []Mesh_Primitive, weights: []f32, name: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Mesh related data structures
Mesh_Primitive ¶
Mesh_Primitive :: struct { attributes: map[string]u32, // Required mode: Mesh_Primitive_Mode, // Default Triangles(4) indices: runtime.Maybe($T=u32), material: runtime.Maybe($T=u32), targets: []Mesh_Target, extensions: encoding_json.Value, extras: encoding_json.Value, }
Mesh_Primitive_Mode ¶
Mesh_Primitive_Mode :: enum int { Points, Lines, Line_Loop, Line_Strip, Triangles, // Default Triangle_Strip, Triangle_Fan, }
Mesh_Target ¶
Mesh_Target :: struct { type: Mesh_Target_Type, index: u32, data: Accessor, name: string, }
TODO: Verify if this is correct
Mesh_Target_Type ¶
Mesh_Target_Type :: enum int { Invalid, Position, Normal, Tangent, TexCoord, Color, Joints, Weights, Custom, }
TODO: Verify if this is correct
Minification_Filter ¶
Minification_Filter :: enum u16 { Nearest = 9728, Linear, Nearest_MipMap_Nearest = 9984, Linear_MipMap_Nearest, Nearest_MipMap_Linear, Linear_MipMap_Linear, }
Node ¶
Node :: struct { mat: matrix[4, 4]f32, // Default Identity Matrix rotation: quaternion128, // Default [x = 0, y = 0, z = 0, w = 1] scale: [3]f32, // Default [1, 1, 1] translation: [3]f32, camera: runtime.Maybe($T=u32), mesh: runtime.Maybe($T=u32), skin: runtime.Maybe($T=u32), children: []u32, name: runtime.Maybe($T=string), weights: []f32, extensions: encoding_json.Value, extras: encoding_json.Value, }
Node data structure
Options ¶
Related Procedures With Parameters
Orthographic_Camera ¶
Orthographic_Camera :: struct { xmag: f32, ymag: f32, zfar: f32, znear: f32, extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Perspective_Camera ¶
Perspective_Camera :: struct { yfov: f32, znear: f32, aspect_ratio: runtime.Maybe($T=f32), zfar: runtime.Maybe($T=f32), extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Quaternion ¶
Quaternion :: quaternion128
Sampler ¶
Sampler :: struct { wrapS: Wrap_Mode, wrapT: Wrap_Mode, // Default Repeat(10497) name: runtime.Maybe($T=string), mag_filter: runtime.Maybe($T=Magnification_Filter), min_filter: runtime.Maybe($T=Minification_Filter), extensions: encoding_json.Value, extras: encoding_json.Value, }
Sampler data structure
Scene ¶
Scene :: struct { nodes: []u32, name: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Scene data structure
Skin ¶
Skin :: struct { joints: []u32, // Required inverse_bind_matrices: runtime.Maybe($T=u32), skeleton: runtime.Maybe($T=u32), name: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Skin data structure
Texture ¶
Texture :: struct { sampler: runtime.Maybe($T=u32), source: runtime.Maybe($T=u32), name: runtime.Maybe($T=string), extensions: encoding_json.Value, extras: encoding_json.Value, }
Texture related data structures
Texture_Info ¶
Texture_Info :: struct { index: u32, tex_coord: u32, extensions: encoding_json.Value, extras: encoding_json.Value, }
Related Procedures With Returns
Wrap_Mode ¶
Wrap_Mode :: enum u16 { Repeat = 10497, // Default Clamp_To_Edge = 33071, Mirrored_Repeat = 33648, }
Constants
CHUNK_TYPE_BIN ¶
CHUNK_TYPE_BIN: int : 0x004e4942
CHUNK_TYPE_JSON ¶
CHUNK_TYPE_JSON: int : 0x4e4f534a
GLB_CHUNK_HEADER_SIZE ¶
GLB_CHUNK_HEADER_SIZE: int : size_of(GLB_Chunk_Header)
GLB_HEADER_SIZE ¶
GLB_HEADER_SIZE: int : size_of(GLB_Header)
GLB_MAGIC ¶
GLB_MAGIC: int : 0x46546c67
GLTF_DOUBLE_PRECISION ¶
GLTF_DOUBLE_PRECISION: bool : #config(GLTF_DOUBLE_PRECISION, false)
Add following line when compiling to change type of Number from f32 to f64:
-define:GLTF_DOUBLE_PRECISION=true
GLTF_MIN_VERSION ¶
GLTF_MIN_VERSION: int : 2
Variables
This section is empty.
Procedures
accessor_sparse_parse ¶
accessor_sparse_parse :: proc(object: encoding_json.Object) -> (res: Accessor_Sparse, err: Error) {…}
accessors_free ¶
accessors_free :: proc(accessors: []Accessor) {…}
accessors_parse ¶
Accessors parsing
animation_channel_target_parse ¶
animation_channel_target_parse :: proc(object: encoding_json.Object) -> (res: Animation_Channel_Target, err: Error) {…}
animation_channels_parse ¶
animation_channels_parse :: proc(array: encoding_json.Array) -> (res: []Animation_Channel, err: Error) {…}
animation_samplers_parse ¶
animation_samplers_parse :: proc(array: encoding_json.Array) -> (res: []Animation_Sampler, err: Error) {…}
animations_free ¶
animations_free :: proc(animations: []Animation) {…}
animations_parse ¶
Animations parsing
asset_parse ¶
Asseet parsing
buffer_slice ¶
buffer_slice :: proc(data: ^Data, accessor_index: u32) -> Buffer_Slice {…}
buffer_views_free ¶
buffer_views_free :: proc(views: []Buffer_View) {…}
buffer_views_parse ¶
buffer_views_parse :: proc(object: encoding_json.Object) -> (res: []Buffer_View, err: Error) {…}
Buffer Views parsing
buffers_free ¶
buffers_free :: proc(buffers: []Buffer) {…}
buffers_parse ¶
buffers_parse :: proc(object: encoding_json.Object, gltf_dir: string) -> (res: []Buffer, err: Error) {…}
Buffers parsing
cameras_free ¶
cameras_free :: proc(cameras: []Camera) {…}
cameras_parse ¶
Cameras parsing
extensions_names_free ¶
extensions_names_free :: proc(names: []string) {…}
extensions_names_parse ¶
Utilitiy procedures
images_free ¶
images_free :: proc(images: []Image) {…}
images_parse ¶
images_parse :: proc(object: encoding_json.Object, gltf_dir: string) -> (res: []Image, err: Error) {…}
Images parsing
load_from_file ¶
load_from_file :: proc(file_name: string, allocator := context.allocator) -> (data: ^Data, err: Error) {…}
Main library interface procedures
materials_free ¶
materials_free :: proc(materials: []Material) {…}
materials_parse ¶
Materials parsing
mesh_primitives_free ¶
mesh_primitives_free :: proc(primitives: []Mesh_Primitive) {…}
mesh_primitives_parse ¶
mesh_primitives_parse :: proc(array: encoding_json.Array) -> (res: []Mesh_Primitive, err: Error) {…}
mesh_targets_parse ¶
mesh_targets_parse :: proc(object: encoding_json.Object) -> (res: []Mesh_Target, err: Error) {…}
meshes_free ¶
meshes_free :: proc(meshes: []Mesh) {…}
meshes_parse ¶
Meshes parsing
nodes_free ¶
nodes_free :: proc(nodes: []Node) {…}
nodes_parse ¶
Nodes parsing
normal_texture_info_parse ¶
normal_texture_info_parse :: proc(object: encoding_json.Object) -> (res: Material_Normal_Texture_Info, err: Error) {…}
occlusion_texture_info_parse ¶
occlusion_texture_info_parse :: proc(object: encoding_json.Object) -> (res: Material_Occlusion_Texture_Info, err: Error) {…}
orthographic_camera_parse ¶
orthographic_camera_parse :: proc(object: encoding_json.Object) -> (res: Orthographic_Camera, err: Error) {…}
parse ¶
parse :: proc(file_content: []u8, opt: Options = Options{}, allocator := context.allocator) -> (data: ^Data, err: Error) {…}
pbr_metallic_roughness_parse ¶
pbr_metallic_roughness_parse :: proc(object: encoding_json.Object) -> (res: Material_Metallic_Roughness, err: Error) {…}
perspective_camera_parse ¶
perspective_camera_parse :: proc(object: encoding_json.Object) -> (res: Perspective_Camera, err: Error) {…}
samplers_free ¶
samplers_free :: proc(samplers: []Sampler) {…}
samplers_parse ¶
Samplers parsing
scenes_free ¶
scenes_free :: proc(scenes: []Scene) {…}
scenes_parse ¶
Scenes parsing
skins_free ¶
skins_free :: proc(skins: []Skin) {…}
skins_parse ¶
Skins parsing
sparse_indices_parse ¶
sparse_indices_parse :: proc(array: encoding_json.Array) -> (res: []Accessor_Sparse_Indices, err: Error) {…}
sparse_values_parse ¶
sparse_values_parse :: proc(array: encoding_json.Array) -> (res: []Accessor_Sparse_Values, err: Error) {…}
texture_info_parse ¶
texture_info_parse :: proc(object: encoding_json.Object) -> (res: Texture_Info, err: Error) {…}
textures_free ¶
textures_free :: proc(textures: []Texture) {…}
textures_parse ¶
Textures parsing
uri_free ¶
uri_free :: proc(uri: Uri) {…}
Procedure Groups
This section is empty.
Source Files
Generation Information
Generated with odin version dev-v0.0.1 (vendor "odin") Linux_amd64 @ 2026-01-30 10:23:17.978193536 +0000 UTC