From 2d16fbd7e235bf2cc96d451469d8d39cae1917c3 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Thu, 8 Sep 2022 23:04:06 +0200 Subject: First render using new texture uploading system --- src/gltf.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/gltf.cpp') diff --git a/src/gltf.cpp b/src/gltf.cpp index 882a64b..64e5644 100644 --- a/src/gltf.cpp +++ b/src/gltf.cpp @@ -69,7 +69,7 @@ void gltf::load_meshes() { const auto &primitives = gltf_meshes[mesh_index]["primitives"]; for (const auto &primitive : primitives) { - auto material = materials[primitive["material"].get()]; + auto& material = materials[primitive["material"].get()]; mesh.add_submesh(load_primitive(primitive), material); } @@ -121,13 +121,14 @@ void gltf::load_textures(const std::filesystem::path &path) { image.data = stbi_load(filepath.c_str(), &image.x, &image.y, &image.n, 4); } - const auto &gltf_samplers = gltf_json["samplers"]; - auto samplers_count = gltf_samplers.size(); - std::vector samplers{samplers_count}; + // const auto &gltf_samplers = gltf_json["samplers"]; + // auto samplers_count = gltf_samplers.size(); + // std::vector samplers{samplers_count}; - for (size_t sampler_index = 0; sampler_index < samplers_count; sampler_index++) { - samplers[sampler_index] = vkrenderer::create_sampler(VK_FILTER_LINEAR, VK_SAMPLER_ADDRESS_MODE_REPEAT); - } + Sampler* sampler = vkrenderer::create_sampler(VK_FILTER_LINEAR, VK_SAMPLER_ADDRESS_MODE_REPEAT); + // for (size_t sampler_index = 0; sampler_index < samplers_count; sampler_index++) { + // samplers[sampler_index] = vkrenderer::create_sampler(VK_FILTER_LINEAR, VK_SAMPLER_ADDRESS_MODE_REPEAT); + // } const auto &gltf_textures = gltf_json["textures"]; auto textures_count = gltf_textures.size(); @@ -137,18 +138,15 @@ void gltf::load_textures(const std::filesystem::path &path) { auto gltf_texture = gltf_textures[texture_index]; auto& image = images[gltf_texture["source"].get()]; - Sampler *sampler = nullptr; - if (gltf_texture.contains("sampler")) { - auto sampler_index = gltf_texture["sampler"].get(); - sampler = samplers[sampler_index]; - } + // if (gltf_texture.contains("sampler")) { + // auto sampler_index = gltf_texture["sampler"].get(); + // sampler = samplers[sampler_index]; + // } auto *texture = vkrenderer::create_2d_texture(static_cast(image.x), static_cast(image.y), VK_FORMAT_R8G8B8A8_UNORM, sampler); texture->update(image.data); - stbi_image_free(image.data); - textures[texture_index] = texture; } } -- cgit v1.3