NarcEngine 0.1.1
C++ Vulkan game engine
 
Loading...
Searching...
No Matches
SwapChain.h
1#pragma once
2
3#include <vulkan/vulkan.h>
4
5#include "RenderPass.h"
6#include "renderer/DepthResources.h"
7
8namespace narc_engine {
9 class DeviceHandler;
10 class Window;
11
12 class SwapChain : public DeviceComponent
13 {
14 public:
15 const VkExtent2D& getSwapChainExtent() const { return m_swapChainExtent; }
16 const RenderPass* getRenderPass() const { return m_renderPass.get(); }
17 const VkSwapchainKHR& getSwapChain() const { return m_swapChain; }
18
19 void create();
20 void createFramebuffers();
21
22 VkRenderPassBeginInfo getRenderPassBeginInfos(uint32_t imageIndex) const;
23 VkResult acquireNextImage(const VkSemaphore& semaphore, uint32_t* imageIndex);
24 void reCreate();
25
26 void cleanSwapChain();
27 void cleanRenderPass();
28
29 private:
30 VkSwapchainKHR m_swapChain;
31 std::vector<VkImage> m_swapChainImages;
32 VkFormat m_swapChainImageFormat;
33 VkExtent2D m_swapChainExtent;
34 std::vector<VkImageView> m_swapChainImageViews;
35 std::vector<VkFramebuffer> m_swapChainFramebuffers;
36
37 std::unique_ptr<DepthResources> m_depthResources;
38 std::unique_ptr<RenderPass> m_renderPass;
39
40 const Window* m_window = nullptr;
41
42 void createSwapChain();
43 void createImageViews();
44 static VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
45 static VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes);
46 VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities) const;
47 };
48}
Definition DeviceHandler.h:11
Definition RenderPass.h:15
Definition SwapChain.h:13
Definition Window.h:12