You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.2 KiB

#pragma once
#include <vulkan/vulkan.h>
#include <vector>
class Image;
class Instance;
struct SwapchainSupportDetails {
VkSurfaceCapabilitiesKHR capabilities {};
std::vector<VkSurfaceFormatKHR> formats {};
std::vector<VkPresentModeKHR> 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<VkFramebuffer> frameBuffers;
VkSwapchainKHR handle = VK_NULL_HANDLE;
private:
std::vector<VkImage> images;
VkFormat imageFormat {};
std::vector<VkImageView> imageViews;
void createImageViews();
void createRenderpass();
Image* depthImage = nullptr;
void createDepthResources();
void createFramebuffers();
static VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
static VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes);
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
void createSwapchain();
};