Compare commits

...

19 Commits

Author SHA1 Message Date
Syoyo Fujita
847df8456a Merge pull request #489 from SeanCurtis-TRI/PR_callback_as_function
Update typedefs of C-style function pointers to std::function
2024-06-12 04:01:37 +09:00
Sean Curtis
6482c08cf7 Remove asserts 2024-06-10 14:18:31 -07:00
Sean Curtis
e08df72575 Update typedefs of C-style function pointers to std::function
This allows for the callback to maintain their own state (without recourse
to globals).

In addition, added some incidental clean up:

  - URICallback, passed by pointer, is now asserted to be non-null before
    accessing.
  - FSCallbacks are validated when they are set (in debug builds).
2024-06-06 07:45:01 -07:00
Syoyo Fujita
f03fe26579 Merge pull request #486 from pmcgvr/release
Fix stripping of slashes from paths
2024-05-24 02:49:22 +09:00
Syoyo Fujita
e54660fbf9 Merge pull request #485 from bwrsandman/patch-1
msvc 32bit: Fix C4244 warning
2024-05-21 04:11:31 +09:00
Patrick Mc Gartoll
1bdd404c04 Fix stripping of slashes from paths 2024-05-16 18:11:26 -07:00
Sandy
2191085580 msvc 32bit: Fix C4244 warning
On 32 bit msvc compilers with warnings on, there are C4244 warnings about  from 'std::streamoff' to size_t to vector::size_type
2024-05-10 08:47:23 -04:00
Syoyo Fujita
cde43ef668 Merge pull request #482 from jam3sward/fix-c4018-warnings-msvc-win32
Fix C4018 warnings in MSVC on WIN32
2024-03-27 03:43:42 +09:00
jamesvert
e3f9a7d8b3 Resolve overload ambiguity in VS2015 (version 14.0) 2024-03-26 11:32:43 +00:00
jamesvert
f57d18ad74 Fix C4018 warnings in MSVC on WIN32 2024-03-26 11:06:16 +00:00
Syoyo Fujita
ed3d1ec2f5 Merge pull request #481 from jam3sward/fix-c4267-warnings-vs-win32
Fix C4267 warnings in Visual Studio on WIN32
2024-03-26 05:23:03 +09:00
James Ward
9b4e1eae9e Fix C4267 warnings in Visual Studio on WIN32 2024-03-25 17:50:33 +00:00
Syoyo Fujita
cbc8e1bea6 Merge pull request #479 from The0Dev/fix_wopen_ronly
Added the pmode argument to _wopen to fix the access permission on MinGW
2024-03-26 02:36:27 +09:00
Syoyo Fujita
212de904ca Merge pull request #480 from ptc-tgamper/bug/msft_lod_extension_used
Bug/msft lod extension used
2024-03-26 02:35:51 +09:00
Thomas Gamper
1f5b8f8b8c tester.cc - extend MSFT_lod test 2024-03-25 17:01:08 +01:00
Thomas Gamper
b274b34972 tiny_gltf.h - register MSFT_lod with the model's used extensions 2024-03-25 17:00:41 +01:00
TheDev
22dfeab315 Added the pmode argument to _wopen to fix the access permission on MinGW 2024-03-25 18:21:20 +03:00
Syoyo Fujita
b132612307 Merge pull request #475 from jam3sward/issue-474
M_PI was not defined by <cmath>
2024-03-20 21:11:56 +09:00
James Ward
50d90c91ac M_PI was not defined by <cmath> 2024-03-19 19:06:19 +00:00
3 changed files with 174 additions and 88 deletions

View File

@@ -788,8 +788,10 @@ static void QuatToAngleAxis(const std::vector<double> quaternion,
return;
}
constexpr double pi = 3.14159265358979323846;
double denom = sqrt(1-qw*qw);
outAngleDegrees = angleRadians * 180.0 / M_PI;
outAngleDegrees = angleRadians * 180.0 / pi;
axis[0] = qx / denom;
axis[1] = qy / denom;
axis[2] = qz / denom;

View File

@@ -978,19 +978,20 @@ TEST_CASE("serialize-lods", "[lods]") {
{
tinygltf::Model m;
m.nodes.resize(3);
m.nodes.resize(4);
// Add Node 1 and Node 2 as lods to Node 0
m.nodes[0].lods.push_back(1);
m.nodes[0].lods.push_back(2);
// Add Material 1 and Material 2 as lods to Material 0
m.materials.resize(3);
m.materials.resize(4);
m.materials[0].lods.push_back(1);
m.materials[0].lods.push_back(2);
tinygltf::Scene scene;
// Scene uses Node 0 as root node
// Scene uses Node 0 and 3 as root node
scene.nodes.push_back(0);
scene.nodes.push_back(3);
// Add scene to the model
m.scenes.push_back(scene);
@@ -1006,28 +1007,52 @@ TEST_CASE("serialize-lods", "[lods]") {
// Parse the serialized model
bool ok = ctx.LoadASCIIFromString(&m, nullptr, nullptr, os.str().c_str(), os.str().size(), "");
REQUIRE(true == ok);
// Make sure the model's used extensions hold MSFT_lod
CHECK(m.extensionsUsed.size() == 1);
CHECK(m.extensionsUsed[0].compare("MSFT_lod") == 0);
// MSFT_lod is not a required extension
CHECK(m.extensionsRequired.size() == 0);
// Make sure all three materials are there
REQUIRE(3 == m.materials.size());
// Make sure all four materials are there
REQUIRE(4 == m.materials.size());
// Make sure the first material has both lod materials
REQUIRE(2 == m.materials[0].lods.size());
// Make sure the order is still the same after serialization and deserialization
CHECK(1 == m.materials[0].lods[0]);
CHECK(2 == m.materials[0].lods[1]);
// Make sure the material with lods exposes the MSFT_lod extension
CHECK(m.materials[0].extensions.size() == 1);
CHECK(m.materials[0].extensions.count("MSFT_lod") == 1);
// Make sure the last material has no lod materials
CHECK(0 == m.materials[3].lods.size());
// Make sure the material without lods does not exposes the MSFT_lod extension
CHECK(m.materials[3].extensions.size() == 0);
CHECK(m.materials[3].extensions.count("MSFT_lod") == 0);
// Make sure the single scene is there
REQUIRE(1 == m.scenes.size());
// Make sure all three nodes are there
REQUIRE(3 == m.nodes.size());
// Make sure the single root node of the scene is there
REQUIRE(1 == m.scenes[0].nodes.size());
// Make sure all four nodes are there
REQUIRE(4 == m.nodes.size());
// Make sure the two root nodes of the scene are there
REQUIRE(2 == m.scenes[0].nodes.size());
REQUIRE(0 == m.scenes[0].nodes[0]);
// Retrieve the scene root node
const tinygltf::Node& node = m.nodes[m.scenes[0].nodes[0]];
// Make sure the single root node has both lod nodes
REQUIRE(2 == node.lods.size());
REQUIRE(3 == m.scenes[0].nodes[1]);
// Retrieve the node with lods
const tinygltf::Node& nodeWithLods = m.nodes[m.scenes[0].nodes[0]];
// Make sure the node has both lod nodes
REQUIRE(2 == nodeWithLods.lods.size());
// Make sure the order is still the same after serialization and deserialization
CHECK(1 == node.lods[0]);
CHECK(2 == node.lods[1]);
CHECK(1 == nodeWithLods.lods[0]);
CHECK(2 == nodeWithLods.lods[1]);
// Make sure the node with lods exposes the MSFT_lod extension
CHECK(nodeWithLods.extensions.size() == 1);
CHECK(nodeWithLods.extensions.count("MSFT_lod") == 1);
// Retrieve the node without lods
const tinygltf::Node& nodeWithoutLods = m.nodes[m.scenes[0].nodes[1]];
// Make sure the node has no lod nodes
CHECK(0 == nodeWithoutLods.lods.size());
// Make sure the node without lods does not exposes the MSFT_lod extension
CHECK(nodeWithoutLods.extensions.size() == 0);
CHECK(nodeWithoutLods.extensions.count("MSFT_lod") == 0);
}
}

View File

@@ -43,9 +43,11 @@
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <limits>
#include <map>
#include <string>
#include <utility>
#include <vector>
// Auto-detect C++14 standard version
@@ -337,12 +339,11 @@ class Value {
T &Get();
// Lookup value from an array
const Value &Get(int idx) const {
const Value &Get(size_t idx) const {
static Value null_value;
assert(IsArray());
assert(idx >= 0);
return (static_cast<size_t>(idx) < array_value_.size())
? array_value_[static_cast<size_t>(idx)]
return (idx < array_value_.size())
? array_value_[idx]
: null_value;
}
@@ -1264,17 +1265,18 @@ enum SectionCheck {
/// image URIs differently, for example. See
/// https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#uris
///
typedef bool (*URIEncodeFunction)(const std::string &in_uri,
const std::string &object_type,
std::string *out_uri, void *user_data);
using URIEncodeFunction = std::function<bool(
const std::string & /* in_uri */, const std::string & /* object_type */,
std::string * /* out_uri */, void * /* user_data */)>;
///
/// URIDecodeFunction type. Signature for custom URI decoding of external
/// resources such as .bin and image files. Used by tinygltf when computing
/// filenames to write resources.
///
typedef bool (*URIDecodeFunction)(const std::string &in_uri,
std::string *out_uri, void *user_data);
using URIDecodeFunction =
std::function<bool(const std::string & /* in_uri */,
std::string * /* out_uri */, void * /* user_data */)>;
// Declaration of default uri decode function
bool URIDecode(const std::string &in_uri, std::string *out_uri,
@@ -1293,22 +1295,21 @@ struct URICallbacks {
///
/// LoadImageDataFunction type. Signature for custom image loading callbacks.
///
typedef bool (*LoadImageDataFunction)(Image *, const int, std::string *,
std::string *, int, int,
const unsigned char *, int,
void *user_pointer);
using LoadImageDataFunction = std::function<bool(
Image * /* image */, const int /* image_idx */, std::string * /* err */,
std::string * /* warn */, int /* req_width */, int /* req_height */,
const unsigned char * /* bytes */, int /* size */, void * /*user_data */)>;
///
/// WriteImageDataFunction type. Signature for custom image writing callbacks.
/// The out_uri parameter becomes the URI written to the gltf and may reference
/// a file or contain a data URI.
///
typedef bool (*WriteImageDataFunction)(const std::string *basepath,
const std::string *filename,
const Image *image, bool embedImages,
const URICallbacks *uri_cb,
std::string *out_uri,
void *user_pointer);
using WriteImageDataFunction = std::function<bool(
const std::string * /* basepath */, const std::string * /* filename */,
const Image *image, bool /* embedImages */,
const URICallbacks * /* uri_cb */, std::string * /* out_uri */,
void * /* user_pointer */)>;
#ifndef TINYGLTF_NO_STB_IMAGE
// Declaration of default image loader callback
@@ -1325,35 +1326,36 @@ bool WriteImageData(const std::string *basepath, const std::string *filename,
#endif
///
/// FilExistsFunction type. Signature for custom filesystem callbacks.
/// FileExistsFunction type. Signature for custom filesystem callbacks.
///
typedef bool (*FileExistsFunction)(const std::string &abs_filename, void *);
using FileExistsFunction = std::function<bool(
const std::string & /* abs_filename */, void * /* user_data */)>;
///
/// ExpandFilePathFunction type. Signature for custom filesystem callbacks.
///
typedef std::string (*ExpandFilePathFunction)(const std::string &, void *);
using ExpandFilePathFunction =
std::function<std::string(const std::string &, void *)>;
///
/// ReadWholeFileFunction type. Signature for custom filesystem callbacks.
///
typedef bool (*ReadWholeFileFunction)(std::vector<unsigned char> *,
std::string *, const std::string &,
void *);
using ReadWholeFileFunction = std::function<bool(
std::vector<unsigned char> *, std::string *, const std::string &, void *)>;
///
/// WriteWholeFileFunction type. Signature for custom filesystem callbacks.
///
typedef bool (*WriteWholeFileFunction)(std::string *, const std::string &,
const std::vector<unsigned char> &,
void *);
using WriteWholeFileFunction =
std::function<bool(std::string *, const std::string &,
const std::vector<unsigned char> &, void *)>;
///
/// GetFileSizeFunction type. Signature for custom filesystem callbacks.
///
typedef bool (*GetFileSizeFunction)(size_t *filesize_out, std::string *err,
const std::string &abs_filename,
void *userdata);
using GetFileSizeFunction =
std::function<bool(size_t *filesize_out, std::string *err,
const std::string &abs_filename, void *userdata)>;
///
/// A structure containing all required filesystem callbacks and a pointer to
@@ -1476,7 +1478,8 @@ class TinyGLTF {
void SetParseStrictness(ParseStrictness strictness);
///
/// Set callback to use for loading image data
/// Set callback to use for loading image data. Passing the nullptr is akin to
/// calling RemoveImageLoader().
///
void SetImageLoader(LoadImageDataFunction LoadImageData, void *user_data);
@@ -1491,14 +1494,18 @@ class TinyGLTF {
void SetImageWriter(WriteImageDataFunction WriteImageData, void *user_data);
///
/// Set callbacks to use for URI encoding and decoding and their user data
/// Set callbacks to use for URI encoding and decoding and their user data.
/// Returns false if there is an error with the callbacks. If err is not
/// nullptr, explanation will be written there.
///
void SetURICallbacks(URICallbacks callbacks);
bool SetURICallbacks(URICallbacks callbacks, std::string* err = nullptr);
///
/// Set callbacks to use for filesystem (fs) access and their user data
/// Set callbacks to use for filesystem (fs) access and their user data.
/// Returns false if there is an error with the callbacks. If err is not
/// nullptr, explanation will be written there.
///
void SetFsCallbacks(FsCallbacks callbacks);
bool SetFsCallbacks(FsCallbacks callbacks, std::string* err = nullptr);
///
/// Set serializing default values(default = false).
@@ -1927,7 +1934,7 @@ static bool Equals(const tinygltf::Value &one, const tinygltf::Value &other) {
}
case ARRAY_TYPE: {
if (one.Size() != other.Size()) return false;
for (int i = 0; i < int(one.Size()); ++i)
for (size_t i = 0; i < one.Size(); ++i)
if (!Equals(one.Get(i), other.Get(i))) return false;
return true;
}
@@ -2246,7 +2253,7 @@ static std::string GetFilePathExtension(const std::string &FileName) {
static std::string GetBaseDir(const std::string &filepath) {
if (filepath.find_last_of("/\\") != std::string::npos)
return filepath.substr(0, filepath.find_last_of("/\\"));
return filepath.substr(0, filepath.find_last_of("/\\") + 1);
return "";
}
@@ -2572,7 +2579,11 @@ void TinyGLTF::SetParseStrictness(ParseStrictness strictness) {
}
void TinyGLTF::SetImageLoader(LoadImageDataFunction func, void *user_data) {
LoadImageData = func;
if (func == nullptr) {
RemoveImageLoader();
return;
}
LoadImageData = std::move(func);
load_image_user_data_ = user_data;
user_image_loader_ = true;
}
@@ -2698,7 +2709,7 @@ bool LoadImageData(Image *image, const int image_idx, std::string *err,
#endif
void TinyGLTF::SetImageWriter(WriteImageDataFunction func, void *user_data) {
WriteImageData = func;
WriteImageData = std::move(func);
write_image_user_data_ = user_data;
}
@@ -2789,14 +2800,36 @@ bool WriteImageData(const std::string *basepath, const std::string *filename,
}
#endif
void TinyGLTF::SetURICallbacks(URICallbacks callbacks) {
assert(callbacks.decode);
if (callbacks.decode) {
uri_cb = callbacks;
bool TinyGLTF::SetURICallbacks(URICallbacks callbacks, std::string* err) {
if (callbacks.decode == nullptr) {
if (err != nullptr) {
*err = "URI Callback require a non-null decode function.";
}
return false;
}
if (callbacks.decode) {
uri_cb = std::move(callbacks);
}
return true;
}
void TinyGLTF::SetFsCallbacks(FsCallbacks callbacks) { fs = callbacks; }
bool TinyGLTF::SetFsCallbacks(FsCallbacks callbacks, std::string *err) {
// If callbacks are defined at all, they must all be defined.
if (callbacks.FileExists == nullptr || callbacks.ExpandFilePath == nullptr ||
callbacks.ReadWholeFile == nullptr ||
callbacks.WriteWholeFile == nullptr ||
callbacks.GetFileSizeInBytes == nullptr) {
if (err != nullptr) {
*err =
"FS Callbacks must be completely defined. At least one callback is "
"null.";
}
return false;
}
fs = std::move(callbacks);
return true;
}
#ifdef _WIN32
static inline std::wstring UTF8ToWchar(const std::string &str) {
@@ -3020,18 +3053,18 @@ bool GetFileSizeInBytes(size_t *filesize_out, std::string *err,
}
f.seekg(0, f.end);
size_t sz = static_cast<size_t>(f.tellg());
const auto sz = f.tellg();
// std::cout << "sz = " << sz << "\n";
f.seekg(0, f.beg);
if (int64_t(sz) < 0) {
if (sz < 0) {
if (err) {
(*err) += "Invalid file size : " + filepath +
" (does the path point to a directory?)";
}
return false;
} else if (sz == 0) {
} else if (sz == std::streamoff(0)) {
if (err) {
(*err) += "File is empty : " + filepath + "\n";
}
@@ -3043,7 +3076,7 @@ bool GetFileSizeInBytes(size_t *filesize_out, std::string *err,
return false;
}
(*filesize_out) = sz;
(*filesize_out) = static_cast<size_t>(sz);
return true;
#endif
}
@@ -3068,7 +3101,7 @@ bool ReadWholeFile(std::vector<unsigned char> *out, std::string *err,
}
return false;
}
out->resize(size);
out->resize(static_cast<size_t>(size));
AAsset_read(asset, reinterpret_cast<char *>(&out->at(0)), size);
AAsset_close(asset);
return true;
@@ -3115,18 +3148,18 @@ bool ReadWholeFile(std::vector<unsigned char> *out, std::string *err,
}
f.seekg(0, f.end);
size_t sz = static_cast<size_t>(f.tellg());
const auto sz = f.tellg();
// std::cout << "sz = " << sz << "\n";
f.seekg(0, f.beg);
if (int64_t(sz) < 0) {
if (sz < 0) {
if (err) {
(*err) += "Invalid file size : " + filepath +
" (does the path point to a directory?)";
}
return false;
} else if (sz == 0) {
} else if (sz == std::streamoff(0)) {
if (err) {
(*err) += "File is empty : " + filepath + "\n";
}
@@ -3151,7 +3184,7 @@ bool WriteWholeFile(std::string *err, const std::string &filepath,
#ifdef _WIN32
#if defined(__GLIBCXX__) // mingw
int file_descriptor = _wopen(UTF8ToWchar(filepath).c_str(),
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
__gnu_cxx::stdio_filebuf<char> wfile_buf(
file_descriptor, std::ios_base::out | std::ios_base::binary);
std::ostream f(&wfile_buf);
@@ -3201,7 +3234,7 @@ static std::string MimeToExt(const std::string &mimeType) {
static bool UpdateImageObject(const Image &image, std::string &baseDir,
int index, bool embedImages,
const URICallbacks *uri_cb,
WriteImageDataFunction *WriteImageData,
const WriteImageDataFunction& WriteImageData,
void *user_data, std::string *out_uri) {
std::string filename;
std::string ext;
@@ -3231,9 +3264,9 @@ static bool UpdateImageObject(const Image &image, std::string &baseDir,
// image data does not exist, this is not considered a failure and the
// original uri should be maintained.
bool imageWritten = false;
if (*WriteImageData != nullptr && !filename.empty() && !image.image.empty()) {
imageWritten = (*WriteImageData)(&baseDir, &filename, &image, embedImages,
uri_cb, out_uri, user_data);
if (WriteImageData != nullptr && !filename.empty() && !image.image.empty()) {
imageWritten = WriteImageData(&baseDir, &filename, &image, embedImages,
uri_cb, out_uri, user_data);
if (!imageWritten) {
return false;
}
@@ -4215,7 +4248,7 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err,
bool store_original_json_for_extras_and_extensions,
const std::string &basedir, const size_t max_file_size,
FsCallbacks *fs, const URICallbacks *uri_cb,
LoadImageDataFunction *LoadImageData = nullptr,
const LoadImageDataFunction& LoadImageData = nullptr,
void *load_image_user_data = nullptr) {
// A glTF image must either reference a bufferView or an image uri
@@ -4346,14 +4379,14 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err,
#endif
}
if (*LoadImageData == nullptr) {
if (LoadImageData == nullptr) {
if (err) {
(*err) += "No LoadImageData callback specified.\n";
}
return false;
}
return (*LoadImageData)(image, image_idx, err, warn, 0, 0, &img.at(0),
static_cast<int>(img.size()), load_image_user_data);
return LoadImageData(image, image_idx, err, warn, 0, 0, &img.at(0),
static_cast<int>(img.size()), load_image_user_data);
}
static bool ParseTexture(Texture *texture, std::string *err,
@@ -6342,7 +6375,7 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
if (!ParseImage(&image, idx, err, warn, o,
store_original_json_for_extras_and_extensions_, base_dir,
max_external_file_size_, &fs, &uri_cb,
&this->LoadImageData, load_image_user_data)) {
this->LoadImageData, load_image_user_data)) {
return false;
}
@@ -6371,7 +6404,7 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
}
const Buffer &buffer = model->buffers[size_t(bufferView.buffer)];
if (*LoadImageData == nullptr) {
if (LoadImageData == nullptr) {
if (err) {
(*err) += "No LoadImageData callback specified.\n";
}
@@ -7070,10 +7103,10 @@ static bool ValueToJson(const Value &value, detail::json *ret) {
obj = detail::json(value.Get<std::string>());
break;
case ARRAY_TYPE: {
for (unsigned int i = 0; i < value.ArrayLen(); ++i) {
Value elementValue = value.Get(int(i));
for (size_t i = 0; i < value.ArrayLen(); ++i) {
Value elementValue = value.Get(i);
detail::json elementJson;
if (ValueToJson(value.Get(int(i)), &elementJson))
if (ValueToJson(value.Get(i), &elementJson))
obj.push_back(elementJson);
}
break;
@@ -7127,7 +7160,7 @@ static bool SerializeGltfBufferData(const std::vector<unsigned char> &data,
#ifdef _WIN32
#if defined(__GLIBCXX__) // mingw
int file_descriptor = _wopen(UTF8ToWchar(binFilename).c_str(),
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
__gnu_cxx::stdio_filebuf<char> wfile_buf(
file_descriptor, std::ios_base::out | std::ios_base::binary);
std::ostream output(&wfile_buf);
@@ -8334,6 +8367,32 @@ static void SerializeGltfModel(const Model *model, detail::json &o) {
}
}
// MSFT_lod
// Look if there is a node that employs MSFT_lod
auto msft_lod_nodes_it = std::find_if(
model->nodes.begin(), model->nodes.end(),
[](const Node& node) { return !node.lods.empty(); });
// Look if there is a material that employs MSFT_lod
auto msft_lod_materials_it = std::find_if(
model->materials.begin(), model->materials.end(),
[](const Material& material) {return !material.lods.empty(); });
// If either a node or a material employ MSFT_lod, then we need
// to add MSFT_lod to the list of used extensions.
if (msft_lod_nodes_it != model->nodes.end() || msft_lod_materials_it != model->materials.end()) {
// First check if MSFT_lod is already registered as used extension
auto has_msft_lod = std::find_if(
extensionsUsed.begin(), extensionsUsed.end(),
[](const std::string &s) { return (s.compare("MSFT_lod") == 0); });
// If MSFT_lod is not registered yet, add it
if (has_msft_lod == extensionsUsed.end()) {
extensionsUsed.push_back("MSFT_lod");
}
}
// Extensions used
if (extensionsUsed.size()) {
SerializeStringArrayProperty("extensionsUsed", extensionsUsed, o);
@@ -8352,7 +8411,7 @@ static bool WriteGltfFile(const std::string &output,
std::ofstream gltfFile(UTF8ToWchar(output).c_str());
#elif defined(__GLIBCXX__)
int file_descriptor = _wopen(UTF8ToWchar(output).c_str(),
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
__gnu_cxx::stdio_filebuf<char> wfile_buf(
file_descriptor, std::ios_base::out | std::ios_base::binary);
std::ostream gltfFile(&wfile_buf);
@@ -8437,7 +8496,7 @@ static bool WriteBinaryGltfFile(const std::string &output,
std::ofstream gltfFile(UTF8ToWchar(output).c_str(), std::ios::binary);
#elif defined(__GLIBCXX__)
int file_descriptor = _wopen(UTF8ToWchar(output).c_str(),
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY);
_O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _S_IWRITE);
__gnu_cxx::stdio_filebuf<char> wfile_buf(
file_descriptor, std::ios_base::out | std::ios_base::binary);
std::ostream gltfFile(&wfile_buf);
@@ -8488,7 +8547,7 @@ bool TinyGLTF::WriteGltfSceneToStream(const Model *model, std::ostream &stream,
// we
std::string uri;
if (!UpdateImageObject(model->images[i], dummystring, int(i), true,
&uri_cb, &this->WriteImageData,
&uri_cb, this->WriteImageData,
this->write_image_user_data_, &uri)) {
return false;
}
@@ -8596,7 +8655,7 @@ bool TinyGLTF::WriteGltfSceneToFile(const Model *model,
std::string uri;
if (!UpdateImageObject(model->images[i], baseDir, int(i), embedImages,
&uri_cb, &this->WriteImageData,
&uri_cb, this->WriteImageData,
this->write_image_user_data_, &uri)) {
return false;
}