initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "VulkanContext.hpp"
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
class Swapchain
|
||||
{
|
||||
public:
|
||||
Swapchain(
|
||||
VkDevice device,
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkSurfaceKHR surface,
|
||||
VkRenderPass renderPass,
|
||||
VkPresentModeKHR preferredPresentMode,
|
||||
uint32_t windowWidth,
|
||||
uint32_t windowHeight);
|
||||
|
||||
~Swapchain();
|
||||
|
||||
Swapchain(const Swapchain&) = delete;
|
||||
Swapchain& operator=(const Swapchain&) = delete;
|
||||
|
||||
void recreate(
|
||||
VkRenderPass renderPass,
|
||||
uint32_t windowWidth,
|
||||
uint32_t windowHeight);
|
||||
|
||||
VkSwapchainKHR handle() const { return m_swapchain; }
|
||||
VkExtent2D extent() const { return m_extent; }
|
||||
VkFormat imageFormat() const { return m_surfaceFormat.format; }
|
||||
uint32_t imageCount() const { return m_imageCount; }
|
||||
|
||||
const std::vector<VkImageView>& imageViews() const { return m_imageViews; }
|
||||
const std::vector<VkFramebuffer>& framebuffers() const { return m_framebuffers; }
|
||||
|
||||
void release();
|
||||
|
||||
private:
|
||||
void createSwapchain(
|
||||
uint32_t windowWidth,
|
||||
uint32_t windowHeight);
|
||||
void createImageViews();
|
||||
void createFramebuffers(
|
||||
VkRenderPass renderPass);
|
||||
void destroy();
|
||||
|
||||
VkDevice m_device;
|
||||
VkPhysicalDevice m_physicalDevice;
|
||||
VkSurfaceKHR m_surface;
|
||||
|
||||
VkSwapchainKHR m_swapchain = VK_NULL_HANDLE;
|
||||
VkPresentModeKHR m_preferredPresentMode =
|
||||
VK_PRESENT_MODE_FIFO_KHR;
|
||||
VkExtent2D m_extent{};
|
||||
VkSurfaceFormatKHR m_surfaceFormat{};
|
||||
VkPresentModeKHR m_presentMode =
|
||||
VK_PRESENT_MODE_FIFO_KHR;
|
||||
uint32_t m_imageCount = 0;
|
||||
|
||||
std::vector<VkImage> m_swapchainImages;
|
||||
std::vector<VkImageView> m_imageViews;
|
||||
std::vector<VkFramebuffer> m_framebuffers;
|
||||
};
|
||||
Reference in New Issue
Block a user