Compare commits

...

59 Commits

Author SHA1 Message Date
Syoyo Fujita
098dfee982 Merge pull request #92 from walf443/respect_stb_image_write_error
handling stbi_write_xxx_to_func return code
2018-08-28 21:33:07 +09:00
Keiji Yoshimi
c0cfc1ed95 handling stbi_write_xxx_to_func return code 2018-08-28 21:13:03 +09:00
Syoyo Fujita
96d2f314cd Merge pull request #86 from mosra/fail-when-bin-missing-from-glb
Properly fail also when external *.bin are missing from *.glb.
2018-08-17 19:52:09 +09:00
Vladimír Vondruš
fd84ceb791 Properly fail also when external *.bin are missing from *.glb.
Consistency with behavior for external *.bin files referenced from
*.gltf.
2018-08-16 21:07:56 +02:00
Syoyo Fujita
6d38ca3894 Merge branch 'devel' of github.com:syoyo/tinygltf into devel 2018-08-16 15:57:28 +09:00
Syoyo Fujita
a6802d10fb Fix typo(n2.z -> n1.z) 2018-08-16 15:56:13 +09:00
Syoyo Fujita
28dc902368 Add link to px_render. 2018-08-09 01:58:40 +09:00
Syoyo Fujita
7c8d4ed748 Added 'warning' message parameter to glTF loader API.
Asset loading failure messages(e.g. image file is missing) are now stored in `warning` message, not `error` message.
2018-07-27 16:49:10 +09:00
Syoyo Fujita
a71be9cc98 Merge pull request #80 from mosra/texture-name
Import texture names as well
2018-07-25 13:51:41 +09:00
Syoyo Fujita
8c29e35b42 Merge pull request #81 from mosra/emscripten-file-paths
Don't try to expand file paths on Emscripten.
2018-07-25 13:51:00 +09:00
Vladimír Vondruš
9f04583280 Don't try to expand file paths on Emscripten.
Since the same is done on all mobile platforms already, I think it
should not do any harm. Without this I was getting compilation/linker
errors.
2018-07-24 23:32:17 +02:00
Vladimír Vondruš
239be2c09f Import texture names as well.
Every other structure has it already.
2018-07-24 23:23:56 +02:00
Syoyo Fujita
39abfb5f91 Consider Data URI buffers in binary. Fixes #79. 2018-07-11 02:46:52 +09:00
Syoyo Fujita
81bbf86e2a Merge pull request #78 from UberLambda/devel
Added filesystem callback support (#77)
2018-07-08 15:17:13 +09:00
Paolo Jovon
b2a587af96 Fixed C++11 compliance of previous commit 2018-07-07 21:50:01 +02:00
Paolo Jovon
e6601bfb4b Added filesystem callback support
Now a library like PhysFS can be used to load files by defining custom
callbacks and disabling the builtin ones by #define TINYGLTF_NO_FS
2018-07-07 20:43:33 +02:00
Syoyo Fujita
90e2c9cc74 Merge pull request #76 from mynz/devel
parse extras on the root object
2018-06-28 20:25:23 +02:00
mynz
c0d4d1c50c parse extras on the root object 2018-06-28 23:06:00 +09:00
Syoyo Fujita
0f282f7e26 Merge pull request #75 from holzon/fix/allextras
Adding missing extras field serializaton
2018-06-04 19:07:49 +09:00
Jens Olsson
b3af2f1cf6 adding missing extras field serializaton 2018-06-04 11:56:00 +02:00
Syoyo Fujita
a48f12d2fc Merge pull request #73 from holzon/fix/extras
Added missing extras serialization for nodes
2018-05-24 23:59:56 +09:00
Jens Olsson
a9718668b4 fixing typo 2018-05-24 15:48:49 +02:00
Jens Olsson
b96f6966ab added missing extras serialization for nodes 2018-05-24 15:29:54 +02:00
Syoyo Fujita
7c56f8eb9e Merge pull request #69 from benbuzbee/serialization-fixes
Serialization fixes for single-number values and integers
2018-04-26 14:06:18 +09:00
Ben Buzbee
f6af224135 Remove use of optional 2018-04-25 15:13:05 -07:00
Ben Buzbee
3b735bb878 Serialization fixes 2018-04-24 11:39:30 -07:00
Syoyo Fujita
2d17a31d3b typedef struct -> struct for enabling forward declarations of struct. 2018-04-17 15:45:42 +09:00
Syoyo Fujita
48f6db0994 Suppress clang warnings. 2018-04-15 18:40:55 +09:00
Syoyo Fujita
c89fc5f06b Describe supported VS 2015 update revision. 2018-04-12 11:52:14 +09:00
Syoyo Fujita
1e629c8efe Fix printing accessor.min and accessor.max in loader_example.
Initial support for printing extensions(no pretty printing at the moment).
Merge branch 'generic_extension_support' of https://github.com/Selmar/tinygltf into Selmar-generic_extension_support
2018-04-05 15:37:57 +09:00
Selmar Kok
341fc31aee Merge remote-tracking branch 'origin/devel' into generic_extension_support
# Conflicts:
#	tiny_gltf.h
2018-04-04 18:34:30 +02:00
Syoyo Fujita
7b0bbc6570 Merge branch 'devel' into Selmar-generic_extension_support 2018-04-05 01:27:03 +09:00
Selmar Kok
9eae110946 serialize texture extensions 2018-04-04 18:10:37 +02:00
Selmar Kok
fa7022f364 Changed ExtensionMap to use Value instead of ParameterMap 2018-04-04 18:10:20 +02:00
Syoyo Fujita
6c67da478f Merge pull request #62 from bowald/feature/serializer-handle-image-output
small bugfix, serializer skipped texture samplers refering to first index.
2018-04-02 15:24:04 +09:00
johan bowald
b97d34cfee bugfix, serializer skipped texture samplers refering to first index. 2018-04-02 07:29:29 +02:00
Syoyo Fujita
142aed7499 Merge pull request #61 from bowald/fix/readme-update
Updated readme
2018-04-02 12:42:49 +09:00
johan bowald
ca80a591e0 updated readme: fixed example, fixed dead links to stb_image/stb_image_write 2018-04-01 22:57:07 +02:00
Syoyo Fujita
dc4bb86bf1 Suppress clang warnings. 2018-04-02 02:04:24 +09:00
johan bowald
ef151a4fed update examples with new defines 2018-04-01 14:08:45 +02:00
johan bowald
0894de77f9 added stb_image_write.h 2018-04-01 13:31:09 +02:00
johan bowald
642a343684 output both embedded and image files, small fix to serializer. 2018-04-01 12:37:18 +02:00
Syoyo Fujita
719d7e4a74 Suppress clang warnings.
Apply clang-format.
2018-03-30 19:26:35 +09:00
Syoyo Fujita
13fd7152ee Merge pull request #59 from bowald/feature/serializer-embed-buffer
Added embed buffers as an option in serializer
2018-03-30 19:17:18 +09:00
johan bowald
30c5347afe added embed buffers as an option in serializer 2018-03-30 11:52:56 +02:00
Syoyo Fujita
841c858bfd Merge pull request #58 from bowald/Bowald-serializer-fixes
Serializer skips null values
2018-03-28 22:09:08 +09:00
Johan Bowald
faa2722f45 Serializer skips null values 2018-03-28 14:54:22 +02:00
Syoyo Fujita
ae751c4882 Merge pull request #57 from Squareys/patch-1
Add Magnum's TinyGltfImporter plugin to projects
2018-03-28 19:23:39 +09:00
Jonathan Hale
6a04c87807 Add Magnum's TinyGltfImporter plugin to projects 2018-03-28 12:19:42 +02:00
Selmar Kok
5210f1539e Merge remote-tracking branch 'origin/devel' into generic_extension_support 2018-03-26 16:22:18 +02:00
Selmar Kok
35c798ed28 Merge remote-tracking branch 'origin/Selmar-generic_extension_support' into generic_extension_support 2018-03-26 16:20:44 +02:00
Syoyo Fujita
5e379693cb Merge pull request #55 from Ybalrid/pr_add_ogre_gltf_to_readme
Add Ogre_glTF to the list of projects using the lib
2018-03-22 02:09:49 +09:00
Arthur Brainville (Ybalrid)
a403cd8736 Add Ogre_glTF to the list of projects using the lib
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
2018-03-21 18:02:36 +01:00
Syoyo Fujita
d1f8bae89c Print extensions. 2018-03-21 18:48:03 +09:00
Selmar Kok
85b3cbc44d Merge branch 'devel' into generic_extension_support 2018-03-19 16:15:22 +01:00
Syoyo Fujita
d5b0244e2c Serialize lights under as KHR_lights_cmn extension. 2018-03-17 16:12:42 -05:00
Selmar Kok
2a15f387bc Merge branch 'devel' into generic_extension_support
# Conflicts:
#	tiny_gltf.h
2018-03-16 12:32:52 +01:00
Selmar
7d8cbba8e4 removed code from another issue 2018-03-15 17:32:27 +01:00
Selmar
09d2ff12d8 generic extension support
Two issues remaining:
- The lights data exists twice on export; once outside of the gltf specification and once in the extensions.
- A lot of objects are still missing the extensions property.
2018-03-15 17:30:42 +01:00
13 changed files with 3008 additions and 469 deletions

View File

@@ -1,6 +1,6 @@
# Use this for strict compilation check(will work on clang 3.8+)
#EXTRA_CXXFLAGS := -fsanitize=address -Wall -Werror -Weverything -Wno-c++11-long-long
#EXTRA_CXXFLAGS := -fsanitize=address -Wall -Werror -Weverything -Wno-c++11-long-long -Wno-c++98-compat
all:
clang++ $(EXTRA_CXXFLAGS) -std=c++11 -g -O0 -o loader_example loader_example.cc

View File

@@ -22,7 +22,7 @@ If you are looking for old, C++03 version, please use `devel-picojson` branch.
* [x] iOS + clang
* [x] Linux + gcc/clang
* [x] Windows + MinGW
* [x] Windows + Visual Studio 2015 or later.
* [x] Windows + Visual Studio 2015 Update 3 or later.
* Visual Studio 2013 is not supported since they have limited C++11 support and failed to compile `json.hpp`.
* [x] Android + CrystaX(NDK drop-in replacement) GCC
* [x] Web using Emscripten(LLVM)
@@ -49,8 +49,11 @@ If you are looking for old, C++03 version, please use `devel-picojson` branch.
## Projects using TinyGLTF
* px_render Single header C++ Libraries for Thread Scheduling, Rendering, and so on... https://github.com/pplux/px
* Physical based rendering with Vulkan using glTF 2.0 models https://github.com/SaschaWillems/Vulkan-glTF-PBR
* Your projects here!(Plese send PR)
* GLTF loader plugin for OGRE 2.1. Support for PBR materials via HLMS/PBS https://github.com/Ybalrid/Ogre_glTF
* [TinyGltfImporter](http://doc.magnum.graphics/magnum/classMagnum_1_1Trade_1_1TinyGltfImporter.html) plugin for [Magnum](https://github.com/mosra/magnum), a lightweight and modular C++11/C++14 graphics middleware for games and data visualization.
* Your projects here! (Please send PR)
## TODOs
@@ -70,12 +73,13 @@ TinyGLTF uses the following third party libraries.
* json.hpp : Copyright (c) 2013-2017 Niels Lohmann. MIT license.
* base64 : Copyright (C) 2004-2008 René Nyffenegger
* stb_image.h : v2.08 - public domain image loader - http://nothings.org/stb_image.h
* stb_image.h : v2.08 - public domain image loader - [Github link](https://github.com/nothings/stb/blob/master/stb_image.h)
* stb_image_write.h : v1.09 - public domain image writer - [Github link](https://github.com/nothings/stb/blob/master/stb_image_write.h)
## Build and example
Copy `stb_image.h`, `json.hpp` and `tiny_gltf.h` to your project.
Copy `stb_image.h`, `stb_image_write.h`, `json.hpp` and `tiny_gltf.h` to your project.
### Loading glTF 2.0 model
@@ -83,6 +87,7 @@ Copy `stb_image.h`, `json.hpp` and `tiny_gltf.h` to your project.
// Define these only in *one* .cc file.
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
// #define TINYGLTF_NOEXCEPTION // optional. disable exception handling.
#include "tiny_gltf.h"
@@ -108,10 +113,17 @@ if (!ret) {
* `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_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.
### Saving gltTF 2.0 model
T.B.W.
* [ ] Buffers.
* [x] To file
* [x] Embedded
* [ ] Draco compressed?
* [x] Images
* [x] To file
* [x] Embedded
* [ ] Binary(.glb)
## Running tests.

View File

@@ -69,13 +69,14 @@ int parse_args(int argc, char** argv) {
tinygltf::TinyGLTF loader;
tinygltf::Model model;
std::string error;
std::string warning;
bool state;
switch (detectType(config.input_path)) {
case FileType::Ascii:
state = loader.LoadASCIIFromFile(&model, &error, config.input_path);
state = loader.LoadASCIIFromFile(&model, &error, &warning, config.input_path);
break;
case FileType::Binary:
state = loader.LoadBinaryFromFile(&model, &error, config.input_path);
state = loader.LoadBinaryFromFile(&model, &error, &warning, config.input_path);
break;
case FileType::Unknown:
default:

View File

@@ -1,4 +1,5 @@
#include <iostream>
#include <algorithm>
#include "stb_image_write.h"
#include "texture_dumper.h"

View File

@@ -16,6 +16,7 @@
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "tiny_gltf.h"
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
@@ -732,16 +733,21 @@ int main(int argc, char **argv) {
tinygltf::Model model;
tinygltf::TinyGLTF loader;
std::string err;
std::string warn;
std::string input_filename(argv[1]);
std::string ext = GetFilePathExtension(input_filename);
bool ret = false;
if (ext.compare("glb") == 0) {
// assume binary glTF.
ret = loader.LoadBinaryFromFile(&model, &err, input_filename.c_str());
ret = loader.LoadBinaryFromFile(&model, &err, &warn, input_filename.c_str());
} else {
// assume ascii glTF.
ret = loader.LoadASCIIFromFile(&model, &err, input_filename.c_str());
ret = loader.LoadASCIIFromFile(&model, &err, &warn, input_filename.c_str());
}
if (!warn.empty()) {
printf("Warn: %s\n", warn.c_str());
}
if (!err.empty()) {

View File

@@ -3,6 +3,7 @@
#include <iostream>
#include <memory> // c++11
#define TINYGLTF_IMPLEMENTATION
#define TINYGLTF_NO_STB_IMAGE_WRITE
#include <tiny_gltf.h>
namespace example {
@@ -25,15 +26,20 @@ bool LoadGLTF(const std::string &filename, float scale,
tinygltf::Model model;
tinygltf::TinyGLTF loader;
std::string err;
std::string warn;
const std::string ext = GetFilePathExtension(filename);
bool ret = false;
if (ext.compare("glb") == 0) {
// assume binary glTF.
ret = loader.LoadBinaryFromFile(&model, &err, filename.c_str());
ret = loader.LoadBinaryFromFile(&model, &err, &warn, filename.c_str());
} else {
// assume ascii glTF.
ret = loader.LoadASCIIFromFile(&model, &err, filename.c_str());
ret = loader.LoadASCIIFromFile(&model, &err, &warn, filename.c_str());
}
if (!warn.empty()) {
std::cout << "glTF parse warning: " << warn << std::endl;
}
if (!err.empty()) {
@@ -292,7 +298,7 @@ bool LoadGLTF(const std::string &filename, float scale,
loadedMesh.facevarying_normals.push_back(n1.x);
loadedMesh.facevarying_normals.push_back(n1.y);
loadedMesh.facevarying_normals.push_back(n2.z);
loadedMesh.facevarying_normals.push_back(n1.z);
loadedMesh.facevarying_normals.push_back(n2.x);
loadedMesh.facevarying_normals.push_back(n2.y);
@@ -327,7 +333,7 @@ bool LoadGLTF(const std::string &filename, float scale,
loadedMesh.facevarying_normals.push_back(n1.x);
loadedMesh.facevarying_normals.push_back(n1.y);
loadedMesh.facevarying_normals.push_back(n2.z);
loadedMesh.facevarying_normals.push_back(n1.z);
loadedMesh.facevarying_normals.push_back(n2.x);
loadedMesh.facevarying_normals.push_back(n2.y);

View File

@@ -3,11 +3,21 @@
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
//#define TINYGLTF_NO_STB_IMAGE_WRITE
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
#define STB_IMAGE_WRITE_IMPLEMENTATION
#endif
// If using a modern Microsoft Compiler, this define supress compilation
// warnings in stb_image_write
//#define STBI_MSC_SECURE_CRT
#include "tiny_gltf.h"
int main(int argc, char *argv[])
{
if (argc != 3) {
int main(int argc, char *argv[]) {
if (argc != 3) {
std::cout << "Needs input.gltf output.gltf" << std::endl;
return EXIT_FAILURE;
}
@@ -15,11 +25,17 @@ int main(int argc, char *argv[])
tinygltf::Model model;
tinygltf::TinyGLTF loader;
std::string err;
std::string warn;
std::string input_filename(argv[1]);
std::string output_filename(argv[2]);
std::string embedded_filename =
output_filename.substr(0, output_filename.size() - 5) + "-Embedded.gltf";
// assume ascii glTF.
bool ret = loader.LoadASCIIFromFile(&model, &err, input_filename.c_str());
bool ret = loader.LoadASCIIFromFile(&model, &err, &warn, input_filename.c_str());
if (!warn.empty()) {
std::cout << "warn : " << warn << std::endl;
}
if (!ret) {
if (!err.empty()) {
std::cerr << err << std::endl;
@@ -28,6 +44,10 @@ int main(int argc, char *argv[])
}
loader.WriteGltfSceneToFile(&model, output_filename);
return EXIT_SUCCESS;
// Embedd buffers and images
#ifndef TINYGLTF_NO_STB_IMAGE_WRITE
loader.WriteGltfSceneToFile(&model, embedded_filename, true, true);
#endif
return EXIT_SUCCESS;
}

View File

@@ -1,5 +1,6 @@
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "tiny_gltf.h"
#include <cstdio>
@@ -210,8 +211,21 @@ static std::string PrintParameterValue(const tinygltf::Parameter &param) {
}
}
#if 0
static std::string PrintParameterMap(const tinygltf::ParameterMap &pmap) {
std::stringstream ss;
ss << pmap.size() << std::endl;
for (auto &kv : pmap) {
ss << kv.first << " : " << PrintParameterValue(kv.second) << std::endl;
}
return ss.str();
}
#endif
static std::string PrintValue(const std::string &name,
const tinygltf::Value &value, const int indent) {
const tinygltf::Value &value, const int indent, const bool tag = true) {
std::stringstream ss;
if (value.IsObject()) {
@@ -219,19 +233,45 @@ static std::string PrintValue(const std::string &name,
tinygltf::Value::Object::const_iterator it(o.begin());
tinygltf::Value::Object::const_iterator itEnd(o.end());
for (; it != itEnd; it++) {
ss << PrintValue(name, it->second, indent + 1);
ss << PrintValue(it->first, it->second, indent + 1) << std::endl;
}
} else if (value.IsString()) {
ss << Indent(indent) << name << " : " << value.Get<std::string>()
<< std::endl;
if (tag) {
ss << Indent(indent) << name << " : " << value.Get<std::string>();
} else {
ss << " " << value.Get<std::string>() << " ";
}
} else if (value.IsBool()) {
ss << Indent(indent) << name << " : " << value.Get<bool>() << std::endl;
if (tag) {
ss << Indent(indent) << name << " : " << value.Get<bool>();
} else {
ss << " " << value.Get<bool>() << " ";
}
} else if (value.IsNumber()) {
ss << Indent(indent) << name << " : " << value.Get<double>() << std::endl;
if (tag) {
ss << Indent(indent) << name << " : " << value.Get<double>();
} else {
ss << " " << value.Get<double>() << " ";
}
} else if (value.IsInt()) {
ss << Indent(indent) << name << " : " << value.Get<int>() << std::endl;
if (tag) {
ss << Indent(indent) << name << " : " << value.Get<int>();
} else {
ss << " " << value.Get<int>() << " ";
}
} else if (value.IsArray()) {
ss << Indent(indent) << name << " [ ";
for (size_t i = 0; i < value.Size(); i++) {
ss << PrintValue("", value.Get(int(i)), indent + 1, /* tag */false);
if (i != (value.ArrayLen()-1)) {
ss << ", ";
}
}
ss << Indent(indent) << "] ";
}
// @todo { binary, array }
// @todo { binary }
return ss.str();
}
@@ -287,6 +327,15 @@ static void DumpPrimitive(const tinygltf::Primitive &primitive, int indent) {
<< PrintValue("extras", primitive.extras, indent + 1) << std::endl;
}
static void DumpExtensions(const tinygltf::ExtensionMap &extension, const int indent)
{
// TODO(syoyo): pritty print Value
for (auto &e : extension) {
std::cout << Indent(indent) << e.first << std::endl;
std::cout << PrintValue("extensions", e.second, indent+1) << std::endl;
}
}
static void Dump(const tinygltf::Model &model) {
std::cout << "=== Dump glTF ===" << std::endl;
std::cout << "asset.copyright : " << model.asset.copyright
@@ -307,6 +356,7 @@ static void Dump(const tinygltf::Model &model) {
for (size_t i = 0; i < model.scenes.size(); i++) {
std::cout << Indent(1) << "scene[" << i
<< "] name : " << model.scenes[i].name << std::endl;
DumpExtensions(model.scenes[i].extensions, 1);
}
}
@@ -344,7 +394,7 @@ static void Dump(const tinygltf::Model &model) {
std::cout << Indent(2) << "min : [";
for (size_t k = 0; k < accessor.minValues.size(); k++) {
std::cout << accessor.minValues[k]
<< ((i != accessor.minValues.size() - 1) ? ", " : "");
<< ((k != accessor.minValues.size() - 1) ? ", " : "");
}
std::cout << "]" << std::endl;
}
@@ -352,7 +402,7 @@ static void Dump(const tinygltf::Model &model) {
std::cout << Indent(2) << "max : [";
for (size_t k = 0; k < accessor.maxValues.size(); k++) {
std::cout << accessor.maxValues[k]
<< ((i != accessor.maxValues.size() - 1) ? ", " : "");
<< ((k != accessor.maxValues.size() - 1) ? ", " : "");
}
std::cout << "]" << std::endl;
}
@@ -530,6 +580,12 @@ static void Dump(const tinygltf::Model &model) {
}
}
}
// toplevel extensions
{
std::cout << "extensions(items=" << model.extensions.size() << ")" << std::endl;
DumpExtensions(model.extensions, 1);
}
}
int main(int argc, char **argv) {
@@ -541,6 +597,7 @@ int main(int argc, char **argv) {
tinygltf::Model model;
tinygltf::TinyGLTF gltf_ctx;
std::string err;
std::string warn;
std::string input_filename(argv[1]);
std::string ext = GetFilePathExtension(input_filename);
@@ -548,13 +605,18 @@ int main(int argc, char **argv) {
if (ext.compare("glb") == 0) {
std::cout << "Reading binary glTF" << std::endl;
// assume binary glTF.
ret = gltf_ctx.LoadBinaryFromFile(&model, &err, input_filename.c_str());
ret = gltf_ctx.LoadBinaryFromFile(&model, &err, &warn, input_filename.c_str());
} else {
std::cout << "Reading ASCII glTF" << std::endl;
// assume ascii glTF.
ret = gltf_ctx.LoadASCIIFromFile(&model, &err, input_filename.c_str());
ret = gltf_ctx.LoadASCIIFromFile(&model, &err, &warn, input_filename.c_str());
}
if (!warn.empty()) {
printf("Warn: %s\n", warn.c_str());
}
if (!err.empty()) {
printf("Err: %s\n", err.c_str());
}

BIN
models/box01.glb Normal file

Binary file not shown.

1831
stb_image_write.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,7 @@ def run(filename):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
except:
print "Failed to execute: ", cmd
print("Failed to execute: ", cmd)
raise
if p.returncode != 0:

View File

@@ -1,5 +1,6 @@
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "tiny_gltf.h"
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
@@ -24,3 +25,18 @@ TEST_CASE("parse-error", "[parse]") {
}
TEST_CASE("datauri-in-glb", "[issue-79]") {
tinygltf::Model model;
tinygltf::TinyGLTF ctx;
std::string err;
bool ret = ctx.LoadBinaryFromFile(&model, &err, "../models/box01.glb");
if (!err.empty()) {
std::cerr << err << std::endl;
}
REQUIRE(true == ret);
}

File diff suppressed because it is too large Load Diff