From f4b6d11abcb14c8ca2e67d4c09d7feada060b8ec Mon Sep 17 00:00:00 2001 From: kroko Date: Sun, 3 Mar 2019 01:11:31 +0200 Subject: [PATCH 1/4] Fix for when json and stb is aready used in project --- README.md | 4 ++++ tiny_gltf.h | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index cd86f97..ba85753 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,10 @@ if (!ret) { * `TINYGLTF_NO_EXTERNAL_IMAGE` : Do not try to load external image file. This option woulde be helpful if you do not want load image file during glTF parsing. * `TINYGLTF_ANDROID_LOAD_FROM_ASSETS`: Load all files from packaged app assets instead of the regular file system. **Note:** You must pass a valid asset manager from your android app to `tinygltf::asset_manager` beforehand. * `TINYGLTF_ENABLE_DRACO`: Enable Draco compression. User must provide include path and link correspnding libraries in your project file. +* `TINYGLTF_BYPASS_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` (usually because it has been included before). +* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` (usually because it has been included before). +* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` (usually because it has been included before). + ### Saving gltTF 2.0 model * [ ] Buffers. diff --git a/tiny_gltf.h b/tiny_gltf.h index c602e0d..e2eb2ff 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1077,7 +1077,9 @@ class TinyGLTF { #endif #endif +#ifndef TINYGLTF_BYPASS_INCLUDE_JSON #include "json.hpp" +#endif #ifdef TINYGLTF_ENABLE_DRACO #include "draco/core/decoder_buffer.h" @@ -1085,12 +1087,20 @@ class TinyGLTF { #endif #ifndef TINYGLTF_NO_STB_IMAGE +#ifndef STB_IMAGE_IMPLEMENTATION +#ifndef TINYGLTF_BYPASS_INCLUDE_STB_IMAGE #include "stb_image.h" #endif +#endif +#endif #ifndef TINYGLTF_NO_STB_IMAGE_WRITE +#ifndef STB_IMAGE_WRITE_IMPLEMENTATION +#ifndef TINYGLTF_BYPASS_INCLUDE_STB_IMAGE #include "stb_image_write.h" #endif +#endif +#endif #ifdef __clang__ #pragma clang diagnostic pop From 6a0d4c57b1a9926343cdded6ec6f69ac06e8fca4 Mon Sep 17 00:00:00 2001 From: kroko Date: Sun, 3 Mar 2019 01:28:45 +0200 Subject: [PATCH 2/4] Fix for when json and stb is aready used in project v2 --- tiny_gltf.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index e2eb2ff..5f8d328 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1087,20 +1087,16 @@ class TinyGLTF { #endif #ifndef TINYGLTF_NO_STB_IMAGE -#ifndef STB_IMAGE_IMPLEMENTATION #ifndef TINYGLTF_BYPASS_INCLUDE_STB_IMAGE #include "stb_image.h" #endif #endif -#endif #ifndef TINYGLTF_NO_STB_IMAGE_WRITE -#ifndef STB_IMAGE_WRITE_IMPLEMENTATION #ifndef TINYGLTF_BYPASS_INCLUDE_STB_IMAGE #include "stb_image_write.h" #endif #endif -#endif #ifdef __clang__ #pragma clang diagnostic pop From 606e5dde31c14716def9ae619f1a437c9067df53 Mon Sep 17 00:00:00 2001 From: kroko Date: Sun, 3 Mar 2019 01:56:34 +0200 Subject: [PATCH 3/4] be more precise in readme about include bypassing flags --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba85753..31a0982 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,9 @@ if (!ret) { * `TINYGLTF_NO_EXTERNAL_IMAGE` : Do not try to load external image file. This option woulde be helpful if you do not want load image file during glTF parsing. * `TINYGLTF_ANDROID_LOAD_FROM_ASSETS`: Load all files from packaged app assets instead of the regular file system. **Note:** You must pass a valid asset manager from your android app to `tinygltf::asset_manager` beforehand. * `TINYGLTF_ENABLE_DRACO`: Enable Draco compression. User must provide include path and link correspnding libraries in your project file. -* `TINYGLTF_BYPASS_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` (usually because it has been included before). -* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` (usually because it has been included before). -* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` (usually because it has been included before). +* `TINYGLTF_BYPASS_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. +* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. +* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. ### Saving gltTF 2.0 model From fc0116b323755db8fceb640109083a5330217e20 Mon Sep 17 00:00:00 2001 From: kroko Date: Sun, 3 Mar 2019 08:28:49 +0200 Subject: [PATCH 4/4] rename TINYGLTF_BYPASS_INCLUDE_x to TINYGLTF_NO_INCLUDE_x --- README.md | 6 +++--- tiny_gltf.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 31a0982..62986ea 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,9 @@ if (!ret) { * `TINYGLTF_NO_EXTERNAL_IMAGE` : Do not try to load external image file. This option woulde be helpful if you do not want load image file during glTF parsing. * `TINYGLTF_ANDROID_LOAD_FROM_ASSETS`: Load all files from packaged app assets instead of the regular file system. **Note:** You must pass a valid asset manager from your android app to `tinygltf::asset_manager` beforehand. * `TINYGLTF_ENABLE_DRACO`: Enable Draco compression. User must provide include path and link correspnding libraries in your project file. -* `TINYGLTF_BYPASS_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. -* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. -* `TINYGLTF_BYPASS_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. +* `TINYGLTF_NO_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. +* `TINYGLTF_NO_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. +* `TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. ### Saving gltTF 2.0 model diff --git a/tiny_gltf.h b/tiny_gltf.h index 5f8d328..76efa16 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1077,7 +1077,7 @@ class TinyGLTF { #endif #endif -#ifndef TINYGLTF_BYPASS_INCLUDE_JSON +#ifndef TINYGLTF_NO_INCLUDE_JSON #include "json.hpp" #endif @@ -1087,13 +1087,13 @@ class TinyGLTF { #endif #ifndef TINYGLTF_NO_STB_IMAGE -#ifndef TINYGLTF_BYPASS_INCLUDE_STB_IMAGE +#ifndef TINYGLTF_NO_INCLUDE_STB_IMAGE #include "stb_image.h" #endif #endif #ifndef TINYGLTF_NO_STB_IMAGE_WRITE -#ifndef TINYGLTF_BYPASS_INCLUDE_STB_IMAGE +#ifndef TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE #include "stb_image_write.h" #endif #endif