PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
imgui_layer.h
1#pragma once
2
3#include "pixelbullet/application/layer.h"
4
5#include "pixelbullet/application/events/application_event.h"
6#include "pixelbullet/application/events/key_event.h"
7#include "pixelbullet/application/events/mouse_event.h"
8
9#include <imgui.h>
10#include <volk.h>
11
12#include <cstdint>
13#include <map>
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace pixelbullet
19{
20class Graphics;
21class Window;
22
23class ImGuiLayer : public Layer, public UiFrameLayer
24{
25public:
26 ImGuiLayer(Window& window, Graphics& graphics);
27 ~ImGuiLayer() = default;
28
29 virtual void OnAttach() override;
30 virtual void OnDetach() override;
31 virtual EventResult OnEvent(Event& e) override;
32
33 bool BeginUiFrame() override;
34 void CancelUiFrame() override;
35
36 bool Begin();
37 void CancelFrame();
38 void End(VkCommandBuffer commandBuffer);
39 ImTextureID GetRenderTargetTexture(std::string_view name);
40
41 void BlockEvents(bool block)
42 {
43 block_events_ = block;
44 }
45
46 void SetTheme();
47
48 uint32_t GetActiveWidgetID() const;
49
50private:
51 bool EnsureVulkanInitialized();
52 void CreateDescriptorPool(VkDevice device);
53 void DestroyRenderTargetTextures();
54
55 struct CachedRenderTargetTexture
56 {
57 std::vector<VkDescriptorSet> descriptor_sets;
58 std::vector<VkImageView> image_views;
59 std::vector<VkSampler> samplers;
60 };
61
62private:
63 bool block_events_ = true;
64 Window& window_;
65 Graphics& graphics_;
66 VkDescriptorPool descriptor_pool_ = VK_NULL_HANDLE;
67 VkRenderPass render_pass_ = VK_NULL_HANDLE;
68 uint32_t image_count_ = 0;
69 bool vulkan_initialized_ = false;
70 bool frame_started_ = false;
71 std::map<std::string, CachedRenderTargetTexture> render_target_textures_;
72};
73
74} // namespace pixelbullet
Definition event.h:72
Module that manages the Vulkan instance_, Surface, Window and the renderpass structure.
Definition graphics.h:36
Definition imgui_layer.h:24
Definition layer.h:26
Definition layer.h:17
Definition window.h:23