From c4efa865f359c5c9e365d5faa8ae3c88f3657cb7 Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Thu, 26 Oct 2023 15:21:11 -0300 Subject: feat Create an interface to change field of view --- src/vk/graphics_pipeline_3d.cpp | 2 +- src/vk/view_3d.cpp | 8 +------- src/vk/view_3d.hpp | 1 + 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src/vk') diff --git a/src/vk/graphics_pipeline_3d.cpp b/src/vk/graphics_pipeline_3d.cpp index d98a27d..6bfd559 100644 --- a/src/vk/graphics_pipeline_3d.cpp +++ b/src/vk/graphics_pipeline_3d.cpp @@ -341,7 +341,7 @@ GraphicsPipeline3D::draw( // Projection matrix. ubo_view_3d.proj = glm::perspective( - glm::radians(45.0f), + glm::radians(view->field_of_view), view->region.z / view->region.w, 0.1f, 100.0f); diff --git a/src/vk/view_3d.cpp b/src/vk/view_3d.cpp index 9040545..f9cfe5a 100644 --- a/src/vk/view_3d.cpp +++ b/src/vk/view_3d.cpp @@ -98,13 +98,6 @@ load_resources_to_descriptor_sets_3d(void *obj) vkUpdateDescriptorSets( cg_core.vk_device_with_swapchain->device, write_descriptors.size(), write_descriptors.data(), 0, nullptr); - - VK::UDOView3D ubo_view_3d; - ubo_view_3d.proj = glm::ortho( - 0.0f, self->region.z, - 0.0f, self->region.w, - 0.0f, 100.0f); - self->ub_3d[i].copy_data(&ubo_view_3d); } } @@ -125,6 +118,7 @@ namespace VK View3D::View3D( glm::vec4 region, float projection_width, float projection_height): View2D{region, projection_width, projection_height}, + field_of_view{45.0f}, camera_position{std::make_shared(0.0f, 0.0f, 0.0f)}, camera_rotation{std::make_shared(0.0f, 0.0f, 0.0f)} { diff --git a/src/vk/view_3d.hpp b/src/vk/view_3d.hpp index 1d51070..52146df 100644 --- a/src/vk/view_3d.hpp +++ b/src/vk/view_3d.hpp @@ -24,6 +24,7 @@ namespace VK struct View3D: public View2D { + float field_of_view; // FIXME: if this vector get resized, it can cause a segmentation fault! std::vector ub_3d; -- cgit v1.2.3