Use TINYGLTF_ENABLE_SERIALIZER ifdef to enable/disable serialization code.
diff --git a/README.md b/README.md
index e9b4134..0b9d4c5 100644
--- a/README.md
+++ b/README.md
@@ -153,6 +153,7 @@
## 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.
diff --git a/tiny_gltf.h b/tiny_gltf.h
index fa16ec5..8025202 100644
--- a/tiny_gltf.h
+++ b/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.
@@ -1323,6 +1324,8 @@
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
///
@@ -1336,16 +1339,22 @@
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
///
@@ -2393,11 +2402,15 @@
}
#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 =
@@ -6214,6 +6227,8 @@
return ret;
}
+#if defined(TINYGLTF_ENABLE_SERIALIZER)
+
///////////////////////
// GLTF Serialization
///////////////////////
@@ -7619,6 +7634,8 @@
return true;
}
+#endif // TINYGLTF_ENABLE_SERIALIZER
+
} // namespace tinygltf
#ifdef __clang__