52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#include "gui.hpp"
|
|
#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") {
|
|
SPDLOG_DEBUG("Creating GUI");
|
|
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();
|
|
SPDLOG_DEBUG("Initialized: {}", initialized);
|
|
}
|
|
|
|
gui::Gui::~Gui() noexcept {
|
|
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();
|
|
}
|
|
}
|
|
|
|
void gui::Gui::render_gpu() const {
|
|
if (initialized) {
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
}
|
|
}
|