light/modules/engine/src/platform/graphics/opengl/user_interface.cpp

63 lines
1.4 KiB
C++
Raw Normal View History

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 {
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
{
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();
}
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
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