Store relative URI in Buffer serializer. Fixes #48.

Apply clang-format.
Add simple saver sample.
This commit is contained in:
Syoyo Fujita
2018-03-15 21:52:00 -05:00
parent 20244e1e4e
commit d42767e63f
4 changed files with 192 additions and 165 deletions

View File

@@ -0,0 +1,2 @@
all:
clang++ -std=c++11 -I../../ -g -O1 -o saver main.cc

1
examples/saver/README.md Normal file
View File

@@ -0,0 +1 @@
# Simple serialization API sample.

33
examples/saver/main.cc Normal file
View File

@@ -0,0 +1,33 @@
#include <fstream>
#include <iostream>
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "tiny_gltf.h"
int main(int argc, char *argv[])
{
if (argc != 3) {
std::cout << "Needs input.gltf output.gltf" << std::endl;
return EXIT_FAILURE;
}
tinygltf::Model model;
tinygltf::TinyGLTF loader;
std::string err;
std::string input_filename(argv[1]);
std::string output_filename(argv[2]);
// assume ascii glTF.
bool ret = loader.LoadASCIIFromFile(&model, &err, input_filename.c_str());
if (!ret) {
if (!err.empty()) {
std::cerr << err << std::endl;
}
return EXIT_FAILURE;
}
loader.WriteGltfSceneToFile(&model, output_filename);
return EXIT_SUCCESS;
}