diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-05 02:21:00 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-05 02:21:00 +0100 |
commit | e4ed331cea817e55956200c9c116f8d11b54c86b (patch) | |
tree | ff152032ea715d1dbac39904c154baae6e9202d1 /ui/applicationBase.cpp | |
parent | Build and link imgui with sdl2 and opengl2 backends (diff) | |
download | ilt-e4ed331cea817e55956200c9c116f8d11b54c86b.tar.bz2 ilt-e4ed331cea817e55956200c9c116f8d11b54c86b.tar.xz ilt-e4ed331cea817e55956200c9c116f8d11b54c86b.zip |
Add imgui init and shutdown to appbase and gamemainwindow
Diffstat (limited to 'ui/applicationBase.cpp')
-rw-r--r-- | ui/applicationBase.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ui/applicationBase.cpp b/ui/applicationBase.cpp index 2be1f6c..3fa6e2b 100644 --- a/ui/applicationBase.cpp +++ b/ui/applicationBase.cpp @@ -1,9 +1,17 @@ #include "applicationBase.h" +#include "imgui_wrap.h" #include <SDL2/SDL.h> #include <stdexcept> ApplicationBase::ApplicationBase() { + initSDL(); + initImGUI(); +} + +void +ApplicationBase::initSDL() const +{ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) { throw std::runtime_error(SDL_GetError()); } @@ -24,7 +32,21 @@ ApplicationBase::ApplicationBase() setGlAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); } +void +ApplicationBase::initImGUI() const +{ + // Setup Dear ImGui context + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO & io = ImGui::GetIO(); + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable docking + io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable viewports +} + ApplicationBase::~ApplicationBase() { SDL_Quit(); + ImGui::DestroyContext(); } |