107 lines
No EOL
2.7 KiB
C++
107 lines
No EOL
2.7 KiB
C++
#include "Window.hpp"
|
|
#include "WindowContext.hpp"
|
|
|
|
#include "Graphics.hpp"
|
|
|
|
// -------- Debug UI -------- //
|
|
#include <imgui.h>
|
|
#include <imgui_impl_glfw.h>
|
|
#include <imgui_impl_opengl3.h>
|
|
#include <imgui_internal.h>
|
|
|
|
#include "implot.h"
|
|
|
|
namespace tp {
|
|
class DebugGUI::Context {
|
|
public:
|
|
ImGuiIO* io{};
|
|
ImGuiContext* ctx{};
|
|
};
|
|
}
|
|
|
|
using namespace tp;
|
|
|
|
DebugGUI::DebugGUI(Window* window) {
|
|
mContext = new Context();
|
|
|
|
IMGUI_CHECKVERSION();
|
|
mContext->ctx = ImGui::CreateContext();
|
|
mContext->io = &ImGui::GetIO();
|
|
|
|
// Initialize ImGui with GLFW and OpenGL
|
|
ImGui_ImplGlfw_InitForOpenGL(window->getContext()->window, true);
|
|
|
|
// ImGui_ImplGlfw_GetBackendData();
|
|
|
|
ImGui_ImplOpenGL3_Init("#version 330");
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
io.Fonts->AddFontFromFileTTF("rsc/Font.ttf", 20.f);
|
|
|
|
io.ConfigInputTrickleEventQueue = false;
|
|
|
|
// appearance
|
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
|
|
ImPlot::CreateContext();
|
|
|
|
return;
|
|
|
|
auto& colors = ImGui::GetStyle().Colors;
|
|
colors[ImGuiCol_WindowBg] = ImVec4{ 0.1f, 0.105f, 0.11f, 1.0f };
|
|
|
|
// Headers
|
|
colors[ImGuiCol_Header] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
|
|
colors[ImGuiCol_HeaderHovered] = ImVec4{ 0.3f, 0.305f, 0.31f, 1.0f };
|
|
colors[ImGuiCol_HeaderActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
|
|
// Buttons
|
|
colors[ImGuiCol_Button] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
|
|
colors[ImGuiCol_ButtonHovered] = ImVec4{ 0.3f, 0.305f, 0.31f, 1.0f };
|
|
colors[ImGuiCol_ButtonActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
|
|
// Frame BG
|
|
colors[ImGuiCol_FrameBg] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
|
|
colors[ImGuiCol_FrameBgHovered] = ImVec4{ 0.3f, 0.305f, 0.31f, 1.0f };
|
|
colors[ImGuiCol_FrameBgActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
|
|
// Tabs
|
|
colors[ImGuiCol_Tab] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
colors[ImGuiCol_TabHovered] = ImVec4{ 0.38f, 0.3805f, 0.381f, 1.0f };
|
|
colors[ImGuiCol_TabActive] = ImVec4{ 0.28f, 0.2805f, 0.281f, 1.0f };
|
|
colors[ImGuiCol_TabUnfocused] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
colors[ImGuiCol_TabUnfocusedActive] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
|
|
|
|
// Title
|
|
colors[ImGuiCol_TitleBg] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
colors[ImGuiCol_TitleBgActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
colors[ImGuiCol_TitleBgCollapsed] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
|
|
}
|
|
|
|
DebugGUI::~DebugGUI() {
|
|
ImPlot::DestroyContext();
|
|
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
ImGui_ImplGlfw_Shutdown();
|
|
ImGui::DestroyContext();
|
|
|
|
|
|
delete mContext;
|
|
}
|
|
|
|
void DebugGUI::procBegin() {
|
|
}
|
|
|
|
void DebugGUI::procEnd() {
|
|
}
|
|
|
|
void DebugGUI::drawBegin() {
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
ImGui_ImplGlfw_NewFrame();
|
|
ImGui::NewFrame();
|
|
}
|
|
|
|
void DebugGUI::drawEnd() {
|
|
ImGui::Render();
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
} |