mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-06 07:38:25 +00:00
ADDED: Some sample code to export gltf/glb meshes -WIP-
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
* #define SUPPORT_FILEFORMAT_MTL
|
||||
* #define SUPPORT_FILEFORMAT_IQM
|
||||
* #define SUPPORT_FILEFORMAT_GLTF
|
||||
* #define SUPPORT_FILEFORMAT_GLTF_WRITE
|
||||
* #define SUPPORT_FILEFORMAT_VOX
|
||||
* #define SUPPORT_FILEFORMAT_M3D
|
||||
* Selected desired fileformats to be supported for model data loading
|
||||
@@ -71,6 +72,11 @@
|
||||
#define CGLTF_IMPLEMENTATION
|
||||
#include "external/cgltf.h" // glTF file format loading
|
||||
#endif
|
||||
#if SUPPORT_FILEFORMAT_GLTF_WRITE
|
||||
// NOTE: No need for custom allocators, memory buffer provided
|
||||
#define CGLTF_WRITE_IMPLEMENTATION
|
||||
#include "external/cgltf_write.h" // glTF file format writing
|
||||
#endif
|
||||
|
||||
#if SUPPORT_FILEFORMAT_VOX
|
||||
#define VOX_MALLOC RL_MALLOC
|
||||
@@ -2017,6 +2023,19 @@ bool ExportMesh(Mesh mesh, const char *fileName)
|
||||
|
||||
RL_FREE(txtData);
|
||||
}
|
||||
else if (IsFileExtension(fileName, ".gltf")) // Or .glb
|
||||
{
|
||||
// TODO: Implement gltf/glb support
|
||||
/*
|
||||
cgltf_size expected = cgltf_write(options, NULL, 0, data);
|
||||
char *buffer = (char *)RL_CALLOC(expected, 0);
|
||||
cgltf_size actual = cgltf_write(options, buffer, expected, data);
|
||||
|
||||
// NOTE: cgltf_write() includes a NULL terminator that should be ommited in case of a .glb
|
||||
if (options->type == cgltf_file_type_glb) cgltf_write_glb(file, buffer, actual - 1, data->bin, data->bin_size);
|
||||
else SaveFileText(fileName, buffer); // Write a plain JSON file
|
||||
*/
|
||||
}
|
||||
else if (IsFileExtension(fileName, ".raw"))
|
||||
{
|
||||
// TODO: Support additional file formats to export mesh vertex data
|
||||
|
||||
Reference in New Issue
Block a user