2021-06-02 17:20:15 +04:30
|
|
|
#include "dxUserInterface.h"
|
|
|
|
|
2021-08-01 16:43:59 +04:30
|
|
|
#include "Input/KeyCodes.h"
|
2022-03-07 21:57:00 +03:30
|
|
|
#include "dxSharedContext.h"
|
2021-08-01 16:43:59 +04:30
|
|
|
|
2021-06-02 17:20:15 +04:30
|
|
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
2022-03-07 21:57:00 +03:30
|
|
|
#include <backends/imgui_impl_dx11.h>
|
|
|
|
#include <backends/imgui_impl_win32.h>
|
2021-06-02 17:20:15 +04:30
|
|
|
#include <glfw/glfw3.h>
|
|
|
|
#include <glfw/glfw3native.h>
|
2021-07-29 17:12:13 +04:30
|
|
|
#include <imgui.h>
|
|
|
|
|
2021-06-02 17:20:15 +04:30
|
|
|
namespace Light {
|
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
void dxUserInterface::PlatformImplementation(GLFWwindow* windowHandle, Ref<SharedContext> sharedContext)
|
|
|
|
{
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
Ref<dxSharedContext> context = std::dynamic_pointer_cast<dxSharedContext>(sharedContext);
|
2021-07-16 19:59:14 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
ImGui_ImplWin32_Init(glfwGetWin32Window(windowHandle));
|
|
|
|
ImGui_ImplDX11_Init(context->GetDevice().Get(), context->GetDeviceContext().Get());
|
|
|
|
}
|
2021-06-02 17:20:15 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
dxUserInterface::~dxUserInterface()
|
|
|
|
{
|
|
|
|
// #todo: handle this in a better way
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
2021-07-23 10:11:20 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
if (io.IniFilename == "default_gui_layout.ini")
|
|
|
|
io.IniFilename = "user_gui_layout.ini";
|
2021-07-23 10:11:20 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
ImGui_ImplDX11_Shutdown();
|
|
|
|
ImGui_ImplWin32_Shutdown();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
}
|
2021-06-02 17:20:15 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
void dxUserInterface::Begin()
|
|
|
|
{
|
|
|
|
ImGui_ImplDX11_NewFrame();
|
|
|
|
ImGui_ImplWin32_NewFrame();
|
|
|
|
ImGui::NewFrame();
|
|
|
|
}
|
2021-06-02 17:20:15 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
void dxUserInterface::End()
|
|
|
|
{
|
|
|
|
ImGui::Render();
|
|
|
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
2021-07-16 19:59:14 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
ImGui::UpdatePlatformWindows();
|
|
|
|
ImGui::RenderPlatformWindowsDefault();
|
|
|
|
}
|
2021-06-02 17:20:15 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
void dxUserInterface::LogDebugData()
|
|
|
|
{
|
|
|
|
// #todo: improve
|
|
|
|
LOG(info, "________________________________________");
|
|
|
|
LOG(info, "UserInterface::");
|
|
|
|
LOG(info, " API : ImGui");
|
|
|
|
LOG(info, " Version: {}", ImGui::GetVersion());
|
|
|
|
LOG(info, " GraphicsAPI : DirectX");
|
|
|
|
LOG(info, "________________________________________");
|
|
|
|
}
|
2021-06-02 17:20:15 +04:30
|
|
|
|
2022-03-07 21:57:00 +03:30
|
|
|
} // namespace Light
|