From d2bf171293349565407c74cde1034b859f2edc50 Mon Sep 17 00:00:00 2001 From: sean Date: Thu, 16 Mar 2023 20:13:52 +0100 Subject: [PATCH] Change: Use named GLB constants --- src/fastgltf.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/fastgltf.cpp b/src/fastgltf.cpp index b1dcde369..590e595a5 100644 --- a/src/fastgltf.cpp +++ b/src/fastgltf.cpp @@ -73,8 +73,9 @@ namespace fastgltf { ParserData& operator=(const ParserData& other) = delete; }; - // ASCII for "glTF". - constexpr uint32_t binaryGltfHeaderMagic = 0x46546C67; + constexpr uint32_t binaryGltfHeaderMagic = 0x46546C67; // ASCII for "glTF". + constexpr uint32_t binaryGltfJsonChunkMagic = 0x4E4F534A; + constexpr uint32_t binaryGltfDataChunkMagic = 0x004E4942; struct BinaryGltfHeader { uint32_t magic; @@ -2220,7 +2221,7 @@ std::unique_ptr fg::Parser::loadBinaryGLTF(GltfDataBuffer* buffer, fs: // 2. BIN chunk (optional) BinaryGltfChunk jsonChunk = {}; read(&jsonChunk, sizeof jsonChunk); - if (jsonChunk.chunkType != 0x4E4F534A) { + if (jsonChunk.chunkType != binaryGltfJsonChunkMagic) { errorCode = Error::InvalidGLB; return nullptr; } @@ -2245,7 +2246,7 @@ std::unique_ptr fg::Parser::loadBinaryGLTF(GltfDataBuffer* buffer, fs: BinaryGltfChunk binaryChunk = {}; read(&binaryChunk, sizeof binaryChunk); - if (binaryChunk.chunkType != 0x004E4942) { + if (binaryChunk.chunkType != binaryGltfDataChunkMagic) { errorCode = Error::InvalidGLB; return nullptr; }