#include "imgui_layer.hpp" #include #include #include namespace coop { ImGuiLayer::~ImGuiLayer() { if (initialized_) { ImGui_ImplDX11_Shutdown(); ImGui_ImplWin32_Shutdown(); ImGui::DestroyContext(); initialized_ = false; } } bool ImGuiLayer::init(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* context) { IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); io.IniFilename = nullptr; // don't litter the cwd with imgui.ini during the spike ImGui::StyleColorsDark(); if (!ImGui_ImplWin32_Init(hwnd)) { return false; } if (!ImGui_ImplDX11_Init(device, context)) { return false; } initialized_ = true; return true; } void ImGuiLayer::begin_frame() { ImGui_ImplDX11_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); } void ImGuiLayer::end_frame() { ImGui::Render(); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); } } // namespace coop