Lugdunum  0.1.0
Swapchain.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
9 
10 namespace lug {
11 namespace Graphics {
12 namespace Vulkan {
13 namespace API {
14 
15 namespace Builder {
16 class Swapchain;
17 } // Builder
18 
19 class Device;
20 class Queue;
21 class RenderPass;
22 
24  friend class Builder::Swapchain;
25 
26 public:
27  Swapchain() = default;
28 
29  Swapchain(const Swapchain&) = delete;
31 
32  Swapchain& operator=(const Swapchain&) = delete;
33  Swapchain& operator=(Swapchain&& Swapchain);
34 
35  ~Swapchain();
36 
37  explicit operator VkSwapchainKHR() const {
38  return _swapchain;
39  }
40 
41  void destroy();
42 
43  bool getNextImage(uint32_t *imageIndex, VkSemaphore semaphore = VK_NULL_HANDLE);
44  bool present(const Queue* presentQueue, uint32_t imageIndex, VkSemaphore semaphore = VK_NULL_HANDLE) const;
45 
46  const std::vector<Image>& getImages() const;
47  const std::vector<ImageView>& getImagesViews() const;
48 
49  const VkSurfaceFormatKHR& getFormat() const;
50  const VkExtent2D& getExtent() const;
51 
52  void setOutOfDate(bool outOfDate);
53  bool isOutOfDate() const;
54 
55 private:
56  explicit Swapchain(VkSwapchainKHR swapchain, const Device* device, const VkSurfaceFormatKHR& swapchainFormat, const VkExtent2D& extent);
57 
58  bool init();
59 
60 private:
61  VkSwapchainKHR _swapchain{VK_NULL_HANDLE};
62  const Device* _device{nullptr};
63 
64  std::vector<Image> _images;
65  std::vector<ImageView> _imagesViews;
66 
67  VkSurfaceFormatKHR _format;
68  VkExtent2D _extent;
69 
70  bool _outOfDate{false};
71 };
72 
74 
75 } // API
76 } // Vulkan
77 } // Graphics
78 } // lug
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
std::vector< ImageView > _imagesViews
Definition: Swapchain.hpp:65