TheAtlasEngine
 
Loading...
Searching...
No Matches
vk_imgui.hpp
1#pragma once
2#include <string>
3#include <vulkan/vulkan.h>
4#include <drivers/vulkan-cpp/vk_swapchain.hpp>
5#include <GLFW/glfw3.h>
6#include <drivers/vulkan-cpp/vk_driver.hpp>
7#include <drivers/vulkan-cpp/vk_swapchain.hpp>
8#include <core/window.hpp>
9#include <vulkan-cpp/descriptor_resource.hpp>
10#include <vulkan-cpp/command_buffer.hpp>
11#include <vulkan-cpp/texture.hpp>
12#include <vulkan-cpp/pipeline.hpp>
13#include <vulkan-cpp/shader_resource.hpp>
14
15namespace atlas::vk {
16 struct hud_data {
17 float playerHealth = 100.0f;
18 int playerScore = 0;
19 float fps = 0.0f;
20 std::string currentWeapon = "Assault Rifle";
21 // Add more data as needed
22 };
23
25 public:
26 imgui_context() = default;
27 imgui_context(const ref<window>& p_window_ctx);
28
29 void create(GLFWwindow* p_window_handler,
30 const uint32_t& p_image_size,
31 const VkRenderPass& p_current_renderpass);
32
33 void begin(const VkCommandBuffer& p_current,
34 const uint32_t& p_current_frame_idx);
35
36 void end();
37
38 // HUD Example, using this to test if imgui initialization works
39 // note: experiemental, for testing imgui with new vulkan implementation
40 // Proper API I want to have this be in atlas::ui::hud namespace
41 // API Usage: ui::hud::health_bar(float)
42 // If users have custom components they want to register to the UI, then
43 // do:
44 /*
45 template<typename UComponent, typename UType>
46 void custom_hud_component(UComponent* p_component,, UType p_type) {
47 // then prob do something lik this: use template to associate
48 struct component and the data, with type specified
49 imgui::progress_bar((p_component)->*p_data);
50 }
51
52 User-side would be the following:
53 struct custom_component_heatlh {
54 uint32_t health_data = 10;
55 };
56 some_entity->set<custom_component_heatlh>({});
57 const custom_component_health* player_hp =
58 some_entity.get<custom_component_heatlh>();
59
60 // Through this specifications the UI will now apply this to the hud
61 // Questions that needs to be talked here are the following points:
62 1.) How will users specify UI component uses?
63 * Position of HUD
64 * Handling alignment of the HUD
65 2.) Ease of usability with minimal specifications on user-side for
66 getting HUD's to work 3.) Making a class be optional, meaning have
67 this be through imgui's API's as a function 4.) Asking if its needed
68 to be represented as a class atlas::ui::hud::health_bar(player_hp,
69 &custom_component_health::health_data)
70 */
71 void draw_hud(const hud_data& p_test,
72 const window_settings& p_settings);
73
74 [[nodiscard]] ::vk::command_buffer imgui_active_command() const {
75 return m_viewport_command_buffers[m_current_frame_index];
76 }
77 void destroy();
78
79 private:
80 VkInstance m_instance = nullptr;
81 VkPhysicalDevice m_physical = nullptr;
82 vk_driver m_driver{};
83 uint32_t m_current_frame_index = 0;
84 VkSwapchainKHR m_current_swapchain_handler = nullptr;
85 VkDescriptorPool m_desc_pool = nullptr;
86 VkCommandBuffer m_current = nullptr;
87 std::vector<::vk::command_buffer> m_viewport_command_buffers;
88 };
89};
Definition vk_imgui.hpp:24
logical device implementation wrapper around the VkDevice
Definition vk_driver.hpp:20
Definition vk_imgui.hpp:16
settings for specification for atlas::window
Definition types.hpp:9