aboutsummaryrefslogtreecommitdiffstats
path: root/include/gltf.hpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2026-05-05 00:50:13 +0200
committerladevieq <ladevie.quentin@gmail.com>2026-05-05 00:50:49 +0200
commit37fdcb8a0f435c42f737252450626f2bd38bbd0f (patch)
tree7eeb45a2d2d08483409a04c74fbc74fb2bbcde9f /include/gltf.hpp
parent6818cbfe21beefc04e4a174d44a92159c34cead1 (diff)
Clean up around included files
Diffstat (limited to 'include/gltf.hpp')
-rw-r--r--include/gltf.hpp67
1 files changed, 34 insertions, 33 deletions
diff --git a/include/gltf.hpp b/include/gltf.hpp
index 1ccaf56..72d757c 100644
--- a/include/gltf.hpp
+++ b/include/gltf.hpp
@@ -3,59 +3,60 @@
#include <vector>
-#include <nlohmann/json.hpp>
-
-using json = nlohmann::json;
-
-#include "material.hpp"
+#include "utils.hpp"
+#include "handle.hpp"
#include "mesh.hpp"
+#include "material.hpp"
struct node {
- std::vector<node> children;
- Mesh* mesh = nullptr;
+ std::vector<uint32_t> children;
+ u32 mesh;
};
struct raw_image {
int32_t width;
int32_t height;
int32_t channels;
- uint8_t *data;
+ const uint8_t *data;
};
-namespace std::filesystem {
- class path;
-}
+struct buffer {
+ u8* bytes;
+ size_t size;
+};
class gltf {
public:
- gltf(const std::filesystem::path &filepath);
-
- node root_node;
-
-private:
-
- void load_node(uint32_t index, node &parent);
+ gltf(const char* filepath);
+ void deinit();
- void load_meshes();
+ std::vector<u32> root_nodes;
- Mesh::submesh load_primitive(const json &primitive);
-
- Mesh::attribute load_attribute(uint32_t accessor_index);
-
- void load_textures(const std::filesystem::path &path);
-
- void load_materials();
-
- json gltf_json;
+ std::vector<node> nodes;
std::vector<Mesh> meshes;
std::vector<material> materials;
-#ifdef API_TEST
std::vector<handle<device_texture>> textures;
// handle<device_sampler> samplers;
-#else
- std::vector<Texture*> textures;
-#endif // API_TEST
- std::vector<std::vector<uint8_t>> buffers;
+ std::vector<struct buffer> buffers;
+
+
+ // gbl only
+ struct glb_chunk {
+ u32 length;
+ u32 type;
+ u8 data[1];
+ };
+
+ struct glb_header {
+ u32 magic;
+ u32 version;
+ u32 length;
+ };
+ std::vector<struct glb_chunk*> chunks;
+ glb_header* header;
+
+ // TODO: remove
+ bool is_glb;
};
#endif