2022-01-08 21:57:17 +01:00
|
|
|
#include "gui.hpp"
|
2022-01-09 00:43:33 +01:00
|
|
|
#include "gui_data.hpp"
|
|
|
|
#include "imgui.h"
|
|
|
|
#include "imgui_impl_glfw.h"
|
|
|
|
#include "imgui_impl_opengl3.h"
|
|
|
|
#include "imgui_impl_opengl3_loader.h"
|
|
|
|
#include "window.hpp"
|
|
|
|
|
|
|
|
gui::Gui::Gui(gui::GuiData &data) : data(data), font("font/DejaVuSans.ttf") {
|
2022-01-10 21:16:05 +01:00
|
|
|
SPDLOG_DEBUG("Creating GUI");
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui::CreateContext();
|
|
|
|
ImGui::StyleColorsDark();
|
|
|
|
ImGui::GetIO().Fonts->AddFontFromFileTTF(font.c_str(), 18.0f);
|
|
|
|
ImGui_ImplGlfw_InitForOpenGL(data.get_window().get_window().get(), true);
|
|
|
|
initialized = ImGui_ImplOpenGL3_Init();
|
2022-01-10 21:16:05 +01:00
|
|
|
SPDLOG_DEBUG("Initialized: {}", initialized);
|
2022-01-09 00:43:33 +01:00
|
|
|
}
|
2022-01-08 21:57:17 +01:00
|
|
|
|
|
|
|
gui::Gui::~Gui() noexcept {
|
2022-01-09 00:43:33 +01:00
|
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
|
|
ImGui_ImplGlfw_Shutdown();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui::Gui::render_gui() {
|
|
|
|
if (initialized) {
|
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
ImGui_ImplGlfw_NewFrame();
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
|
|
|
//TODO GUI
|
|
|
|
if (!ImGui::Begin("Billy")) {
|
|
|
|
ImGui::End();
|
|
|
|
ImGui::Render();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ImGui::Text("Hello world!");
|
|
|
|
ImGui::Text("Average framerate: %.3f ms/frame (%.1f FPS)", 1000.f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
ImGui::Render();
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 21:57:17 +01:00
|
|
|
|
2022-01-09 00:43:33 +01:00
|
|
|
void gui::Gui::render_gpu() const {
|
|
|
|
if (initialized) {
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
|
|
}
|
2022-01-08 21:57:17 +01:00
|
|
|
}
|