@@ -36,11 +36,14 @@ class ContextVulkan
3636 ~ContextVulkan ();
3737
3838 /* *
39- * TODO: This should not be public imo . The Vulkan context should only be exposed to the window.
39+ * TODO: This should not be public. The Vulkan context should only be exposed to the window.
4040 * Calling this function from the static `getInstance().draw()` can break stuff.
4141 */
4242 void draw ();
4343
44+ // TODO: should not be public, remove once events are implemented
45+ void setFrameBufferResized (bool value) noexcept { m_frameBufferResized = value; }
46+
4447 static void createInstance (GLFWwindow* windowHandle);
4548 static ContextVulkan& getInstance ();
4649
@@ -121,10 +124,10 @@ class ContextVulkan
121124 explicit ContextVulkan (GLFWwindow* windowHandle);
122125
123126 void createInstance ();
124- void createSurface (GLFWwindow* windowHandle );
127+ void createSurface ();
125128 void pickPhysicalDevice ();
126129 void createLogicalDevice ();
127- void createSwapChain (GLFWwindow* windowHandle );
130+ void createSwapChain ();
128131 void createImageViews ();
129132 void createRenderPass ();
130133 void createGraphicsPipeline ();
@@ -135,13 +138,17 @@ class ContextVulkan
135138 void createCommandBuffers ();
136139 void createSyncObject ();
137140
141+ void recreateSwapChain ();
138142 void createBuffer (vk::DeviceSize size, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags properties,
139143 vk::Buffer& outBuffer, vk::DeviceMemory& outDeviceMemory);
140144 void copyBuffer (const vk::Buffer& sourceBuffer, vk::Buffer& destinationBuffer, vk::DeviceSize size);
141145
146+ void cleanupSwapchain (vk::SwapchainKHR& swapchain);
147+ void cleanupSwapchainSubObjects ();
148+
142149 void chooseSwapSurfaceFormat ();
143150 void chooseSwapPresentMode ();
144- void chooseSwapExtent (GLFWwindow* windowHandle );
151+ void chooseSwapExtent ();
145152
146153 [[nodiscard]] uint32_t findMemoryType (uint32_t typeFilter, vk::MemoryPropertyFlags properties) const ;
147154
@@ -152,6 +159,9 @@ class ContextVulkan
152159
153160 // TODO: cache image count used in framebuffers, swap-chain, etc
154161
162+ // TODO: the ContextVulkan should not contain the raw window handle, maybe a Window reference though
163+ GLFWwindow* m_windowHandle;
164+
155165 vk::Instance m_instance{};
156166 vk::PhysicalDevice m_physicalDevice{};
157167 vk::Device m_device{};
@@ -164,10 +174,10 @@ class ContextVulkan
164174 vk::Queue m_graphicsQueue{};
165175 vk::Queue m_presentQueue{};
166176
167- vk::SwapchainKHR m_swapChain {};
168- std::vector<vk::Image> m_swapChainImages {};
169- std::vector<vk::ImageView> m_swapChainImageViews {};
170- vk::Format m_swapChainFormat {};
177+ vk::SwapchainKHR m_swapchain {};
178+ std::vector<vk::Image> m_swapchainImages {};
179+ std::vector<vk::ImageView> m_swapchainImageViews {};
180+ vk::Format m_swapchainFormat {};
171181
172182 vk::Viewport m_viewport{};
173183 vk::RenderPass m_renderPass{};
@@ -176,9 +186,9 @@ class ContextVulkan
176186
177187 QueueFamilyIndices m_queueFamilyIndices{};
178188 QueueFamilyPropertiesList m_queueFamilyProperties{};
179- SwapChainSupportDetails m_swapChainSupport {};
189+ SwapChainSupportDetails m_swapchainSupport {};
180190
181- std::vector<vk::Framebuffer> m_swapChainFrameBuffers {};
191+ std::vector<vk::Framebuffer> m_swapchainFrameBuffers {};
182192
183193 vk::CommandPool m_commandPool{};
184194 std::vector<vk::CommandBuffer> m_commandBuffers{};
@@ -196,6 +206,8 @@ class ContextVulkan
196206 static const size_t s_maxFramesInFlight;
197207 //
198208
209+ bool m_frameBufferResized{false };
210+
199211 template <typename T>
200212 static constexpr vk::IndexType getIndexType ()
201213 {
0 commit comments