forked from jkuhlmann/cgltf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jkuhlmann#181 from sanghoon/feature/fix_write
Fix a bug related to json extras & Impl. a data URI writer.
- Loading branch information
Showing
5 changed files
with
141 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#define CGLTF_IMPLEMENTATION | ||
#define CGLTF_WRITE_IMPLEMENTATION | ||
#include "../cgltf_write.h" | ||
|
||
#include <algorithm> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <limits> | ||
#include <string.h> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
if (argc < 2) | ||
{ | ||
printf("err\n"); | ||
return -1; | ||
} | ||
|
||
cgltf_options options = {}; | ||
cgltf_data* data0 = NULL; | ||
cgltf_result result = cgltf_parse_file(&options, argv[1], &data0); | ||
|
||
// Silently skip over files that are unreadable since this is a writing test. | ||
if (result != cgltf_result_success) | ||
{ | ||
return cgltf_result_success; | ||
} | ||
|
||
options.type = cgltf_file_type_glb; // Write back in a GLB format | ||
result = cgltf_write_file(&options, "out.glb", data0); | ||
if (result != cgltf_result_success) | ||
{ | ||
return result; | ||
} | ||
|
||
cgltf_data* data1 = NULL; | ||
result = cgltf_parse_file(&options, "out.glb", &data1); | ||
if (result != cgltf_result_success) | ||
{ | ||
return result; | ||
} | ||
|
||
if (data0->meshes_count != data1->meshes_count) { | ||
return -1; | ||
} | ||
|
||
// Compare binary buffers | ||
if (data0->bin_size != data1->bin_size) { | ||
return -1; | ||
} | ||
if (memcmp(data0->bin, data1->bin, data0->bin_size) != 0) { | ||
return -1; | ||
} | ||
|
||
cgltf_free(data1); | ||
cgltf_free(data0); | ||
return cgltf_result_success; | ||
} |