2021-07-29 17:12:13 +04:30
|
|
|
|
|
|
|
|
|
#include "ltpch.h"
|
2021-05-27 10:41:32 +04:30
|
|
|
|
#include "glUserInterface.h"
|
|
|
|
|
|
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-05-27 10:41:32 +04:30
|
|
|
|
#include <imgui.h>
|
2021-09-09 19:46:02 +04:30
|
|
|
|
#include <backends/imgui_impl_glfw.h>
|
|
|
|
|
#include <backends/imgui_impl_opengl3.h>
|
2021-05-27 10:41:32 +04:30
|
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
|
2021-08-11 17:40:01 +04:30
|
|
|
|
void glUserInterface::PlatformImplementation(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext)
|
2021-05-27 10:41:32 +04:30
|
|
|
|
{
|
2021-08-11 17:40:01 +04:30
|
|
|
|
m_WindowHandle = windowHandle;
|
2021-06-19 15:12:42 +04:30
|
|
|
|
|
2021-05-27 12:51:39 +04:30
|
|
|
|
ImGui_ImplGlfw_InitForOpenGL(windowHandle, false);
|
2021-05-27 10:41:32 +04:30
|
|
|
|
ImGui_ImplOpenGL3_Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glUserInterface::~glUserInterface()
|
|
|
|
|
{
|
2021-07-23 10:11:20 +04:30
|
|
|
|
// #todo: handle this in a better way
|
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
|
|
|
|
|
|
if (io.IniFilename == "default_gui_layout.ini")
|
|
|
|
|
io.IniFilename = "user_gui_layout.ini";
|
|
|
|
|
|
2021-05-27 10:41:32 +04:30
|
|
|
|
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());
|
2021-07-16 19:59:14 +04:30
|
|
|
|
|
|
|
|
|
ImGui::UpdatePlatformWindows();
|
|
|
|
|
ImGui::RenderPlatformWindowsDefault();
|
|
|
|
|
glfwMakeContextCurrent(m_WindowHandle);
|
2021-05-27 10:41:32 +04:30
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 11:23:41 +04:30
|
|
|
|
void glUserInterface::LogDebugData()
|
|
|
|
|
{
|
2021-06-19 15:12:42 +04:30
|
|
|
|
// #todo: improve
|
2021-06-01 11:23:41 +04:30
|
|
|
|
LT_ENGINE_INFO("________________________________________");
|
|
|
|
|
LT_ENGINE_INFO("UserInterface::");
|
|
|
|
|
LT_ENGINE_INFO(" API : ImGui");
|
|
|
|
|
LT_ENGINE_INFO(" Version: {}", ImGui::GetVersion());
|
2021-07-01 19:25:46 +04:30
|
|
|
|
LT_ENGINE_INFO(" GraphicsAPI : OpenGL");
|
2021-06-01 11:23:41 +04:30
|
|
|
|
LT_ENGINE_INFO("________________________________________");
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 10:41:32 +04:30
|
|
|
|
}
|