SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
ImGuiEngine Class Reference

#include <ImGuiWrapper.h>

Public Member Functions

 ImGuiEngine (std::string configDir, ImFontAtlas *fontAtlas)
 
 ~ImGuiEngine ()
 
ImGuiRendererrenderer () const
 
ImGuiContext * context () const
 

Private Member Functions

void init (const std::string &configPath)
 

Private Attributes

ImGuiRenderer_renderer {nullptr}
 
ImGuiContext * _context {nullptr}
 
std::string _iniFilename
 

Detailed Description

Wraps the following things:

  • Create ImGuiContext (which is shared over all instances of ImGuiWrapper)
  • Destroy ImGuiContext
  • Init general imgui stuff (e.g. define where to store ini file)
  • Load fonts (these are shared over the all ImGuiWrappers)
  • Instantiate renderer

Definition at line 93 of file ImGuiWrapper.h.

Constructor & Destructor Documentation

◆ ImGuiEngine()

ImGuiEngine::ImGuiEngine ( std::string  configDir,
ImFontAtlas *  fontAtlas 
)
inline

Definition at line 96 of file ImGuiWrapper.h.

97  {
98  _context = ImGui::CreateContext(fontAtlas);
99  init(configDir);
100 
101  // make sure fonts are loaded before texture for fonts is generated
102  //(here fonts are transferred with font atlas)
104  assert(_renderer);
105  }
ImGuiContext * _context
Definition: ImGuiWrapper.h:122
void init(const std::string &configPath)
ImGuiRenderer * _renderer
Definition: ImGuiWrapper.h:121

◆ ~ImGuiEngine()

ImGuiEngine::~ImGuiEngine ( )
inline

Definition at line 107 of file ImGuiWrapper.h.

108  {
109  if (_renderer)
110  delete _renderer;
111  ImGui::DestroyContext(_context);
112  _context = nullptr;
113  }

Member Function Documentation

◆ context()

ImGuiContext* ImGuiEngine::context ( ) const
inline

Definition at line 116 of file ImGuiWrapper.h.

116 { return _context; }

◆ init()

void ImGuiEngine::init ( const std::string &  configPath)
private

Definition at line 398 of file ImGuiWrapper.cpp.

399 {
400  ImGuiIO& io = _context->IO;
401  _iniFilename = configPath + "imgui.ini";
402  io.IniFilename = _iniFilename.c_str();
403 
404  io.KeyMap[ImGuiKey_Tab] = K_tab;
405  io.KeyMap[ImGuiKey_LeftArrow] = K_left;
406  io.KeyMap[ImGuiKey_RightArrow] = K_right;
407  io.KeyMap[ImGuiKey_UpArrow] = K_up;
408  io.KeyMap[ImGuiKey_DownArrow] = K_down;
409  io.KeyMap[ImGuiKey_PageUp] = K_pageUp;
410  io.KeyMap[ImGuiKey_PageDown] = K_pageUp;
411  io.KeyMap[ImGuiKey_Home] = K_home;
412  io.KeyMap[ImGuiKey_End] = K_end;
413  io.KeyMap[ImGuiKey_Delete] = K_delete;
414  io.KeyMap[ImGuiKey_Backspace] = K_backspace;
415  io.KeyMap[ImGuiKey_Enter] = K_enter;
416  io.KeyMap[ImGuiKey_Escape] = K_esc;
417  io.KeyMap[ImGuiKey_A] = 'A';
418  io.KeyMap[ImGuiKey_C] = 'C';
419  io.KeyMap[ImGuiKey_V] = 'V';
420  io.KeyMap[ImGuiKey_X] = 'X';
421  io.KeyMap[ImGuiKey_Y] = 'Y';
422  io.KeyMap[ImGuiKey_Z] = 'Z';
423 
424  // The screen size is set again in onResize
425  io.DisplaySize = ImVec2(0, 0);
426  io.DisplayFramebufferScale = ImVec2(1, 1);
427 }
@ K_down
Definition: SLEnums.h:25
@ K_delete
Definition: SLEnums.h:23
@ K_up
Definition: SLEnums.h:24
@ K_enter
Definition: SLEnums.h:20
@ K_esc
Definition: SLEnums.h:21
@ K_tab
Definition: SLEnums.h:19
@ K_end
Definition: SLEnums.h:29
@ K_right
Definition: SLEnums.h:26
@ K_pageUp
Definition: SLEnums.h:31
@ K_left
Definition: SLEnums.h:27
@ K_backspace
Definition: SLEnums.h:22
@ K_home
Definition: SLEnums.h:28
std::string _iniFilename
Definition: ImGuiWrapper.h:123

◆ renderer()

ImGuiRenderer* ImGuiEngine::renderer ( ) const
inline

Definition at line 115 of file ImGuiWrapper.h.

115 { return _renderer; }

Member Data Documentation

◆ _context

ImGuiContext* ImGuiEngine::_context {nullptr}
private

Definition at line 122 of file ImGuiWrapper.h.

◆ _iniFilename

std::string ImGuiEngine::_iniFilename
private

Definition at line 123 of file ImGuiWrapper.h.

◆ _renderer

ImGuiRenderer* ImGuiEngine::_renderer {nullptr}
private

Definition at line 121 of file ImGuiWrapper.h.


The documentation for this class was generated from the following files: