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
48 lines
1.2 KiB
2 months ago
|
#pragma once
|
||
|
|
||
|
#include <vulkan/vulkan.h>
|
||
|
#include <vector>
|
||
|
|
||
2 months ago
|
class Image;
|
||
2 months ago
|
class Instance;
|
||
2 months ago
|
|
||
|
struct SwapchainSupportDetails {
|
||
|
VkSurfaceCapabilitiesKHR capabilities {};
|
||
|
std::vector<VkSurfaceFormatKHR> formats {};
|
||
|
std::vector<VkPresentModeKHR> presentModes {};
|
||
|
};
|
||
|
SwapchainSupportDetails querySwapchainSupport(VkPhysicalDevice device, VkSurfaceKHR surface);
|
||
|
|
||
|
class Swapchain {
|
||
|
public:
|
||
2 months ago
|
explicit Swapchain();
|
||
2 months ago
|
~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 {};
|
||
|
|
||
2 months ago
|
std::vector<VkImageView> imageViews;
|
||
|
void createImageViews();
|
||
|
|
||
2 months ago
|
void createRenderpass();
|
||
2 months ago
|
|
||
|
Image* depthImage = nullptr;
|
||
|
void createDepthResources();
|
||
|
|
||
2 months ago
|
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();
|
||
|
};
|