Add tg3_validate() glTF 2.0 validation API to tiny_gltf_v3#545
Draft
Add tg3_validate() glTF 2.0 validation API to tiny_gltf_v3#545
Conversation
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com> Agent-Logs-Url: https://github.com/syoyo/tinygltf/sessions/5e03ce1e-cc19-46d5-a9ae-04c373be3919
Copilot
AI
changed the title
[WIP] Add glTF validation feature for tinygltf v3
Add tg3_validate() glTF 2.0 validation API to tiny_gltf_v3
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tinygltf v3 had error codes and an error stack for validation but no post-parse validation function. This adds
tg3_validate()— a standalone validator that checks a parsedtg3_modelagainst the glTF 2.0 spec.API
Typical usage: parse first, then validate independently (or validate after programmatic model construction).
Validation coverage
versionrequired, warns if not"2.0"byteOffset+byteLengthwithin buffer bounds,byteStriderange [4,252] and 4-alignment (per spec §3.6.2.4)componentType/type,count ≥ 1, byte bounds and alignment within buffer view, sparse sub-structure refstranslation|rotation|scale|weightsalphaModeenum, all texture info indicestyperequired, perspectiveyfov/znear > 0, orthographicxmag/ymag ≠ 0,znear ≥ 0,zfar > znearbufferViewindex, warns on missing URI/bufferView/dataError message lifetime fix
tg3_error_stackgains an internalmsg_arena_field.tg3_validate()allocates both message andjson_pathstrings into this arena so they remain valid after the function returns.tg3_error_stack_free()destroys it. No change to existing parser behaviour.Tests
New
tests/v3/tester_v3.cc(22 test cases, 53 assertions) and correspondingtester_v3CMake target.Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.