diff --git a/README.md b/README.md index 14e5e0d..45b7d1f 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ if (!ret) { * `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_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_NO_LODEPNG` : Do not load 16bit PNG image with lodepng. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images(You'll also need to disable stb image with `TINYGLTF_NO_STB_IMAGE`). +* `TINYGLTF_USE_LODEPNG` : Load 16bit PNG image with lodepng(Valid when `TINYGLTF_NO_STB_IMAGE` was **not** defined). Must defined `LODEPNG_IMPLEMENTATION` in one .cc. ### Saving gltTF 2.0 model * [ ] Buffers. diff --git a/examples/raytrace/image-impl.cc b/examples/raytrace/image-impl.cc new file mode 100644 index 0000000..c74d69e --- /dev/null +++ b/examples/raytrace/image-impl.cc @@ -0,0 +1,6 @@ + +#define STB_IMAGE_IMPLEMENTATION +#include "stb_image.h" + +#define LODEPNG_IMPLEMENTATION +#include "lodepng.h" diff --git a/tiny_gltf.h b/tiny_gltf.h index a008291..57485c0 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1075,7 +1075,7 @@ class TinyGLTF { #include "./stb_image_write.h" #endif -#ifndef TINYGLTF_NO_LODEPNG +#if defined(TINYGLTF_USE_LODEPNG) #include "./lodepng.h" #endif @@ -1621,7 +1621,7 @@ bool LoadImageData(Image *image, const int image_idx, std::string *err, std::str unsigned char *data = stbi_load_from_memory(bytes, size, &w, &h, &comp, req_comp); if (!data) { -#if !defined(TINYGLTF_NO_LODEPNG) +#if defined(TINYGLTF_USE_LODEPNG) // try to load as 16bit PNG RGBA unsigned ret = lodepng_decode_memory(&data, reinterpret_cast(&w), reinterpret_cast(&h), bytes, size, LCT_RGBA, /* bitdepth*/16);