Debian Codegraph @

third_party/cgltf/test/test_write.cpp

raw
1 #define CGLTF_IMPLEMENTATION
2 #define CGLTF_WRITE_IMPLEMENTATION
3 #include "../cgltf_write.h"
4
5 #include <algorithm>
6 #include <cmath>
7 #include <cstdio>
8 #include <limits>
9
10 int main(int argc, char** argv)
11 {
12 if (argc < 2)
13 {
14 printf("err\n");
15 return -1;
16 }
17
18 cgltf_options options = {};
19 cgltf_data* data0 = NULL;
20 cgltf_result result = cgltf_parse_file(&options, argv[1], &data0);
21
22 // Silently skip over files that are unreadable since this is a writing test.
23 if (result != cgltf_result_success)
24 {
25 return cgltf_result_success;
26 }
27
28 result = cgltf_write_file(&options, "out.gltf", data0);
29 if (result != cgltf_result_success)
30 {
31 return result;
32 }
33 cgltf_data* data1 = NULL;
34 result = cgltf_parse_file(&options, "out.gltf", &data1);
35 if (result != cgltf_result_success)
36 {
37 return result;
38 }
39 if (data0->meshes_count != data1->meshes_count) {
40 return -1;
41 }
42 cgltf_free(data1);
43 cgltf_free(data0);
44 return cgltf_result_success;
45 }