#pragma once #include #include #include "types.h" #include "util.h" // NOTE: wrapper for stb_image struct util_image { i32 w; i32 h; i32 bits_per_channel; i32 num_channels; uint data_len; u8* pixels; u64 filepath_hash; // FIXME: should use a pointer here, and just add the length of file_path // onto the allocation for util_image char file_path[256]; }; // NOTE: wrapper for tinygltf https://github.com/syoyo/tinygltf // https://github.com/KhronosGroup/glTF struct mesh { u32 num_vertices; u32 num_indices; glm::vec3* vertices; glm::vec3* normals; glm::vec2* uvs; glm::vec3* colors; u16* indices; // NOTE: u16 to match tinygltf library output glm::mat4* xform; }; #define MAX_PATH_SIZE 256 struct model { char* filepath; u64 filepath_hash; uint num_meshes; mesh* meshes; util_image* diffuse_texture; }; struct Assets { u32 num_models; u32 max_models; model* models; u32 num_textures; u32 max_textures; util_image* textures; }; model* assetLoadFromFile(Assets* assets, memory_arena* arena, const char* filename); model* assetGetCached(Assets* assets, u64 path_hash);