diff options
author | Frederico Linhares <fred@linhares.blue> | 2023-10-26 15:21:11 -0300 |
---|---|---|
committer | Frederico Linhares <fred@linhares.blue> | 2023-10-27 17:27:36 -0300 |
commit | c4efa865f359c5c9e365d5faa8ae3c88f3657cb7 (patch) | |
tree | 6beeadf7a5eec70dccfb42cfd580fa63a11993ed /src/vk | |
parent | ba447583c74d44c6b07c5409918207157f921efe (diff) |
feat Create an interface to change field of view
Diffstat (limited to 'src/vk')
-rw-r--r-- | src/vk/graphics_pipeline_3d.cpp | 2 | ||||
-rw-r--r-- | src/vk/view_3d.cpp | 8 | ||||
-rw-r--r-- | src/vk/view_3d.hpp | 1 |
3 files changed, 3 insertions, 8 deletions
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<glm::vec3>(0.0f, 0.0f, 0.0f)}, camera_rotation{std::make_shared<glm::vec3>(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<UniformBuffer> ub_3d; |