jGL
Loading...
Searching...
No Matches
swapchain.h
Go to the documentation of this file.
1#ifndef SWAPCHAIN
2#define SWAPCHAIN
3
5#include <jLog/jLog.h>
6#include <sstream>
7
8#include <limits>
9#include <algorithm>
10#include <vector>
11
12namespace jGL::Vulkan
13{
15 {
16
17 public:
18
19 Swapchain() = default;
20
21 Swapchain(unsigned width, unsigned height, const Device & device, const VkSurfaceKHR & surface)
22 {
23 createSwapchain(width, height, device, surface);
24 }
25
26 void cleanupSwapchain(const Device & device);
27
28 void recreateSwapchain(unsigned width, unsigned height, const Device & device, const VkSurfaceKHR & surface);
29
30 const VkFormat & getImageFormat() const { return swapchainImageFormat; }
31 const VkExtent2D & getVkExtend2D() const { return swapchainExtent; }
32
33 const std::vector<VkImageView> & getVkImageViews() const { return swapchainImageViews; }
34
35 const VkSwapchainKHR & getVkSwapchainKHR() { return swapchain; }
36
37 private:
38
39 VkSwapchainKHR swapchain;
40 VkFormat swapchainImageFormat;
41 VkExtent2D swapchainExtent;
42
43 std::vector<VkImage> swapchainImages;
44
45 std::vector<VkImageView> swapchainImageViews;
46
47 void createSwapchain(unsigned width, unsigned height, const Device & device, const VkSurfaceKHR & surface);
48
49 VkSurfaceFormatKHR chooseSwapchainSurfaceFormat(const std::vector<VkSurfaceFormatKHR> & availableFormats);
50 VkPresentModeKHR chooseSwapchainPresentMode(const std::vector<VkPresentModeKHR> & availablePresentModes);
51 VkExtent2D chooseSwapExtent(unsigned width, unsigned height, const VkSurfaceCapabilitiesKHR & capabilities);
52 void createImageViews(const Device & device);
53
54 };
55}
56
57#endif /* SWAPCHAIN */
Definition device.h:10
Definition swapchain.h:15
Swapchain(unsigned width, unsigned height, const Device &device, const VkSurfaceKHR &surface)
Definition swapchain.h:21
const std::vector< VkImageView > & getVkImageViews() const
Definition swapchain.h:33
const VkFormat & getImageFormat() const
Definition swapchain.h:30
void cleanupSwapchain(const Device &device)
Definition swapchain.cpp:94
void recreateSwapchain(unsigned width, unsigned height, const Device &device, const VkSurfaceKHR &surface)
Definition swapchain.cpp:84
const VkSwapchainKHR & getVkSwapchainKHR()
Definition swapchain.h:35
const VkExtent2D & getVkExtend2D() const
Definition swapchain.h:31
Definition buffer.h:10