mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-24 16:18:49 +00:00
Compare commits
2 Commits
cwbhhjl-fi
...
separate-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bafde6a53e | ||
|
|
3d939fd3ee |
@@ -153,6 +153,7 @@ if (!ret) {
|
||||
|
||||
## Compile options
|
||||
|
||||
* `TINYGLTF_ENABLE_SERIALIZER` : Enable glTF serialization feature.
|
||||
* `TINYGLTF_NOEXCEPTION` : Disable C++ exception in JSON parsing. You can use `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION` and `TINYGLTF_NOEXCEPTION` to fully remove C++ exception codes when compiling TinyGLTF.
|
||||
* `TINYGLTF_NO_STB_IMAGE` : Do not load images with stb_image. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images.
|
||||
* `TINYGLTF_NO_STB_IMAGE_WRITE` : Do not write images with stb_image_write. Instead use `TinyGLTF::SetImageWriter(WriteimageDataFunction WriteImageData, void *user_data)` to set a callback for writing images.
|
||||
|
||||
25
tiny_gltf.h
25
tiny_gltf.h
@@ -26,6 +26,7 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
// Version:
|
||||
// - v2.4.3 Introduce TINYGLTF_ENABLE_SERIALIZER.
|
||||
// - v2.4.2 Decode percent-encoded URI.
|
||||
// - v2.4.1 Fix some glTF object class does not have `extensions` and/or
|
||||
// `extras` property.
|
||||
@@ -1249,7 +1250,13 @@ struct FsCallbacks {
|
||||
|
||||
bool FileExists(const std::string &abs_filename, void *);
|
||||
|
||||
std::string ExpandFilePath(const std::string &filepath, void *);
|
||||
///
|
||||
/// Expand file path(e.g. `~` to home directory on posix, `%APPDATA%` to `C:\Users\tinygltf\AppData`)
|
||||
///
|
||||
/// @param[in] filepath File path string. Assume UTF-8
|
||||
/// @param[in] userdata User data. Set to `nullptr` if you don't need it.
|
||||
///
|
||||
std::string ExpandFilePath(const std::string &filepath, void *userdata);
|
||||
|
||||
bool ReadWholeFile(std::vector<unsigned char> *out, std::string *err,
|
||||
const std::string &filepath, void *);
|
||||
@@ -1317,6 +1324,8 @@ class TinyGLTF {
|
||||
const std::string &base_dir = "",
|
||||
unsigned int check_sections = REQUIRE_VERSION);
|
||||
|
||||
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||
|
||||
///
|
||||
/// Write glTF to stream, buffers and images will be embeded
|
||||
///
|
||||
@@ -1330,16 +1339,22 @@ class TinyGLTF {
|
||||
bool embedImages, bool embedBuffers,
|
||||
bool prettyPrint, bool writeBinary);
|
||||
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Set callback to use for loading image data
|
||||
///
|
||||
void SetImageLoader(LoadImageDataFunction LoadImageData, void *user_data);
|
||||
|
||||
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||
|
||||
///
|
||||
/// Set callback to use for writing image data
|
||||
///
|
||||
void SetImageWriter(WriteImageDataFunction WriteImageData, void *user_data);
|
||||
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Set callbacks to use for filesystem (fs) access and their user data
|
||||
///
|
||||
@@ -2387,11 +2402,15 @@ bool LoadImageData(Image *image, const int image_idx, std::string *err,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||
|
||||
void TinyGLTF::SetImageWriter(WriteImageDataFunction func, void *user_data) {
|
||||
WriteImageData = func;
|
||||
write_image_user_data_ = user_data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
|
||||
static void WriteToMemory_stbi(void *context, void *data, int size) {
|
||||
std::vector<unsigned char> *buffer =
|
||||
@@ -6208,6 +6227,8 @@ bool TinyGLTF::LoadBinaryFromFile(Model *model, std::string *err,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||
|
||||
///////////////////////
|
||||
// GLTF Serialization
|
||||
///////////////////////
|
||||
@@ -7613,6 +7634,8 @@ bool TinyGLTF::WriteGltfSceneToFile(Model *model, const std::string &filename,
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // TINYGLTF_ENABLE_SERIALIZER
|
||||
|
||||
} // namespace tinygltf
|
||||
|
||||
#ifdef __clang__
|
||||
|
||||
Reference in New Issue
Block a user