light/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp

62 lines
1.4 KiB
C++
Raw Normal View History

2022-03-08 21:19:19 +03:30
#include "glUserInterface.hpp"
2021-05-27 10:41:32 +04:30
2022-03-08 21:19:19 +03:30
#include "Input/KeyCodes.hpp"
2021-07-29 17:12:13 +04:30
#include <GLFW/glfw3.h>
2021-09-09 19:46:02 +04:30
#include <backends/imgui_impl_glfw.h>
#include <backends/imgui_impl_opengl3.h>
2022-03-07 21:57:00 +03:30
#include <imgui.h>
2021-05-27 10:41:32 +04:30
namespace Light {
2022-03-07 21:57:00 +03:30
void glUserInterface::PlatformImplementation(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext)
{
m_WindowHandle = windowHandle;
ImGui_ImplGlfw_InitForOpenGL(windowHandle, false);
ImGui_ImplOpenGL3_Init();
}
glUserInterface::~glUserInterface()
{
// #todo: handle this in a better way
ImGuiIO& io = ImGui::GetIO();
if (io.IniFilename == "default_gui_layout.ini")
io.IniFilename = "user_gui_layout.ini";
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void glUserInterface::Begin()
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void glUserInterface::End()
{
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(m_WindowHandle);
}
void glUserInterface::LogDebugData()
{
// #todo: improve
LOG(info, "________________________________________");
LOG(info, "UserInterface::");
LOG(info, " API : ImGui");
LOG(info, " Version: {}", ImGui::GetVersion());
LOG(info, " GraphicsAPI : OpenGL");
LOG(info, "________________________________________");
}
} // namespace Light