mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-11 16:09:02 +08:00
Allow opting out of STB_IMAGE dependency
Signed-off-by: Squareys <squareys@googlemail.com>
This commit is contained in:
parent
ff644d82c9
commit
2d3594de22
@ -101,6 +101,7 @@ if (!ret) {
|
|||||||
## Compile options
|
## Compile options
|
||||||
|
|
||||||
* `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.
|
||||||
|
|
||||||
### Saving gltTF 2.0 model
|
### Saving gltTF 2.0 model
|
||||||
|
|
||||||
|
@ -730,10 +730,12 @@ enum SectionCheck {
|
|||||||
///
|
///
|
||||||
typedef bool (*LoadImageDataFunction)(Image *, std::string *, int, int, const unsigned char *, int, void *);
|
typedef bool (*LoadImageDataFunction)(Image *, std::string *, int, int, const unsigned char *, int, void *);
|
||||||
|
|
||||||
|
#ifndef TINYGLTF_NO_STB_IMAGE
|
||||||
// Declaration of default image loader callback
|
// Declaration of default image loader callback
|
||||||
static bool LoadImageData(Image *image, std::string *err, int req_width,
|
static bool LoadImageData(Image *image, std::string *err, int req_width,
|
||||||
int req_height, const unsigned char *bytes,
|
int req_height, const unsigned char *bytes,
|
||||||
int size, void*);
|
int size, void*);
|
||||||
|
#endif
|
||||||
|
|
||||||
class TinyGLTF {
|
class TinyGLTF {
|
||||||
public:
|
public:
|
||||||
@ -869,7 +871,11 @@ class TinyGLTF {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "./json.hpp"
|
#include "./json.hpp"
|
||||||
|
|
||||||
|
#ifndef TINYGLTF_NO_STB_IMAGE
|
||||||
#include "./stb_image.h"
|
#include "./stb_image.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
@ -1186,6 +1192,7 @@ void TinyGLTF::SetImageLoader(LoadImageDataFunction func, void *user_data) {
|
|||||||
load_image_user_data_ = user_data;
|
load_image_user_data_ = user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TINYGLTF_NO_STB_IMAGE
|
||||||
static bool LoadImageData(Image *image, std::string *err, int req_width,
|
static bool LoadImageData(Image *image, std::string *err, int req_width,
|
||||||
int req_height, const unsigned char *bytes,
|
int req_height, const unsigned char *bytes,
|
||||||
int size, void*) {
|
int size, void*) {
|
||||||
@ -1242,6 +1249,7 @@ static bool LoadImageData(Image *image, std::string *err, int req_width,
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool IsDataURI(const std::string &in) {
|
static bool IsDataURI(const std::string &in) {
|
||||||
std::string header = "data:application/octet-stream;base64,";
|
std::string header = "data:application/octet-stream;base64,";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user