2025-07-05 13:28:41 +03: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>
|
2025-07-05 13:28:41 +03:30
|
|
|
|
#include <engine/input/key_codes.hpp>
|
|
|
|
|
#include <engine/platform/graphics/opengl/user_interface.hpp>
|
2022-03-07 21:57:00 +03:30
|
|
|
|
#include <imgui.h>
|
2021-05-27 10:41:32 +04:30
|
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
|
void glUserInterface::platform_implementation(
|
2025-07-05 13:28:41 +03:30
|
|
|
|
GLFWwindow *windowHandle,
|
|
|
|
|
Ref<SharedContext> sharedContext
|
|
|
|
|
)
|
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-05 13:28:41 +03:30
|
|
|
|
ImGuiIO &io = ImGui::GetIO();
|
2022-03-07 21:57:00 +03:30
|
|
|
|
|
|
|
|
|
if (io.IniFilename == "default_gui_layout.ini")
|
|
|
|
|
io.IniFilename = "user_gui_layout.ini";
|
|
|
|
|
|
|
|
|
|
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-05 15:36:53 +03:30
|
|
|
|
lt_log(info, "________________________________________");
|
|
|
|
|
lt_log(info, "UserInterface::");
|
|
|
|
|
lt_log(info, " API : ImGui");
|
|
|
|
|
lt_log(info, " Version: {}", ImGui::GetVersion());
|
|
|
|
|
lt_log(info, " GraphicsAPI : OpenGL");
|
|
|
|
|
lt_log(info, "________________________________________");
|
2022-03-07 21:57:00 +03:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Light
|