light/Engine/src/Platform/GraphicsAPI/OpenGL/glUserInterface.cpp

64 lines
1.4 KiB
C++
Raw Normal View History

2021-07-29 17:12:13 +04:30

#include "ltpch.h"
2021-05-27 10:41:32 +04:30
#include "glUserInterface.h"
#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-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()
{
// #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());
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()
{
// #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());
LT_ENGINE_INFO(" GraphicsAPI : OpenGL");
2021-06-01 11:23:41 +04:30
LT_ENGINE_INFO("________________________________________");
}
2021-05-27 10:41:32 +04:30
}