mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-07-31 03:01:59 +08:00
Make lodepng optional.
This commit is contained in:
parent
c91b6468e8
commit
1b7994a4f4
@ -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.
|
||||
|
6
examples/raytrace/image-impl.cc
Normal file
6
examples/raytrace/image-impl.cc
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
#define LODEPNG_IMPLEMENTATION
|
||||
#include "lodepng.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<unsigned *>(&w), reinterpret_cast<unsigned *>(&h), bytes, size, LCT_RGBA, /* bitdepth*/16);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user