#pragma once #include #include class Image; class Instance; struct SwapchainSupportDetails { VkSurfaceCapabilitiesKHR capabilities {}; std::vector formats {}; std::vector presentModes {}; }; SwapchainSupportDetails querySwapchainSupport(VkPhysicalDevice device, VkSurfaceKHR surface); class Swapchain { public: explicit Swapchain(); ~Swapchain(); void recreateSwapchain(); void cleanupSwapchain(); VkRenderPass renderPass = VK_NULL_HANDLE; VkExtent2D extent {}; std::vector frameBuffers; VkSwapchainKHR handle = VK_NULL_HANDLE; private: std::vector images; VkFormat imageFormat {}; std::vector imageViews; void createImageViews(); void createRenderpass(); Image *depthImage = nullptr; void createDepthResources(); void createFramebuffers(); static VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector &availableFormats); static VkPresentModeKHR chooseSwapPresentMode(const std::vector &availablePresentModes); VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities); void createSwapchain(); };