Plasma Engine  2.0
Loading...
Searching...
No Matches
DearImgui.h
1#pragma once
2
3#ifdef BUILDSYSTEM_ENABLE_IMGUI_SUPPORT
4
5# include <Core/ResourceManager/ResourceHandle.h>
6# include <Foundation/Configuration/Singleton.h>
7# include <Foundation/Math/Size.h>
8# include <Foundation/Memory/CommonAllocators.h>
9# include <Foundation/Types/UniquePtr.h>
10# include <GameEngine/GameEngineDLL.h>
11# include <RendererCore/Pipeline/Declarations.h>
12
13# include <Imgui/imgui.h>
14
16
17struct ImGuiContext;
18
19using plImguiConfigFontCallback = plDelegate<void(ImFontAtlas&)>;
20using plImguiConfigStyleCallback = plDelegate<void(ImGuiStyle&)>;
21
33class PL_GAMEENGINE_DLL plImgui
34{
35 PL_DECLARE_SINGLETON(plImgui);
36
37public:
38 plImgui(plImguiConfigFontCallback configFontCallback = plImguiConfigFontCallback(),
39 plImguiConfigStyleCallback configStyleCallback = plImguiConfigStyleCallback());
40 ~plImgui();
41
43 void SetCurrentContextForView(const plViewHandle& hView);
44
46 plSizeU32 GetCurrentWindowResolution() const { return m_CurrentWindowResolution; }
47
50 void SetPassInputToImgui(bool bPassInput) { m_bPassInputToImgui = bPassInput; }
51
55 bool WantsInput() const { return m_bImguiWantsInput; }
56
58 ImFontAtlas& GetFontAtlas() { return *m_pSharedFontAtlas; }
59
60 void SetStyle();
61
62private:
63 friend class plImguiExtractor;
64 friend class plImguiRenderer;
65
66 void Startup(plImguiConfigFontCallback configFontCallback);
67 void Shutdown();
68
69 ImGuiContext* CreateContext();
70 void BeginFrame(const plViewHandle& hView);
71
72 plProxyAllocator m_Allocator;
73
74 bool m_bPassInputToImgui = true;
75 bool m_bImguiWantsInput = false;
76 plSizeU32 m_CurrentWindowResolution;
78
79 plImguiConfigStyleCallback m_ConfigStyleCallback;
80
81 plUniquePtr<ImFontAtlas> m_pSharedFontAtlas;
82
83 struct Context
84 {
85 ImGuiContext* m_pImGuiContext = nullptr;
86 plUInt64 m_uiFrameBeginCounter = -1;
87 plUInt64 m_uiFrameRenderCounter = -1;
88 };
89
90 plMutex m_ViewToContextTableMutex;
91 plHashTable<plViewHandle, Context> m_ViewToContextTable;
92};
93
94#endif
Definition HashTable.h:333
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
Definition Declarations.h:64
A generic delegate class which supports static functions and member functions.
Definition Delegate.h:76