mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-04-21 13:39:54 +08:00
Use TINYGLTF_ENABLE_SERIALIZER ifdef to enable/disable serialization code.
This commit is contained in:
parent
3d939fd3ee
commit
bafde6a53e
@ -153,6 +153,7 @@ if (!ret) {
|
|||||||
|
|
||||||
## Compile options
|
## 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_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` : 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.
|
* `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.
|
||||||
|
17
tiny_gltf.h
17
tiny_gltf.h
@ -26,6 +26,7 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
// Version:
|
// Version:
|
||||||
|
// - v2.4.3 Introduce TINYGLTF_ENABLE_SERIALIZER.
|
||||||
// - v2.4.2 Decode percent-encoded URI.
|
// - v2.4.2 Decode percent-encoded URI.
|
||||||
// - v2.4.1 Fix some glTF object class does not have `extensions` and/or
|
// - v2.4.1 Fix some glTF object class does not have `extensions` and/or
|
||||||
// `extras` property.
|
// `extras` property.
|
||||||
@ -1323,6 +1324,8 @@ class TinyGLTF {
|
|||||||
const std::string &base_dir = "",
|
const std::string &base_dir = "",
|
||||||
unsigned int check_sections = REQUIRE_VERSION);
|
unsigned int check_sections = REQUIRE_VERSION);
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Write glTF to stream, buffers and images will be embeded
|
/// Write glTF to stream, buffers and images will be embeded
|
||||||
///
|
///
|
||||||
@ -1336,16 +1339,22 @@ class TinyGLTF {
|
|||||||
bool embedImages, bool embedBuffers,
|
bool embedImages, bool embedBuffers,
|
||||||
bool prettyPrint, bool writeBinary);
|
bool prettyPrint, bool writeBinary);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set callback to use for loading image data
|
/// Set callback to use for loading image data
|
||||||
///
|
///
|
||||||
void SetImageLoader(LoadImageDataFunction LoadImageData, void *user_data);
|
void SetImageLoader(LoadImageDataFunction LoadImageData, void *user_data);
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set callback to use for writing image data
|
/// Set callback to use for writing image data
|
||||||
///
|
///
|
||||||
void SetImageWriter(WriteImageDataFunction WriteImageData, void *user_data);
|
void SetImageWriter(WriteImageDataFunction WriteImageData, void *user_data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set callbacks to use for filesystem (fs) access and their user data
|
/// Set callbacks to use for filesystem (fs) access and their user data
|
||||||
///
|
///
|
||||||
@ -2393,11 +2402,15 @@ bool LoadImageData(Image *image, const int image_idx, std::string *err,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
void TinyGLTF::SetImageWriter(WriteImageDataFunction func, void *user_data) {
|
void TinyGLTF::SetImageWriter(WriteImageDataFunction func, void *user_data) {
|
||||||
WriteImageData = func;
|
WriteImageData = func;
|
||||||
write_image_user_data_ = user_data;
|
write_image_user_data_ = user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
|
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
|
||||||
static void WriteToMemory_stbi(void *context, void *data, int size) {
|
static void WriteToMemory_stbi(void *context, void *data, int size) {
|
||||||
std::vector<unsigned char> *buffer =
|
std::vector<unsigned char> *buffer =
|
||||||
@ -6214,6 +6227,8 @@ bool TinyGLTF::LoadBinaryFromFile(Model *model, std::string *err,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(TINYGLTF_ENABLE_SERIALIZER)
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// GLTF Serialization
|
// GLTF Serialization
|
||||||
///////////////////////
|
///////////////////////
|
||||||
@ -7619,6 +7634,8 @@ bool TinyGLTF::WriteGltfSceneToFile(Model *model, const std::string &filename,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // TINYGLTF_ENABLE_SERIALIZER
|
||||||
|
|
||||||
} // namespace tinygltf
|
} // namespace tinygltf
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user