CGUIManager.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <ionCore.h>
5 #include <ionWindow.h>
6 #include <ionGraphics.h>
7 
8 #include "imGUI.h"
9 
10 
11 namespace ion
12 {
13 
14  class CGUIManager : public Singleton<CGUIManager>, public IEventListener
15  {
16 
17  public:
18 
19  bool Init(CWindow * Window, float const DefaultFontSize = 18.f);
20  void Shutdown();
21  void NewFrame();
22  void Draw();
23 
24  template <typename... Args>
25  void Text(vec2i const & Position, color3i const & Color, char const * const Format, Args const &... args)
26  {
27  TextUnformatted(Position, Color, tfm::format(Format, args...));
28  }
29 
30  void TextUnformatted(vec2i const & Position, color3i const & Color, string const & Text);
31 
32  void OnEvent(IEvent & Event);
33  static ImTextureID GetTextureID(SharedPointer<Graphics::ITexture2D> const Texture);
34 
35  ImGuiIO & IO = ImGui::GetIO();
36 
37  protected:
38 
39  void AddFontFromFile(string const & FileName, float const Size);
40 
41  void DrawCallback(ImDrawData* draw_data);
42  void CreateFontsTexture();
43  bool CreateDeviceObjects();
44 
45  size_t const StartVboMaxSize = 20000;
46 
47  CWindow * Window = nullptr;
48  double Time = 0;
49  bool MouseWasPressed[3];
50  bool MouseHeld[3];
51  float MouseWheel = 0;
53  int ShaderHandle = 0, VertHandle = 0, FragHandle = 0;
57 
58  struct SDrawText
59  {
62  string Text;
63  };
64 
65  vector<SDrawText> TextQueue;
66 
67  private:
68 
69  friend class Singleton<CGUIManager>;
70 
71  CGUIManager();
72 
73  friend void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data);
74  friend char const * ImGui_ImplGlfwGL3_GetClipboardText(void * user_data);
75  friend void ImGui_ImplGlfwGL3_SetClipboardText(void * user_data, char const * text);
76 
77  };
78 
79 }
bool MouseWasPressed[3]
Definition: CGUIManager.h:49
void Shutdown()
Definition: CGUIManager.cpp:331
void DrawCallback(ImDrawData *draw_data)
Definition: CGUIManager.cpp:13
color3i Color
Definition: CGUIManager.h:61
void CreateFontsTexture()
Definition: CGUIManager.cpp:167
bool CreateDeviceObjects()
Definition: CGUIManager.cpp:200
int AttribLocationPosition
Definition: CGUIManager.h:55
CWindow * Window
Definition: CGUIManager.h:47
void OnEvent(IEvent &Event)
Definition: CGUIManager.cpp:107
int AttribLocationTex
Definition: CGUIManager.h:54
void Draw()
Definition: CGUIManager.cpp:409
uint VboHandle
Definition: CGUIManager.h:56
string Text
Definition: CGUIManager.h:62
uint ElementsHandle
Definition: CGUIManager.h:56
static ImTextureID GetTextureID(SharedPointer< Graphics::ITexture2D > const Texture)
Definition: CGUIManager.cpp:194
void NewFrame()
Definition: CGUIManager.cpp:361
bool MouseHeld[3]
Definition: CGUIManager.h:50
Definition: CCatmullRomAdvancedSplineInterpolator.h:7
void AddFontFromFile(string const &FileName, float const Size)
Definition: CGUIManager.cpp:188
uint VaoHandle
Definition: CGUIManager.h:56
Definition: IEvent.h:5
unsigned int uint
Definition: ionTypes.h:42
friend char const * ImGui_ImplGlfwGL3_GetClipboardText(void *user_data)
Definition: CGUIManager.cpp:285
Base class for Singleton design pattern implementation.
Definition: Singleton.h:13
Definition: CWindow.h:16
friend void ImGui_ImplGlfwGL3_SetClipboardText(void *user_data, char const *text)
Definition: CGUIManager.cpp:291
Definition: IEventListener.h:8
float MouseWheel
Definition: CGUIManager.h:51
int AttribLocationColor
Definition: CGUIManager.h:55
vec2i Position
Definition: CGUIManager.h:60
void Text(vec2i const &Position, color3i const &Color, char const *const Format, Args const &...args)
Definition: CGUIManager.h:25
size_t const StartVboMaxSize
Definition: CGUIManager.h:45
int AttribLocationProjMtx
Definition: CGUIManager.h:54
friend void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData *draw_data)
Definition: CGUIManager.cpp:279
double Time
Definition: CGUIManager.h:48
int VertHandle
Definition: CGUIManager.h:53
void TextUnformatted(vec2i const &Position, color3i const &Color, string const &Text)
Definition: CGUIManager.cpp:432
int ShaderHandle
Definition: CGUIManager.h:53
int FragHandle
Definition: CGUIManager.h:53
bool Init(CWindow *Window, float const DefaultFontSize=18.f)
Definition: CGUIManager.cpp:297
ImGuiIO & IO
Definition: CGUIManager.h:35
Definition: CGUIManager.h:58
std::shared_ptr< T > SharedPointer
Definition: ionSmartPointer.h:25
vector< SDrawText > TextQueue
Definition: CGUIManager.h:65
uint FontTexture
Definition: CGUIManager.h:52
int AttribLocationUV
Definition: CGUIManager.h:55
Definition: CGUIManager.h:14