Lugdunum  0.1.0
Window.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
13 
14 namespace lug {
15 namespace Graphics {
16 namespace Vulkan {
17 
18 namespace API {
19 class QueueFamily;
20 } // API
21 
22 class Renderer;
23 
24 namespace Render {
25 
27 private:
30  int imageIdx = -1;
31  };
32 
33  struct FrameData {
34  API::Semaphore allDrawsFinishedSemaphore{};
35  std::vector<API::Semaphore> imageReadySemaphores{};
36  std::vector<API::CommandBuffer> cmdBuffers;
37  };
38 
39 public:
40  Window() = delete;
41 
43 
44  Window(const Window&) = delete;
45  Window(Window&&) = delete;
46 
47  Window& operator=(const Window&) = delete;
48  Window& operator=(Window&&) = delete;
49 
50  ~Window();
51 
52  bool pollEvent(lug::Window::Event&) override;
53 
54  bool beginFrame(const lug::System::Time& elapsedTime) override final;
55  bool endFrame() override final;
56 
57  const API::Swapchain& getSwapchain() const;
58 
59  ::lug::Graphics::Render::View* createView(::lug::Graphics::Render::View::InitInfo& initInfo) override final;
60 
61  bool render() override final;
62 
63  uint16_t getWidth() const override final;
64  uint16_t getHeight() const override final;
65 
66  static std::unique_ptr<Window> create(lug::Graphics::Vulkan::Renderer& renderer, Window::InitInfo& initInfo);
67 
68  bool initRender();
69  void destroyRender();
70 
71  bool initGui();
72 
73 private:
74  bool init(Window::InitInfo& initInfo);
75  bool initSurface();
76  bool initSwapchainCapabilities();
77  bool initPresentQueue();
78  bool initSwapchain();
79  bool initFramesData();
80 
81  bool buildBeginCommandBuffer();
82  bool buildEndCommandBuffer();
83  bool buildCommandBuffers();
84 
85 private:
86  InitInfo _initInfo;
87 
88  lug::Graphics::Vulkan::Renderer& _renderer;
89  API::Surface _surface{};
90  API::Swapchain _swapchain{};
91 
92  const API::Queue* _presentQueue{nullptr};
93  const API::QueueFamily* _presentQueueFamily{nullptr};
94  uint32_t _currentImageIndex{0};
95 
96  std::vector<FrameData> _framesData;
97 
98  std::vector<AcquireImageData> _acquireImageDatas;
99 
100  API::CommandPool _commandPool{};
101 
103 
105 };
106 
108 
109 } // Render
110 } // Vulkan
111 } // Graphics
112 } // lug
Represents an event.
Definition: Event.hpp:89
std::vector< AcquireImageData > _acquireImageDatas
Definition: Window.hpp:98
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
std::vector< FrameData > _framesData
Definition: Window.hpp:96
lug::Graphics::Vulkan::Gui _guiInstance
Definition: Window.hpp:102
std::unique_ptr< T, Deleter > unique_ptr
Definition: Memory.hpp:80
std::vector< API::CommandBuffer > cmdBuffers
Definition: Window.hpp:36
Class for graphics.
Definition: Graphics.hpp:25