light/modules/ui/private/gl/ui.cpp

65 lines
1.4 KiB
C++
Raw Normal View History

#include <GLFW/glfw3.h>
2022-03-07 21:57:00 +03:30
#include <imgui.h>
#include <input/key_codes.hpp>
#include <ui/gl/backend.hpp>
#include <ui/gl/ui.hpp>
#include <ui/glfw/glfw.h>
2021-05-27 10:41:32 +04:30
2025-07-11 00:05:48 +03:30
namespace lt {
2021-05-27 10:41:32 +04:30
void glUserInterface::platform_implementation(
2025-07-05 13:28:41 +03:30
GLFWwindow *windowHandle,
Ref<SharedContext> /* shared_context */
2025-07-05 13:28:41 +03:30
)
2022-03-07 21:57:00 +03:30
{
m_window_handle = windowHandle;
2022-03-07 21:57:00 +03:30
ImGui_ImplGlfw_InitForOpenGL(windowHandle, false);
ImGui_ImplOpenGL3_Init();
}
glUserInterface::~glUserInterface()
{
// #todo: handle this in a better way
2025-07-06 14:02:50 +03:30
auto &io = ImGui::GetIO();
2022-03-07 21:57:00 +03:30
if (io.IniFilename == "default_gui_layout.ini")
{
2022-03-07 21:57:00 +03:30
io.IniFilename = "user_gui_layout.ini";
}
2022-03-07 21:57:00 +03:30
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void glUserInterface::begin()
2022-03-07 21:57:00 +03:30
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
void glUserInterface::end()
2022-03-07 21:57:00 +03:30
{
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(m_window_handle);
2022-03-07 21:57:00 +03:30
}
void glUserInterface::log_debug_data()
2022-03-07 21:57:00 +03:30
{
// #todo: improve
2025-07-06 16:30:38 +03:30
log_inf("________________________________________");
log_inf("UserInterface::");
log_inf(" API : ImGui");
log_inf(" Version: {}", ImGui::GetVersion());
log_inf(" GraphicsAPI : OpenGL");
log_inf("________________________________________");
2022-03-07 21:57:00 +03:30
}
2025-07-11 00:05:48 +03:30
} // namespace lt