summaryrefslogtreecommitdiff
path: root/src/imgui_context.cpp
blob: 49b74caf80fadd7d9682c4dde2a6a105039d427a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "imgui_context.hpp"

#include <imgui/imgui_impl_opengl3.h>
#include <imgui/imgui_impl_sdl2.h>

namespace bookmouse {

ImguiContext::ImguiContext(GlContext& glContext, SdlContext& sdlContext, SdlMainWindow& mainWindow)
{
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();

    setIOFlag(ImGuiConfigFlags_NavEnableKeyboard);
    setIOFlag(ImGuiConfigFlags_NavEnableGamepad);

    ImGui::StyleColorsDark();
    // ImGui::StyleColorsLight();

    ImGui_ImplSDL2_InitForOpenGL(mainWindow.window(), glContext.context());
    ImGui_ImplOpenGL3_Init(sdlContext.glslVersion());
}

ImguiContext::~ImguiContext()
{
    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplSDL2_Shutdown();
    ImGui::DestroyContext();
}

void ImguiContext::setIOFlag(ImGuiConfigFlags_ flag)
{
    ImGui::GetIO().ConfigFlags |= flag;
}

const ImGuiIO& ImguiContext::getIO()
{
    return ImGui::GetIO();
}

} // namespace bookmouse