mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-10-24 17:51:04 +00:00
Store relative URI in Buffer serializer. Fixes #48.
Apply clang-format. Add simple saver sample.
This commit is contained in:
2
examples/saver/Makefile.dev
Normal file
2
examples/saver/Makefile.dev
Normal file
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
clang++ -std=c++11 -I../../ -g -O1 -o saver main.cc
|
||||
1
examples/saver/README.md
Normal file
1
examples/saver/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Simple serialization API sample.
|
||||
33
examples/saver/main.cc
Normal file
33
examples/saver/main.cc
Normal 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;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user