From 15069341c7c8c36c7371ea1de4b63ed52034b3a8 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Mon, 12 Sep 2022 22:04:54 +0200 Subject: Fix texture uploading bug --- src/gltf.cpp | 4 ++-- src/vk-renderer.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gltf.cpp b/src/gltf.cpp index 537e4e1..9b55cbb 100644 --- a/src/gltf.cpp +++ b/src/gltf.cpp @@ -118,7 +118,7 @@ void gltf::load_textures(const std::filesystem::path &path) { const auto &gltf_image = gltf_images[image_index]; auto filepath = (path / gltf_image["uri"].get()).string(); auto& image = images[image_index]; - image.data = stbi_load(filepath.c_str(), &image.x, &image.y, &image.channels, 4); + image.data = stbi_load(filepath.c_str(), &image.width, &image.height, &image.channels, 4); } // const auto &gltf_samplers = gltf_json["samplers"]; @@ -143,7 +143,7 @@ void gltf::load_textures(const std::filesystem::path &path) { // sampler = samplers[sampler_index]; // } - auto *texture = vkrenderer::create_2d_texture(static_cast(image.x), static_cast(image.y), VK_FORMAT_R8G8B8A8_UNORM, sampler); + auto *texture = vkrenderer::create_2d_texture(static_cast(image.width), static_cast(image.height), VK_FORMAT_R8G8B8A8_UNORM, sampler); texture->update(image.data); diff --git a/src/vk-renderer.cpp b/src/vk-renderer.cpp index 54c667f..77e461d 100644 --- a/src/vk-renderer.cpp +++ b/src/vk-renderer.cpp @@ -130,7 +130,6 @@ void vkrenderer::update_images() { vkrenderer::api.image_barrier(command_buffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, texture->device_image); vkrenderer::api.copy_buffer(command_buffer, staging_buffer->device_buffer, texture->device_image, 0, offset); vkrenderer::api.image_barrier(command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, texture->device_image); - break; } vkrenderer::api.end_record(command_buffer); -- cgit v1.3