From 75337ae1c59e8b2c3bc6fbcd7ccafc7a8205d6b2 Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Fri, 23 Dec 2022 15:02:39 -0300 Subject: feat Add size to projections in 2D views --- src/vk/view_2d.cpp | 9 ++++++--- src/vk/view_2d.hpp | 3 ++- src/vk/view_3d.cpp | 5 +++-- src/vk/view_3d.hpp | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/vk') diff --git a/src/vk/view_2d.cpp b/src/vk/view_2d.cpp index a80cc89..b6f208c 100644 --- a/src/vk/view_2d.cpp +++ b/src/vk/view_2d.cpp @@ -101,8 +101,8 @@ load_resources_to_descriptor_sets_2d(void *obj) VK::UBOView2D ubo_view_2d; ubo_view_2d.proj = glm::ortho( - 0.0f, self->region.z, - 0.0f, self->region.w, + 0.0f, self->projection_width, + 0.0f, self->projection_height, 0.0f, 100.0f); self->ub_2d[i].copy_data(&ubo_view_2d); } @@ -122,7 +122,10 @@ const CommandChain View2D::descriptor_sets_loader{ {&load_resources_to_descriptor_sets_2d, nullptr} }; -View2D::View2D(glm::vec4 region): +View2D::View2D( + glm::vec4 region, float projection_width, float projection_height): + projection_width{projection_width}, + projection_height{projection_height}, region{region}, descriptor_pool{VK_NULL_HANDLE}, rectangles_to_draw{cg_core.vk_swapchain->images_count}, diff --git a/src/vk/view_2d.hpp b/src/vk/view_2d.hpp index f49c3be..caa3d0f 100644 --- a/src/vk/view_2d.hpp +++ b/src/vk/view_2d.hpp @@ -31,6 +31,7 @@ namespace VK struct View2D { glm::vec4 region; + float projection_width, projection_height; // FIXME: if these vectors get resized, they can cause a segmentation fault! std::vector ub_2d; @@ -43,7 +44,7 @@ struct View2D std::unordered_map, std::vector>> sprites_to_draw; - View2D(glm::vec4 region); + View2D(glm::vec4 region, float projection_width, float projection_height); virtual ~View2D(); void diff --git a/src/vk/view_3d.cpp b/src/vk/view_3d.cpp index 39d1159..d9e9844 100644 --- a/src/vk/view_3d.cpp +++ b/src/vk/view_3d.cpp @@ -122,8 +122,9 @@ const CommandChain descriptor_sets_loader{ namespace VK { -View3D::View3D(glm::vec4 region): - View2D{region}, +View3D::View3D( + glm::vec4 region, float projection_width, float projection_height): + View2D{region, projection_width, projection_height}, 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 ba08957..1d51070 100644 --- a/src/vk/view_3d.hpp +++ b/src/vk/view_3d.hpp @@ -32,7 +32,7 @@ struct View3D: public View2D std::shared_ptr camera_position; std::shared_ptr camera_rotation; - View3D(glm::vec4 region); + View3D(glm::vec4 region, float projection_width, float projection_height); ~View3D(); void -- cgit v1.2.3