2025-07-10 13:29:03 +03:30
|
|
|
#include <GLFW/glfw3.h>
|
2022-03-07 21:57:00 +03:30
|
|
|
#include <imgui.h>
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <input/key_codes.hpp>
|
2025-07-20 05:20:43 +03:30
|
|
|
#include <ui/gl/backend.hpp>
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <ui/gl/ui.hpp>
|
2025-07-20 05:20:43 +03:30
|
|
|
#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
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
void glUserInterface::platform_implementation(
|
2025-07-05 13:28:41 +03:30
|
|
|
GLFWwindow *windowHandle,
|
2025-07-10 13:29:03 +03:30
|
|
|
Ref<SharedContext> /* shared_context */
|
2025-07-05 13:28:41 +03:30
|
|
|
)
|
2022-03-07 21:57:00 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +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
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
if (io.IniFilename == "default_gui_layout.ini")
|
|
|
|
{
|
2022-03-07 21:57:00 +03:30
|
|
|
io.IniFilename = "user_gui_layout.ini";
|
2025-07-10 13:29:03 +03:30
|
|
|
}
|
2022-03-07 21:57:00 +03:30
|
|
|
|
|
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
|
|
ImGui_ImplGlfw_Shutdown();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
}
|
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
void glUserInterface::begin()
|
2022-03-07 21:57:00 +03:30
|
|
|
{
|
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
ImGui_ImplGlfw_NewFrame();
|
|
|
|
ImGui::NewFrame();
|
|
|
|
}
|
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
void glUserInterface::end()
|
2022-03-07 21:57:00 +03:30
|
|
|
{
|
|
|
|
ImGui::Render();
|
|
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
|
|
|
|
|
|
ImGui::UpdatePlatformWindows();
|
|
|
|
ImGui::RenderPlatformWindowsDefault();
|
2025-07-05 14:23:01 +03:30
|
|
|
glfwMakeContextCurrent(m_window_handle);
|
2022-03-07 21:57:00 +03:30
|
|
|
}
|
|
|
|
|
2025-07-05 15:36:53 +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
|