mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-15 22:25:57 +08:00
Build fix.
This commit is contained in:
parent
190382aecd
commit
9e3d1f6db5
10
tiny_gltf.h
10
tiny_gltf.h
@ -7534,13 +7534,13 @@ static void WriteBinaryGltfStream(std::ostream &stream,
|
||||
const uint32_t content_size = uint32_t(content.size());
|
||||
const uint32_t binBuffer_size = uint32_t(binBuffer.size());
|
||||
// determine number of padding bytes required to ensure 4 byte alignment
|
||||
const uint32_t padding_size = content_size % 4 == 0 ? 0 : 4 - content_size % 4;
|
||||
const uint32_t content_padding_size = content_size % 4 == 0 ? 0 : 4 - content_size % 4;
|
||||
const uint32_t bin_padding_size = binBuffer_size % 4 == 0 ? 0 : 4 - binBuffer_size % 4;
|
||||
|
||||
// 12 bytes for header, JSON content length, 8 bytes for JSON chunk info.
|
||||
// Chunk data must be located at 4-byte boundary, which may require padding
|
||||
const uint32_t length =
|
||||
12 + 8 + content_size + content_padding +
|
||||
12 + 8 + content_size + content_padding_size +
|
||||
(binBuffer_size ? (8 + binBuffer_size + bin_padding_size : 0);
|
||||
|
||||
stream.write(header.c_str(), std::streamsize(header.size()));
|
||||
@ -7548,7 +7548,7 @@ static void WriteBinaryGltfStream(std::ostream &stream,
|
||||
stream.write(reinterpret_cast<const char *>(&length), sizeof(length));
|
||||
|
||||
// JSON chunk info, then JSON data
|
||||
const uint32_t model_length = uint32_t(content.size()) + padding_size;
|
||||
const uint32_t model_length = uint32_t(content.size()) + content_padding_size;
|
||||
const uint32_t model_format = 0x4E4F534A;
|
||||
stream.write(reinterpret_cast<const char *>(&model_length),
|
||||
sizeof(model_length));
|
||||
@ -7557,8 +7557,8 @@ static void WriteBinaryGltfStream(std::ostream &stream,
|
||||
stream.write(content.c_str(), std::streamsize(content.size()));
|
||||
|
||||
// Chunk must be multiplies of 4, so pad with spaces
|
||||
if (padding_size > 0) {
|
||||
const std::string padding = std::string(size_t(padding_size), ' ');
|
||||
if (content_padding_size > 0) {
|
||||
const std::string padding = std::string(size_t(content_padding_size), ' ');
|
||||
stream.write(padding.c_str(), std::streamsize(padding.size()));
|
||||
}
|
||||
if (binBuffer.size() > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user