71 lines
1.4 KiB
C++
71 lines
1.4 KiB
C++
#pragma once
|
|
#include <imgui.h>
|
|
#include <backends/imgui_impl_opengl3.h>
|
|
#include <backends/imgui_impl_glfw.h>
|
|
#include <ImGuizmo.h>
|
|
#include "../../src/YoggieEngine.h"
|
|
|
|
|
|
class GUIRenderer {
|
|
public:
|
|
GUIRenderer(YoggieEngine::NativeWindow& window ) {
|
|
IMGUI_CHECKVERSION();
|
|
ImGui::CreateContext();
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
|
|
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
|
|
io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18);
|
|
|
|
ImGui::StyleColorsDark();
|
|
|
|
ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true);
|
|
ImGui_ImplOpenGL3_Init("#version 450");
|
|
|
|
ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext());
|
|
ImGuizmo::SetOrthographic(true);
|
|
|
|
}
|
|
|
|
void Begin ()
|
|
{
|
|
ImGui_ImplGlfw_NewFrame();
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
ImGui::NewFrame();
|
|
ImGuizmo::BeginFrame();
|
|
}
|
|
|
|
void End()
|
|
{
|
|
|
|
ImGui::EndFrame();
|
|
|
|
|
|
ImGui::Render();
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
|
|
|
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
|
{
|
|
GLFWwindow* last_context = glfwGetCurrentContext();
|
|
ImGui::UpdatePlatformWindows();
|
|
ImGui::RenderPlatformWindowsDefault();
|
|
glfwMakeContextCurrent(last_context);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
~GUIRenderer(){
|
|
|
|
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
ImGui_ImplGlfw_Shutdown();
|
|
ImGui::DestroyContext();
|
|
|
|
|
|
}
|
|
};
|