Lugdunum  0.1.0
Gui.hpp
Go to the documentation of this file.
1 #pragma once
2 
22 #include <lug/System/Time.hpp>
23 #include <lug/Math/Vector.hpp>
24 
25 namespace lug {
26 namespace Graphics {
27 namespace Vulkan {
28 
29 namespace Render {
30  namespace DescriptorSetPool {
31  class GuiTexture;
32  class DescriptorSet;
33  };
34  class Window;
35 } // Render
36 
37 class Renderer;
38 
40 private:
41  // UI params are set via push constants
42  struct PushConstBlock {
43  lug::Math::Vec2f scale;
44  lug::Math::Vec2f translate;
45  };
46 
47  struct FrameData {
52 
53  std::vector<const Render::DescriptorSetPool::DescriptorSet*> texturesDescriptorSets;
54 
57 
60 
61  void* vertexMemoryPtr{nullptr};
62  void* indexMemoryPtr{nullptr};
63  };
64 
65 public:
67 
68  Gui(const Gui&) = delete;
69  Gui(Gui&& gui) = delete;
70 
71  Gui& operator=(const Gui&) = delete;
72  Gui& operator=(Gui&& fence) = delete;
73 
74  ~Gui();
75 
76  void destroy();
77 
78  bool init(const std::vector<API::ImageView>& imageViews);
79  void initKeyMapping();
80  bool initFontsTexture();
81  bool initPipeline();
82  bool initFramebuffers(const std::vector<API::ImageView>&);
83 
84  void beginFrame(const lug::System::Time& elapsedTime);
85  bool endFrame(const std::vector<VkSemaphore>& waitSemaphores, uint32_t currentImageIndex);
86 
87  bool processEvent(const lug::Window::Event event);
88 
89  const Vulkan::API::Semaphore& getSemaphore(uint32_t currentImageIndex) const;
90 
91 private:
92  bool updateBuffers(uint32_t currentImageIndex);
93  bool initFrameData();
94 
95 private:
98 
99  const API::Queue* _graphicQueue{nullptr};
100  const API::Queue* _transferQueue{nullptr};
101 
102  std::unique_ptr<Render::DescriptorSetPool::GuiTexture> _texturesDescriptorSetPool;
103 
104  API::CommandPool _graphicQueueCommandPool{};
105  API::CommandPool _transferQueueCommandPool{};
106 
108 
111 
112  std::vector<FrameData> _framesData;
113 };
114 
115 } // Vulkan
116 } // Graphics
117 } // lug
Represents an event.
Definition: Event.hpp:89
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Texture > _fontTexture
Definition: Gui.hpp:107
API::GraphicsPipeline _pipeline
Definition: Gui.hpp:110
Vulkan::API::Buffer indexBuffer
Definition: Gui.hpp:59
Vulkan::API::DeviceMemory indexMemory
Definition: Gui.hpp:56
lug::Graphics::Vulkan::Render::Window & _window
Definition: Gui.hpp:97
Vulkan::API::DeviceMemory vertexMemory
Definition: Gui.hpp:55
Vulkan::API::Semaphore semaphore
Definition: Gui.hpp:49
Vulkan::API::CommandBuffer commandBuffer
Definition: Gui.hpp:51
Vulkan::API::Fence fence
Definition: Gui.hpp:50
API::Framebuffer framebuffer
Definition: Gui.hpp:48
std::vector< FrameData > _framesData
Definition: Gui.hpp:112
lug::Graphics::Vulkan::Renderer & _renderer
Definition: Gui.hpp:96
Vulkan::API::Buffer vertexBuffer
Definition: Gui.hpp:58
std::vector< const Render::DescriptorSetPool::DescriptorSet * > texturesDescriptorSets
Definition: Gui.hpp:53
std::unique_ptr< Render::DescriptorSetPool::GuiTexture > _texturesDescriptorSetPool
Definition: Gui.hpp:102
API::PipelineLayout _pipelineLayout
Definition: Gui.hpp:109