Skip to content
Snippets Groups Projects
Commit d7c421d3 authored by Trevor Hollmann's avatar Trevor Hollmann
Browse files

[#26] Start implementing hack for loading single texture.

parent 5b87ee71
No related branches found
No related tags found
1 merge request!19Resolve "Asset Loading"
......@@ -95,6 +95,11 @@ typedef struct {
std::string name;
std::vector<VertexGroup> vertexGroups;
std::vector<Material> materials;
// FIXME Dirty hack to get one(!) texture for our cube demo
struct {
int w, h, ch; // width, height and channels of image
void *img; // raw data, free after use (deal with it)
} texture_hack;
} Mesh;
......
......@@ -170,6 +170,23 @@ int loadMesh(const std::string &path, Mesh &mesh) {
std::vector<Material> materials;
// FIXME HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
// fail quietly if there is no texture
if (object.textures.size()) {
const std::string mime_type("image/jpeg");
const fx::gltf::Texture &tex = object.textures[0];
const fx::gltf::Image &img = object.images[tex.source];
printf("texture name=%s sampler=%u source=%u\n",
tex.name.c_str(), tex.sampler, tex.source);
printf("image name=%s uri=%s mime=%s\n",
img.name.c_str(), img.uri.c_str(),
img.mimeType.c_str());
// URI is in img.uri
// TODO decode using stbimage lib and store in mesh.texture
}
// FIXME HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
mesh = { object.meshes[0].name, vertexGroups, materials };
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment