2021-10-07 14:51:17 +03:30
|
|
|
|
#include "glUserInterface.h"
|
2021-05-27 10:41:32 +04:30
|
|
|
|
|
2021-08-01 16:43:59 +04:30
|
|
|
|
#include "Input/KeyCodes.h"
|
|
|
|
|
|
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
|